Tag Info

Hot answers tagged

7

Ajax in WordPress works by sending an HTTP post to /wp-admin/admin-ajax.php (by default) that then fires the corresponding hook. So, you attach some jquery to an event triggered by your delete button, which then posts to admin-ajax.php, which has an action, say, delete_my_options(), which actually runs the php to delete. Then, you have a function, called a ...


7

There is no index because the need for it was never strong enough. In ticket #14258 it was suggested, but since most options use autoload=yes by default, the index would be ignored anyway. There is also the still open ticket #24044 _Add index to wp_options to aid/improve performance_. I think you should create an index. It will survive upgrades. It might ...


6

Yes, sort of. When the get_option call is made, WordPress runs a function called wp_load_alloptions, which either grabs a cached copy of all autoloaded options or loads all those options into the cache. Then wp_load_alloptions returns an array of all the autoloaded options. If your option is autoloaded (specified when you use the add_option function), it ...


4

Yep, this does seem like a cron issue. Core Control plugin is good to diagnose cron tasks (among other things). I am still unsure what is the reason of you getting overrun with feed transients. However I had written some code that might help with automatic cleanup.


4

It makes sense that if it's faster to use a new table for a thousand entries, it must also be faster for tens or hundreds of entries. Performance is not about the pure number rows – the real amount of data and their structure counts. Usually, you use just the theme mod API. Your theme data is on a predictable place and can easily exported or changed by ...


4

Assuming this array for example usage: $options = array( "name" => __('Font','mytheme'), "desc" => __('Change the font face)','mytheme'), "id" => "mytheme_font", "std" => array('size' => '10px', 'face' => 'Arial', 'color' => '#000000'), "type" => "text", ); For question 1, to reference nested arrays, just ...


4

This is not an amount that is likely to cause performance issues. However if you are concerned about leftover transients it is worth looking into if any code you are using is consistently "leaking" them (creating transients that are never removed). See Are transients garbage collected? for relevant discussion and some code snippets.


3

Update: The reason the query is being logged is it doesn't use an index. The query time is 0, i.e. it actually executes fast. You can unset the "log-queries-not-using-indexes" option if you don't want these to be logged. The wp_options table has no index on autoload, so the query ends up doing a full table scan. In general that table shouldn't get too ...


3

