This post will show you how to identify which WordPress plugin options in the wp_options
table belong to a specific plugin. Normally developers will search in the wp_options
table manually with phpMyAdmin or Adminer (WordPress plugin version) but this can often be very tedious as you have to paginate though sometimes hundreds of pages! When we have Linux command line tools available via SSH like WP-CLI and grep, we can efficiently identify which options in the WordPress database belong to a specific plugin and save precious time!
In this post I will show the techniques I normally use for finding these options so that I can correct any settings, back them up etc by matching the WordPress option_name
to the plugin.
Please note that both of these approaches will require a terminal and SSH access of some kind to your WordPress installation.
I will assume WP-CLI and grep are already installed on the Linux system. Both Kinsta and Cloudways provide SSH access which have WP-CLI and grep available.
Find out which WordPress Plugin option_name Database Values
The first 2 techniques use my favorite tool: WP-CLI, after that there is a method using the Linux tool grep
.
WP-CLI
I had a client on Codeable that had about 3 different social sharing plugins! I wanted to write a script using WP-CLI to batch delete all of these WordPress plugin values in the database that were no longer necessary. In this tutorial I will be trying to identify the addthis option_names
in the wp_options
table in the WordPress database.
In this section we will use WP-CLI 🙂
Using WP-CLI option Command
Using the option list
command coupled with restricting the --field
to option_names
only, we can then use grep
to only show us the option_names that contain the addthis
string.
wp option list --field=option_name --allow-root | grep addthis
Here is the output showing all of the option_name
values with the string addthis
addthis_settings
widget_addthis-widget
addthis_shared_settings
addthis_sharing_buttons_settings
If you want to see all of the option_values
for each option_name
containing addthis
, you can use this command which will loop through each of them
wp option list --field=option_name --allow-root | grep addthis | xargs --replace=% wp option get % --allow-root
Note that thesea re serialized arrays
array (
'addthis_social_widget_migrated_to' => 'addthis_sharing_buttons_settings',
)
array (
1 =>
array (
),
'_multiwidget' => 1,
)
array (
'addthis_anonymous_profile' => 'wp-c419021f34068dcd14db1185f724f76c',
'addthis_asynchronous_loading' => true,
'addthis_environment' => '',
'addthis_per_post_enabled' => true,
'addthis_plugin_controls' => 'AddThis',
'addthis_profile' => 'ra-53ce33e04caa78a0',
'addthis_rate_us' => '',
'addthis_rate_us_timestamp' => 1500897630,
'credential_validation_status' => '1',
'wpfooter' => true,
'addthis_twitter_template' => 'biznewsCOM',
'addthis_bitly' => true,
'addthis_share_json' => '',
'addthis_layers_json' => '',
'data_ga_property' => '',
'addthis_language' => '',
'atversion' => 300,
'addthis_append_data' => true,
'addthis_addressbar' => false,
'addthis_508' => false,
'addthis_config_json' => '',
)
array (
'above' => 'disable',
'below' => 'disable',
'addthis_showonexcerpts' => false,
'addthis_aftertitle' => false,
'addthis_beforecomments' => false,
'atversion_update_status' => '0',
'above_chosen_list' => '',
'below_chosen_list' => '',
'addthis_wordpress_version' => '4.0',
'addthis_plugin_version' => '5.3.4',
'addthis_above_showon_home' => true,
'addthis_below_showon_home' => true,
'addthis_above_showon_pages' => true,
'addthis_below_showon_pages' => true,
'addthis_above_showon_categories' => true,
'addthis_below_showon_categories' => true,
'addthis_above_showon_archives' => true,
'addthis_below_showon_archives' => true,
'addthis_above_enabled' => false,
'addthis_below_enabled' => false,
'above_auto_services' => true,
'above_custom_more' => '',
'above_custom_preferred' => '',
'above_custom_services' => '',
'above_custom_size' => '',
'above_custom_string' => '',
'addthis_sidebar_count' => '5',
'addthis_sidebar_enabled' => false,
'addthis_sidebar_position' => 'left',
'addthis_mobile_toolbar_enabled' => false,
'addthis_mobile_toolbar_numPreferredServices' => '4',
'addthis_mobile_toolbar_position' => 'bottom',
'addthis_mobile_toolbar_counts' => true,
'below_auto_services' => true,
'below_custom_more' => '',
'below_custom_preferred' => '',
'below_custom_services' => '',
'below_custom_size' => '',
'below_custom_string' => '',
'location' => 'below',
'style' => 'fb_tw_p1_sc',
'toolbox' => '',
'addthis_above_showon_posts' => true,
'addthis_above_showon_excerpts' => true,
'addthis_below_showon_posts' => true,
'addthis_below_showon_excerpts' => true,
'addthis_sidebar_showon_home' => true,
'addthis_sidebar_showon_posts' => true,
'addthis_sidebar_showon_pages' => true,
'addthis_sidebar_showon_archives' => true,
'addthis_sidebar_showon_categories' => true,
'addthis_mobile_toolbar_showon_home' => true,
'addthis_mobile_toolbar_showon_posts' => true,
'addthis_mobile_toolbar_showon_pages' => true,
'addthis_mobile_toolbar_showon_archives' => true,
'addthis_mobile_toolbar_showon_categories' => true,
)
If they are serialized arrays this will put them in the json format by employing the --format
flag.
wp option list --field=option_name --allow-root | grep addthis | xargs --replace=% wp option get % --format=json --allow-root
Notice the output is now in json format
{"addthis_social_widget_migrated_to":"addthis_sharing_buttons_settings"}
{"1":[],"_multiwidget":1}
{"addthis_anonymous_profile":"wp-c419021f34068dcd14db1185f724f76c","addthis_asynchronous_loading":true,"addthis_environment":"","addthis_per_post_enabled":true,"addthis_plugin_controls":"AddThis","addthis_profile":"ra-53ce33e04caa78a0","addthis_rate_us":"","addthis_rate_us_timestamp":1500897630,"credential_validation_status":"1","wpfooter":true,"addthis_twitter_template":"biznewsCOM","addthis_bitly":true,"addthis_share_json":"","addthis_layers_json":"","data_ga_property":"","addthis_language":"","atversion":300,"addthis_append_data":true,"addthis_addressbar":false,"addthis_508":false,"addthis_config_json":""}
{"above":"disable","below":"disable","addthis_showonexcerpts":false,"addthis_aftertitle":false,"addthis_beforecomments":false,"atversion_update_status":"0","above_chosen_list":"","below_chosen_list":"","addthis_wordpress_version":"4.0","addthis_plugin_version":"5.3.4","addthis_above_showon_home":true,"addthis_below_showon_home":true,"addthis_above_showon_pages":true,"addthis_below_showon_pages":true,"addthis_above_showon_categories":true,"addthis_below_showon_categories":true,"addthis_above_showon_archives":true,"addthis_below_showon_archives":true,"addthis_above_enabled":false,"addthis_below_enabled":false,"above_auto_services":true,"above_custom_more":"","above_custom_preferred":"","above_custom_services":"","above_custom_size":"","above_custom_string":"","addthis_sidebar_count":"5","addthis_sidebar_enabled":false,"addthis_sidebar_position":"left","addthis_mobile_toolbar_enabled":false,"addthis_mobile_toolbar_numPreferredServices":"4","addthis_mobile_toolbar_position":"bottom","addthis_mobile_toolbar_counts":true,"below_auto_services":true,"below_custom_more":"","below_custom_preferred":"","below_custom_services":"","below_custom_size":"","below_custom_string":"","location":"below","style":"fb_tw_p1_sc","toolbox":"","addthis_above_showon_posts":true,"addthis_above_showon_excerpts":true,"addthis_below_showon_posts":true,"addthis_below_showon_excerpts":true,"addthis_sidebar_showon_home":true,"addthis_sidebar_showon_posts":true,"addthis_sidebar_showon_pages":true,"addthis_sidebar_showon_archives":true,"addthis_sidebar_showon_categories":true,"addthis_mobile_toolbar_showon_home":true,"addthis_mobile_toolbar_showon_posts":true,"addthis_mobile_toolbar_showon_pages":true,"addthis_mobile_toolbar_showon_archives":true,"addthis_mobile_toolbar_showon_categories":true}
If they are serialized you can save them all to separate files for inspection with this mini bash script loop
WPPATH=""
WPFLAGS="--path=${WPPATH} --skip-plugins --skip-themes --allow-root"
# path to store option values without trailing slash
OPTIONPATH=/tmp
OPTIONNAME="addthis"
OPTIONLIST=($(wp option list --field=option_name ${WPFLAGS} | grep ${OPTIONNAME}))
for OPTION in ${OPTIONLIST[@]};
do
wp option get ${OPTION} --format=json ${WPFLAGS} > ${OPTIONPATH}/${OPTION}.txt
done
You will have a separate file for each option_name
in the /tmp
folder to peruse afterwards.
If you do not want them in json format then this should do the trick
WPPATH=""
WPFLAGS="--path=${WPPATH} --skip-plugins --skip-themes --allow-root"
# path to store option values without trailing slash
OPTIONPATH=/tmp
OPTIONNAME="addthis"
OPTIONLIST=($(wp option list --field=option_name ${WPFLAGS} | grep ${OPTIONNAME}))
for OPTION in ${OPTIONLIST[@]};
do
wp option get ${OPTION} ${WPFLAGS} > ${OPTIONPATH}/${OPTION}.txt
done
If it is an option_value
rather than an option_name
you are looking for in the WordPress plugin, try this and replace addthis
with the value you are searching for
wp option list --field=option_value --allow-root | grep addthis
herp
a:1:{s:33:"addthis_social_widget_migrated_to";s:32:"addthis_sharing_buttons_settings";}
a:21:{s:25:"addthis_anonymous_profile";s:35:"wp-c419021f34068dcd14db1185f724f76c";s:28:"addthis_asynchronous_loading";b:1;s:19:"addthis_environment";s:0:"";s:24:"addthis_per_post_enabled";b:1;s:23:"addthis_plugin_controls";s:7:"AddThis";s:15:"addthis_profile";s:19:"ra-53ce33e04caa78a0";s:15:"addthis_rate_us";s:0:"";s:25:"addthis_rate_us_timestamp";i:1500897630;s:28:"credential_validation_status";s:1:"1";s:8:"wpfooter";b:1;s:24:"addthis_twitter_template";s:10:"biznewsCOM";s:13:"addthis_bitly";b:1;s:18:"addthis_share_json";s:0:"";s:19:"addthis_layers_json";s:0:"";s:16:"data_ga_property";s:0:"";s:16:"addthis_language";s:0:"";s:9:"atversion";i:300;s:19:"addthis_append_data";b:1;s:18:"addthis_addressbar";b:0;s:11:"addthis_508";b:0;s:19:"addthis_config_json";s:0:"";}
a:56:{s:5:"above";s:7:"disable";s:5:"below";s:7:"disable";s:22:"addthis_showonexcerpts";b:0;s:18:"addthis_aftertitle";b:0;s:22:"addthis_beforecomments";b:0;s:23:"atversion_update_status";s:1:"0";s:17:"above_chosen_list";s:0:"";s:17:"below_chosen_list";s:0:"";s:25:"addthis_wordpress_version";s:3:"4.0";s:22:"addthis_plugin_version";s:5:"5.3.4";s:25:"addthis_above_showon_home";b:1;s:25:"addthis_below_showon_home";b:1;s:26:"addthis_above_showon_pages";b:1;s:26:"addthis_below_showon_pages";b:1;s:31:"addthis_above_showon_categories";b:1;s:31:"addthis_below_showon_categories";b:1;s:29:"addthis_above_showon_archives";b:1;s:29:"addthis_below_showon_archives";b:1;s:21:"addthis_above_enabled";b:0;s:21:"addthis_below_enabled";b:0;s:19:"above_auto_services";b:1;s:17:"above_custom_more";s:0:"";s:22:"above_custom_preferred";s:0:"";s:21:"above_custom_services";s:0:"";s:17:"above_custom_size";s:0:"";s:19:"above_custom_string";s:0:"";s:21:"addthis_sidebar_count";s:1:"5";s:23:"addthis_sidebar_enabled";b:0;s:24:"addthis_sidebar_position";s:4:"left";s:30:"addthis_mobile_toolbar_enabled";b:0;s:43:"addthis_mobile_toolbar_numPreferredServices";s:1:"4";s:31:"addthis_mobile_toolbar_position";s:6:"bottom";s:29:"addthis_mobile_toolbar_counts";b:1;s:19:"below_auto_services";b:1;s:17:"below_custom_more";s:0:"";s:22:"below_custom_preferred";s:0:"";s:21:"below_custom_services";s:0:"";s:17:"below_custom_size";s:0:"";s:19:"below_custom_string";s:0:"";s:8:"location";s:5:"below";s:5:"style";s:11:"fb_tw_p1_sc";s:7:"toolbox";s:0:"";s:26:"addthis_above_showon_posts";b:1;s:29:"addthis_above_showon_excerpts";b:1;s:26:"addthis_below_showon_posts";b:1;s:29:"addthis_below_showon_excerpts";b:1;s:27:"addthis_sidebar_showon_home";b:1;s:28:"addthis_sidebar_showon_posts";b:1;s:28:"addthis_sidebar_showon_pages";b:1;s:31:"addthis_sidebar_showon_archives";b:1;s:33:"addthis_sidebar_showon_categories";b:1;s:34:"addthis_mobile_toolbar_showon_home";b:1;s:35:"addthis_mobile_toolbar_showon_posts";b:1;s:35:"addthis_mobile_toolbar_showon_pages";b:1;s:38:"addthis_mobile_toolbar_showon_archives";b:1;s:40:"addthis_mobile_toolbar_showon_categories";b:1;}
Searching the Database with WP-CLI
This command will search the wp_options
table only in both the option_name
and option_value
columns.
We are using the helpful wp db prefix
command as well.
wp db search "addthis" $(wp db prefix --allow-root)options --allow-root
Here is the output
aue_options:option_name
251966:addthis_settings
aue_options:option_name
2868184:addthis_shared_settings
aue_options:option_name
2868185:addthis_sharing_buttons_settings
aue_options:option_name
257106:widget_addthis-widget
aue_options:option_value
251966:a:1:{s:33:"addthis_social_widget_migrated_to";s:32:"addthis_sharing_buttons_settings";}
aue_options:option_value
392010:link-to-facebook.php";s:5:"1.212";s:33:"addthis/addthis_social_widget.php";s:3:"4.0";s:43:"brok [...] /add-link-to-facebook.1.212.zip";}s:33:"addthis/addthis_social_widget.php";O:8:"stdClass":7:{s: [...] :7:{s:2:"id";s:4:"5710";s:4:"slug";s:7:"addthis";s:6:"plugin";s:33:"addthis/addthis_social_widget.php";s:11:"new_version";s [...] rl";s:38:"https://wordpress.org/plugins/addthis/";s:7:"package";s:57:"https://downloads [...] "https://downloads.wordpress.org/plugin/addthis.3.5.10.zip";}s:43:"broken-link-checker/
aue_options:option_value
2868184:a:21:{s:25:"addthis_anonymous_profile";s:35:"wp-c419021f340 [...] c419021f34068dcd14db1185f724f76c";s:28:"addthis_asynchronous_loading";b:1;s:19:"addthis_environment";s:0:"";s:24:"addthis_per_post_enabled";b:1;s:23:"addthis_plugin_controls";s:7:"AddThis";s:15:"addthis_profile";s:19:"ra-53ce33e04caa78a0";s:1 [...] ofile";s:19:"ra-53ce33e04caa78a0";s:15:"addthis_rate_us";s:0:"";s:25:"addthis_rate_us_timestamp";i:1500897630;s:28:"c [...] tatus";s:1:"1";s:8:"wpfooter";b:1;s:24:"addthis_twitter_template";s:10:"biznewsCOM";s:1 [...] itter_template";s:10:"biznewsCOM";s:13:"addthis_bitly";b:1;s:18:"addthis_share_json";s:0:"";s:19:"addthis_layers_json";s:0:"";s:16:"data_ga_prope [...] "";s:16:"data_ga_property";s:0:"";s:16:"addthis_language";s:0:"";s:9:"atversion";i:300; [...] age";s:0:"";s:9:"atversion";i:300;s:19:"addthis_append_data";b:1;s:18:"addthis_addressbar";b:0;s:11:"addthis_508";b:0;s:19:"addthis_config_json";s:0:"";}
aue_options:option_value
2868185:isable";s:5:"below";s:7:"disable";s:22:"addthis_showonexcerpts";b:0;s:18:"addthis_aftertitle";b:0;s:22:"addthis_beforecomments";b:0;s:23:"atversion_upd [...] ";s:17:"below_chosen_list";s:0:"";s:25:"addthis_wordpress_version";s:3:"4.0";s:22:"addthis_plugin_version";s:5:"5.3.4";s:25:"addthis_above_showon_home";b:1;s:25:"addthis_below_showon_home";b:1;s:26:"addthis_above_showon_pages";b:1;s:26:"addthis_below_showon_pages";b:1;s:31:"addthis_above_showon_categories";b:1;s:31:"addthis_below_showon_categories";b:1;s:29:"addthis_above_showon_archives";b:1;s:29:"addthis_below_showon_archives";b:1;s:21:"addthis_above_enabled";b:0;s:21:"addthis_below_enabled";b:0;s:19:"above_auto_ser [...] s:19:"above_custom_string";s:0:"";s:21:"addthis_sidebar_count";s:1:"5";s:23:"addthis_sidebar_enabled";b:0;s:24:"addthis_sidebar_position";s:4:"left";s:30:"addthis_mobile_toolbar_enabled";b:0;s:43:"addthis_mobile_toolbar_numPreferredServices";s: [...] bar_numPreferredServices";s:1:"4";s:31:"addthis_mobile_toolbar_position";s:6:"bottom";s [...] le_toolbar_position";s:6:"bottom";s:29:"addthis_mobile_toolbar_counts";b:1;s:19:"below_ [...] fb_tw_p1_sc";s:7:"toolbox";s:0:"";s:26:"addthis_above_showon_posts";b:1;s:29:"addthis_above_showon_excerpts";b:1;s:26:"addthis_below_showon_posts";b:1;s:29:"addthis_below_showon_excerpts";b:1;s:27:"addthis_sidebar_showon_home";b:1;s:28:"addthis_sidebar_showon_posts";b:1;s:28:"addthis_sidebar_showon_pages";b:1;s:31:"addthis_sidebar_showon_archives";b:1;s:33:"addthis_sidebar_showon_categories";b:1;s:34:"addthis_mobile_toolbar_showon_home";b:1;s:35:"addthis_mobile_toolbar_showon_posts";b:1;s:35:" [...] _mobile_toolbar_showon_posts";b:1;s:35:"addthis_mobile_toolbar_showon_pages";b:1;s:38:" [...] _mobile_toolbar_showon_pages";b:1;s:38:"addthis_mobile_toolbar_showon_archives";b:1;s:4 [...] bile_toolbar_showon_archives";b:1;s:40:"addthis_mobile_toolbar_showon_categories";b:1;}
If the wp_options
table is empty, you can search all of the tables with the --all-tables
flag (Source)
wp db search "addthis" --all-tables --allow-root
The above commmand can help catch WordPress plugin options that may live outside of the wp_options
table.
Using Grep
grep
is a fantastic tool for scanning files for a specific string extremely efficiently.
In this command we are searching for the update_option
string in the addthis
plugin folder’s files.
We can restrict the search to .php files only by using the --include
flag with grep
grep -rHin update_option wp-content/plugins/addthis/ --include \*.php
The output is the filename that contains the string, the line number and then the context before and after the occurrence of that string
wp-content/plugins/addthis/backend/AddThisFollowButtonsFeature.php:206: update_option('widget_' . $newWidgetsName, $newWidgetSettings);
wp-content/plugins/addthis/backend/AddThisFollowButtonsFeature.php:238: update_option('sidebars_widgets', $sideBarConfigs);
wp-content/plugins/addthis/backend/AddThisSharingButtonsFeature.php:440: update_option('widget_addthis_tool_by_class_name_widget', $outputWidgets);
wp-content/plugins/addthis/backend/AddThisFeature.php:721: update_option($this->settingsVariableName, $this->configs);
wp-content/plugins/addthis/backend/AddThisRegistrationFeature.php:761: update_option('smart_layer_profile', $profileId);
wp-content/plugins/addthis/backend/AddThisRegistrationFeature.php:765: update_option('addthis_settings', $configs);
Hopefully this helps you track down and identify some of those option_names
you are looking to backup, delete or modify on your WooCommerce store or WordPress site 🙂
2 thoughts on “Find out which WordPress Database Options Belong to Plugins”
Comments are closed.