I have a wordpress script, wp-supercache, that I need to disable (as its cached on a nasty error), however, the error is causing the wp-admin redirect to fail, which means I can't get into the site to disable the plugin.
Any advice? I can access the database via cpanel.
Try re-naming the folder of the plugin and then see if error is gone (make backup first of course.). If that does not help, here is the solution then.
To disable a specific plugin, you have to remove it from the serialized string that stores the list of all plugins - that's set in the option_value column of the wp_options table as discussed by #TimDurden. The specific format change you have to make is, taken shamelessly from teh Internet:
a:4:{
i:0;s:19:"akismet/akismet.php";
i:1;s:36:"google-sitemap-generator/sitemap.php";
i:2;s:55:"google-syntax-highlighter/google_syntax_highlighter.php";
i:3;s:29:"wp-swfobject/wp-swfobject.php";
}
That first set of characters - a:4 - designates an array and its length. Note also that each line in the list of plugins has an index. So:
Decrement the index (from 4 to 3 in this case)
In each line, decrement the number after the i:
Remove the specific plugin you want to disable.
Update the value in the db using the new string you constructed from these steps:
update wp_options set option_value=<new value> where option_id=<id of this option>
Note that your table name might not be wp_options - you might have a prefix to add.
You only need to rename the folder in /wp-content/plugins/ and the plugin will be automatically de-activated. Once it is de-activated, you will be able to login.
Backup database or just the wp_options table
SELECT option_value FROM wp_options WHERE option_name = 'active_plugins';
Copy selected string (serialized string) and paste in the left side at https://serializededitor.com/
Remove the line which plugin you want to deactivate
Copy the serialized result string from the right side and update active_plugins value with it.
UPDATE wp_options
SET option_value = 'THE_NEW_SERIALIZED_STRING'
WHERE option_name = 'active_plugins' LIMIT 1;
I wrote a little exe in .dot to repair/remove options string from database.
Download exe here
Run on MySQL server
SELECT * FROM wp_options WHERE option_name = 'active_plugins';
Paste Results in textbox, press parse.
Remove the ones you don't want.
Click output, it copies output to clipboard
replace brackets inside the single quotes below with output and Run on MySQL server
UPDATE wp_options SET option_value = '[replace inside single quotes with your output' WHERE option_name = 'active_plugins';
No warranties... I don't claim to be programmer
To disable all Wordpress plugins on your site:
Login to your database management tool (e.g. PHPMyAdmin)
Execute the following query:
UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins';
Another way to do this is you can backup the site and then just rename the folder of the plugin under /wp-content/plugins/ to some other name . So the plugin will be disabled.
I wont prefer deleting the plugin folder as it may cause errors.
After the step is done log in to your wordpress site and delete the plugin from there
You just need to change the values in the record "active_plugins" in the database. You can find the process Here
Late answer,but answering as it will be useful to someone in the future. All the plugins are stored in the wp_options table in a serialized manner. U can edit this field manually. Or if you unserialize it using a function like in php using unserialize(), you will get an array. just modify it to remove the plugin you want to remove from that array, and serialize it back. then update the table. Thats it. If you want to know more about it here is a good article. It explains all about this.
Using this code you can activate your plugin from the functions.php:
function activate_plugin_via_php() {
$active_plugins = get_option( 'active_plugins' );
array_push($active_plugins, 'unyson/unyson.php'); /* Here just replace unyson plugin directory and plugin file*/
update_option( 'active_plugins', $active_plugins );
}
add_action( 'init', 'activate_plugin_via_php' );
Related
I had a project on localhost, now in wamp I setted virtual domain. Now the local project opens fine on domain address but resource files on pages are not loading. In source code of pages css and js files are still linked with 'localhost' hence are not found.
Its very simple
Edit wp-config.php
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
Edit functions.php
and add the line
<?php
update_option('siteurl','http://example.com');
update_option('home','http://example.com');
?>
Take care of permalinks .htacess file & database resources links
You can check here
In your wp-config.php, add these two lines.
define('WP_HOME','sitename/');
define('WP_SITEURL','sitename/');
Also, you need to edit the SQL file to change the resource locations.
I wrote this tutorial which shows you how to do that.
It's here, on my blog.
If you want to maintain your ability to upgrade WordPress in one click, never edit the WordPress core code. Instead, you can use their recommended (clean "drop-in") solution:
Create a new file at /wp-content/db.php with this content:
<?php
/**
* #see http://codex.wordpress.org/Running_a_Development_Copy_of_WordPress
*/
add_filter('pre_option_home', 'test_localhosts');
add_filter('pre_option_siteurl', 'test_localhosts');
function test_localhosts()
{
if (isDevEnvironment($_SERVER)) {
return "http://mysite.local/blog"; //Specify your local dev URL here.
} else {
return false; // act as normal; will pull main site info from db
}
}
/**
* Logic to determine the environment (dev or prod)
* #return bool
*/
function isDevEnvironment($serverArray)
{
return strpos($serverArray['SERVER_NAME'], 'mysite.local') !== false;//Edit this function such that it returns a boolean based on your specific URL naming convention.
}
Now, your local development environment will use its own base URL, and then when you deploy a copy of your codebase to a production environment, it will use its production base URL automatically.
Try this:
You need to change your local links to live links.
For that, Update your database with some query.
:: Queries to change URL for WP Website
UPDATE pvgc_options
SET option_value = replace(option_value, 'http://pleasantviewgarden.hideoutdev.co.uk/',
'http://pleasantviewgardencentre.com/')
WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE pvgc_postmeta
SET meta_value = replace(meta_value, "http://whynickoli.com/", "http://localhost/onestopproperty/");
UPDATE pvgc_posts
SET guid = REPLACE(guid, "http://whynickoli.com/", "http://sparsh-technologies.co.in/megha/onestopproperty/");
UPDATE pvgc_posts
SET post_content = REPLACE(post_content, "http://whynickoli.com/",
"http://sparsh-technologies.co.in/megha/onestopproperty/");
Here you should use your domain.
Thanks!
Edit the wp-config.php settings for a new domain:
define('WP_HOME','siteurl');
define('WP_SITEURL','siteurl');
Search and replace on the database with InterconnectIT Search and Replace Tool. With that tool it's easy to search through the entire database for all occurrences of old domain, and replace that with the name of new domain
my problems started when I moved my website to another folder (from /dev/ to /).
I have gone through the whole database in order to change all the hardcoded /dev/ into / but I still notice that wordpress, somehow, still uses the old values.
Basically the website uses information that are not there anymore.
I checked my own and the server cache and they all seem to be clean (the server doesn't even seem to have that feature on).
So, I am pretty much lost...
When you move a wordpress install, you need to change the site URL throughout your database. To do this you'll need to export your current database via PHP MyAdmin, and then use a tool like:
http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
...to do a search and replace on the entire database.
Search for:
www.yourwebsite.com/dev
replace with:
www.yourwebsite.com
Then import the new database, open your Wordpress site via wp-admin and re-save permalinks.
Run this query in your database
set #oldurl = 'http://oldwp-url.com', #newurl = 'http://newwp-url.com';
UPDATE wp_options SET option_value = replace(option_value, #oldurl, #newurl) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE (guid, #oldurl, #newurl);
UPDATE wp_posts SET post_content = REPLACE (post_content, #oldurl, #newurl);
UPDATE wp_posts SET post_content = REPLACE (post_content, CONCAT('src="', #oldurl), CONCAT('src="', #newurl));
UPDATE wp_posts SET guid = REPLACE (guid, #oldurl, #newurl) WHERE post_type = 'attachment';
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, #oldurl, #newurl);
I was going to update the ecommerce plugin (Shopp) on my wordpress site and it asked me to deactivate it. once I did that I lost the entire site.
I am trying to activate the plugin through the php files, but not sure what I am doing and would like some help.
Does anyone know how I can activate the Shopp plugin (or any plugin for that matter) on my site through the php files?
This is the code I'm using to get the string:
$unserialized = unserialize('a:14:{i:0;s:19:"akismet/akismet.php";i:1;s:37:"breadcrumbs-plus/breadcrumbs-plus.php";i:2;s:35:"googleanalytics/googleanalytics.php";i:3;s:45:"grunion-contact-form/grunion-contact-form.php";i:4;s:43:"image-caption-links/image-caption-links.php";i:5;s:29:"image-widget/image-widget.php";i:6;s:13:"rate/rate.php";i:7;s:33:"restore-jquery/restore-jquery.php";i:8;s:41:"shopp-cache-helper/shopp-cache-helper.php";i:9;s:47:"shopp-default-breadcrumb-extender-sdbe/sdbe.php";i:10;s:33:"shopp-improved/shopp-improved.php";i:11;s:19:"shuffle/shuffle.php";i:12;s:19:"vslider/vslider.php";i:13;s:41:"wordpress-importer/wordpress-importer.php";}');
array_push($unserialized, 'shopp/shopp.php');
$serialized = serialize($unserialize);
echo $serialized;
The active plugins are not stored in a PHP file. It's stored in the database. Open the wp_options table in the database. Look for a row in which the value of the option_name field is active_plugins. In this row, look for the value of option_value. You'll see a serialized string containing the information of the active plugins.
Now, it might be a little bit confusing to edit the string straight away especially if you're not familiar how serialized strings are formatted. So, I suggest you copy the string and use PHP unserialize() function on it, which will then return an array. After that, use array_push() to add another element in which the value is the path to the plugins file (e.g. "akismet/akismet.php", in your case it might be "shopp/shopp.php"). Once you've add another element, use serialize() and copy the returned string and replace the old serialized string in the database.
$unserialized = unserialize('...');
array_push($unserialized, 'shopp/shopp.php');
$serialized = serialize($unserialized);
echo $serialized; // Copy this output back into the database
There are details on this site about how to programmatically activate and deactivate a plugin. Here is a snippet:
function toggle_plugin() {
// Full path to WordPress from the root
$wordpress_path = '/full/path/to/wordpress/';
// Absolute path to plugins dir
$plugin_path = $wordpress_path.'wp-content/plugins/';
// Absolute path to your specific plugin
$my_plugin = $plugin_path.'my_plugin/my_plugin.php';
// Check to see if plugin is already active
if(is_plugin_active($my_plugin)) {
// Deactivate plugin
// Note that deactivate_plugins() will also take an
// array of plugin paths as a parameter instead of
// just a single string.
deactivate_plugins($my_plugin);
}
else {
// Activate plugin
activate_plugin($my_plugin);
}
}
For everyone who has a plugin acting weird
The easiest way to regain access to your site when being locked out after deactivating, activating, installing, updating a plugin is:
Go to your webhost adminpanel (Cpanel, DirectAdmin)
Go to Files (Filemanager)
Go to //wp-content/ and rename your "plugins" folder to something else for instance "plugins_off"
Go to your WP-admin. You will have access again but no plugins visible.
Go back to your webhost adminpanel and rename "plugins_off" back to "plugins".
Now your plugins will all be listed again in WP-admin, but all deactivated.
Take it from there.
There is no need to add PHP code.
Like RST wrote: No need for coding to restore site that crashed after you deactivate a plugin. There's a good reason the site crashed because other plugins depended on that deactivated plugin (like WooCommerce).
The easiest way to restore the site and gain access to WP admin is simply to rename the plugins folder, refresh the page, go back and rename the folder back to "plugins" then hit refresh again. All plugins will be back as before only they are all deactivated. Now all you need to do is to activate them again. Do it one by one to be sure nothing else crashes.
Here is working code
(just uncomment "activate" line):
function MY_toggle_plugins() {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
$temp_files1 = glob(WP_PLUGIN_DIR.'/*');
$activated=array();
$already_active=array();
foreach($temp_files1 as $file1){
if(is_dir($file1)) {
$temp_files2 = glob($file1 . '/*');
foreach($temp_files2 as $file2){
if(is_file($file2) && stripos(file_get_contents($file2),'Plugin Name:')!==false) {
$plugin_name_full=basename(dirname($file2)).'/'.basename($file2);
if(is_plugin_active($plugin_name_full)) {
array_push($already_active, $plugin_name_full);
//deactivate_plugins($plugin_name_full);
}
else{
array_push($activated, $plugin_name_full);
//activate_plugin($plugin_name_full);
}
}
}
}
}
echo 'You have activated these plugins:<br/><br/>'.serialize($activated).'<br/><br/>These were already active:<br/><br/>'.serialize($already_active); exit;
}
//execute
MY_toggle_plugins();
Can I set the default in phpMyAdmin to open in structure instead of browse?
thanks
If perchance you are using the "quick access icon" next to the table name in the navigation frame, this may be configured.
From the configuration file documentation:
$cfg['LeftDefaultTabTable'] string
Defines the tab displayed by default when clicking the small icon
next to each table name in the
navigation panel. Possible values:
"tbl_structure.php", "tbl_sql.php",
"tbl_select.php", "tbl_change.php" or
"sql.php".
For MAMP 3.x the DefaultTabTable configuration parameter applies. It needs to be set in MAMP/bin/phpMyAdmin/config.inc.php, e.g.:
$cfg['DefaultTabTable'] = 'sql.php';
As I said in my comment, you can click on the little table icon to the left of the table name (assuming, as Mike B said, we are talking about the table list on the left) and it will open up the table structure page.
AFAIK, switching the behavior on those links is not possible through a configuration directive. You would have to dig through the code and change it in there. Shouldn't be too complicated, though.
Add:
$cfg['DefaultTabTable'] = 'tbl_structure.php';
To either config.inc.php or config.default.php.
You can also change LeftDefaultTabTable which changes the icon. The options are:
'tbl_structure.php' = fields list
'tbl_sql.php' = SQL form
'tbl_select.php' = search page
'tbl_change.php' = insert row page
'sql.php' = browse page
In phpMyAdmin 4.8.2...
Click the double gears icon at the top of the left navigation pane.
Then click the "Tables" tab within the popup modal. (last tab)
There you can set the "Target for quick access icon" setting, which is referring to the little index card icon to the left of the table links in the left pane.
I didn't see any settings to change the default link behavior, but you can also add an additional "Target for second quick access icon" and define it's default view behavior differently if desired. It adds an additional "Quick access" icon to the left of the table links with your chosen behavior.
I use an old version of XAMPP (1.6.7) which contains an old version of phpMyAdmin (2.11.7), but the following worked for me.
In the /phpmyadmin/libraries/config.default.php file there is a section of code that handles how the table is viewed.
Change the last two lines of code to suit your purposes, for mine I wanted to open tables in "Browse" view, not "Structure" view (which was my default).
/**
* Possible values:
* 'tbl_structure.php' = fields list
* 'tbl_sql.php' = SQL form
* 'tbl_select.php' = select page
* 'tbl_change.php' = insert row page
* 'sql.php' = browse page
*
* #global string $cfg['DefaultTabTable']
*/
// Show table Structure - Default
$cfg['DefaultTabTable'] = 'tbl_structure.php';
// Uncomment below to show table data
// $cfg['DefaultTabTable'] = 'sql.php';
Save this config file and refresh PhpMyAdmin in your browser.
Hope that helps!
In version 3.5.1: go to the PhpMyAdmin home page -> Settings -> Navigation Frame -> Tables tab. Here you will find an option "Target for quick access icon", and set it
"sql.php" if you want it to go to the Browse tab
"tbl_structure.php" if you want it to go to the Structure tab
"tbl_sql.php" if you want it to go to the SQL tab
"tbl_select.php" if you want it to go to the Search tab
"tbl_change.php" if you want it to go to the Insert tab.
Then Save.
This way when you will click on the table name, it will go to the structure; and when clicking on the little icon before the table name, it will go to the tab you just set.
navigation.php
Around Line #646 in phpMyAdmin version 3.3.8
Insert
$href = $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
. $GLOBALS['common_url_query']
.'&table=' . urlencode($table['Name'])
.'&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable'];
AFTER
$href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
.$GLOBALS['common_url_query'] . '&table='
.urlencode($table['Name']) . '&pos=0';
to make the text field name link in the navigation to behave the same as the little icon to the left of it.
In my version, the configuration setting for it is supposed to be
$cfg['DefaultTabTable'] = 'tbl_structure.php';
It is listed in sample config file. However, /libraries/navigation/Nodes/Node_Table.class.php on line 34 ignores this setting and uses 'sql.php' directly. I changed that line to
'text' => $GLOBALS['cfg']['DefaultTabTable'].'?server=' . $GLOBALS['server']
On that line and it works fine for me.
Go to phpMyAdmin/config.inc.php
find line starting
$cfg['DefaultTabTable']
and set it to value
$cfg['DefaultTabTable'] = 'browse';
Restart Apache, empty session data (second icon under phpMyAdmin logo, alternatively log-out and log-in, not sure if this step is needed, some configs are cached in user's session)
This solved the issue in MAMP 5.7 (i.e. if you click on table name in left navigation tree, the Browse tab is open). PhpMyAdmin is located in MAMP/bin folder
I was following the instructions from etheros and wasn't able to find that configuration option, but it can just be added (to the confic.inc.php file). In my config file, I added it to the "Left frame setup" section, around line 160.
Depending on the phpMyAdmin version either of these should work:
$cfg['LeftDefaultTabTable'] = 'tbl_structure.php';
$cfg['NavigationTreeDefaultTabTable'] = 'tbl_structure.php';
Also you may actually be saving these setting in the phpmyadmin database, table=pma__userconfig. Go ot the phpmyadmin home and click Settings -> Navigation Frame ->Tables -> Target for quick access icon
I need to assign the "active" theme via script. Anyone know the API call needed to do this? Also, how do I retrieve the current theme via script (PHP)?
Update current_theme option:
update_option('current_theme', '[theme name]');
To get the theme's name use:
$themes = get_themes();
In current Wordpress version 3.4.2 you need to update 3 options to switch to another theme(minihyper - in my case)
update_option('template', 'minihyper');
update_option('stylesheet', 'minihyper');
update_option('current_theme', 'Mini Hyper');
The first two options are key, the third really does nothing except maybe you can use this option somewhere in code to display current theme name.
Update:
Here is a true way:
<?php switch_theme( $template, $stylesheet ) ?>
Example with minihyper:
<?php switch_theme( 'minihyper', 'minihyper' ) ?>