The process of saving option conveniently offers filter for new value, with access to old value as well. We only need to combine both and give it to WP as value to save: add_filter( 'pre_update_option_recently_edited', 'increase_recently_edited_list', 10, 2 ); function increase_recently_edited_list( $newvalue, $oldvalue ) { return array_slice( ...


3

If your theme framework has so many options that you're contemplating putting them in a separate table, you're Doing It Wrong™. What are the differences in query execution time, memory usage, and other factors between these two options? It depends on how you build the table (column data types, indexes), how many rows it has and what kind of queries ...


3

creating a custom script that writes to the static CSS file is a bad idea!!! you would need to regenerate the file each time you save any changes. a better solution would be to save all options in an array of options say for example: $MyCSS['background_color'] = #009988; $MyCSS['background_repeat'] = no-repeat; update_option('theme_settings',$MyCSS); and ...


3

The entries life for different time. You can run a sql for delete all: DELETE FROMwp_optionsWHEREoption_nameLIKE ('_transient%_feed_%') THe easiest wy for run a sql direct on the database is the plugin Adminer inside the WP Backend. More you can read on this post about delete the transient-cache of feeds.


2

The following should do it: function get_hidden_cats() { $my_cats = get_option('ce4_category_fields'); $my_hidden_cats = array(); foreach( $my_cats as $cat_id => $cat_attrs ) { if( 'true' == $cat_attrs['my_cat_hide'] ) $my_hidden_cats[] = $cat_id; } $my_hidden_cats = implode( ',', $my_hidden_cats ); return ...


2

Try esc_html( $string ) (Codex ref), which among other things encodes single- and double-quotes. For further reference, see the Data Validation entry in the Codex.


2

No, only the options that are specifically loaded with autoload set to true See http://codex.wordpress.org/Function_Reference/add_option So if it is an option that is needed on every page, when you add it to the db, set autoload=true. After that, just use get_option normally - wp will handle the cacheing etc.


2

Those edit links are Theme-dependent, via the edit_post_link() template tag. However, there are several other, similar variances in site appearance between logged-in and non-logged-in users: the presence of the Admin bar, edit-post links, edit-comment links, login/logout/register links (added directly to the template, or via Widget), etc. These don't really ...


2

I found a way to do that. This is how to Consolidate Options with Arrays described in this article http://striderweb.com/nerdaphernalia/2008/07/consolidate-options-with-arrays/ Related question: How do you store options with a:n:{{}} syntax in wp_options?


2

The ability to store abstract key-value pairs without modifying the database structure is the reason. Without that, WordPress loses much of its flexibility. I can't speak for others, but the single largest reason why I develop atop WordPress is its flexible nature. To quote one of your links above, Usually the reasoning behind doing what you are doing ...


2

The framework offers a filter for validating input values inside the optionsframework_validate function. Just for reference, here's the relevant part from the file wp-content/themes/your-theme/inc/options-framework.php: /** * Validate Options. * * This runs after the submit/reset button has been clicked and * validates the inputs. */ function ...


2

I presume your options are being saved in an array under a single key and not actually within the native options WP uses. You can add an action to update_option_{$option_name} to update the options famework entry when an option is updated outside your own options panel. You'll have to figure out what key your own options are being saved under.


1

The function is update_recently_edited in wp-admin/includes/misc.php. unfortunately it is fixed at 5: function update_recently_edited( $file ) { $oldfiles = (array) get_option( 'recently_edited' ); if ( $oldfiles ) { $oldfiles = array_reverse( $oldfiles ); $oldfiles[] = $file; $oldfiles = array_reverse( $oldfiles ); ...


1

Updating options via pure SQL is wrong. If you feel you have too many options to use the regular API you probably have too many options at all. A theme should not do the job a plugin can do. In fact, it should do as little as possible and let the user choose a plugin for simple tasks. Examples are fields for tracking codes or sharing meta data. Store your ...


1

There is a plugin called - Clean Options which promises to remove all unused entries from wp_options table. NOTE - that plugin hasn't been updated for 2 years, you must do backup before using it. To remove all data manually You have to manually look into database for unused tables or rows and use the SQL query to delete those permanently from the database. ...


1

Transients are nothing but temporary options, which are kept in the database for a certain period, means they expire once their purpose is over. For example: The _site_transient_update_plugins transient. It holds the information about the plugins which have updates available. If you delete this transient, and then refresh your dashboard, you'll find it back ...


1

Transients, as a rule are temporary data. So if the person who coded the use of such data did so properly, you should be fine. My knowledge of the subject is limited, though, and I have not had much experience with them myself. Your best bet will almost certainly be to back up your database, wipe out the data you don't think you need, then test your site. ...


1

Turn on Privacy or Incognito mode, or use another browser, it's the only reliable way of doing it. People may give you filters that may get rid of one thing ro another but there'll never be a 100% perfect code fix. Asking for a solution that allows you to view the frontend as if your not logged in introduces a whole new raft of issues such as people not ...


1

You can conditionally nuke global variable with user info, something like this: function no_user() { global $current_user; if( is_admin() ) return; $current_user = -1; } I don't know precisely which is most appropriate moment to do this. Doing this on template_redirect should be early enough to cancel it out for most (if not all) ...


1

If you are using the Settings API then you don't have to save the options, that's done for you. So when using an array to store the options your validation function should get an array of all existing options, update only the changed and return that array. Something like this: function my_settings_option_validate( $input ) { //do regular validation ...


1

Got a partial solution, but requires VPS to run it as shared hosting has a restriction on what you can do with a cursor. Anyway, DROP PROCEDURE IF EXISTS `update_all_options`; DELIMITER // CREATE PROCEDURE update_all_options( IN db varchar(255), IN theoption varchar(255), IN set_val VARCHAR(255) ) BEGIN DECLARE table_val VARCHAR(255); -- Declare variables ...


1

Sounds like a couple of possibilities 1) an upgrade that may not have completed successfully or fully - try reloading wordpress completely (download and ftp). This has happening to a few folk or 2) a plugin that may not be compatible with new version. For debugging purposes, try deactivating one by one till problem goes away (or deactivate all, then ...



Only top voted, non community-wiki answers of a minimum length are eligible