Articles of get option

Including a custom options page causes “Pages” to disappear from dashboard menu

I’ve created a custom options page and referenced it through my functions.php file. When i do this, the Pages option is removed from the WP dashboard, almost as if overwritten by the new options page. The pages continue to exist, and I can navigate directly to the new page editor, but I cannot access it […]

Getting all the settings for a plugin

Looking at the Settings API and you can register new setting using register_setting() but I can’t find a way of getting all the settings for a certain plugin. Let’s say I want to get a list with all settings for pluginA, how would you do it?

My WP_Query didn't work after upgrading to WordPress 3.2

I created a custom loop using WP_Query for my featured content slider. <?php $slider_query = new WP_Query(); $slider_query->query(“posts_per_page=5&tag=”.(get_option(‘cgr_slider_tag’))” “);?> <?php while ($slider_query->have_posts()) : $slider_query->the_post(); ?> <article class=”slide-item “> …. It works fine in previous 3.1.4 , but after upgraded to 3.2 that code is just didn’t work. No error found in WP_Debug mode, and Then […]

How to prevent plugins from sniffing/stealing other plugins' options?

Many plugins require configuration with sensitive data such as API keys, passwords, etc. When implementing these plugins, this sensitive data is stored using functions such as update_option() and get_option(). It would be trivial to write a trojan plugin that provides a useful function but also performs a variety of get_option() calls on known-sensitive options. Even […]

Pull GetOption() variable into jQuery dynamically created html

I have a page with the following markup in the site theme footer: <div id=”modalpopup”><div id=”inside”></div></div> I have a variable in the WP db I can retrieve via GetOption() which I would like to stuff into that div#inside on page load via jQuery. When I’ve done AJAX before it’s always been upon the user hitting […]

get_option and list of options

I’m trying to retrieve some values stored in the option panel of WordPress, however the list of the options I found on the site seems not complete. Perhaps it’s me looking in the wrong place. What for getting the name of the author of a given post?

Time & Date on Post – Time Ago Custom Function

I’m using the following custom function to display the timestamp for a post as posted “X minutes ago” or “X days ago” for 14 days and then this changes to the actual date (e.g. 17th December 2010): add_filter(‘the_time’, ‘dynamictime’); function dynamictime() { global $post; $date = $post->post_date; $time = get_post_time(‘G’, true, $post); $mytime = time() […]

get_option() will not work without access to wp-config.php

I’ve created a plugin. In the initialisation file of my plugin I created an options page with some options to be stored by the admin. <form method=”post” action=”options.php”> <?php settings_fields( ‘settings-group’ ); do_settings_sections( ‘settings-group’ ); ?> <label>API key</label><br /> <input type=”email” name=”apiemail” value=”<?php echo get_option(‘apiemail’); ?>”> <p><input type=”submit” value=”Save” class=”button-primary” /></p> </form> This works correctly […]

Plugin Options Array Set to Undefined

I want to set a number of plugin options set to blank if they are not defined so I can avoid the PHP notices. What is a better way of writing this code? $options = get_option(‘plugin_options’); // Add new plugin options defaults here if( !isset( $options[‘plugin_option_1’] ) ) $options[‘plugin_option_1’] = ”; if( !isset( $options[‘plugin_option_2’] ) […]

How to see everything in get_option()?

In theme and plugin development I like to completely run through everything to make sure there are no issues and I’m not getting any errors. ONLY in development do I add the following in my footer.php to see what is going on: if (is_user_logged_in()) : // GET POST META // global $wp_query; $post_meta = […]