Tag Info

Hot answers tagged

6

Neither. register_activation_hook( __FILE__, 'trigger_me' ); function trigger_me() { if ( !wp_next_scheduled( 'my_plugin_cron' ) ) { wp_schedule_event(time(), 'hourly', 'my_plugin_cron'); } } Why parse code on every request when you don't need to?


5

Short answer: your name attribute values must use the schema option_name[array_key]. So, when you use … <input name="option_name[key1]"> <input name="option_name[key2]"> … you get an array as option value in your validation function: array ( 'key1' => 'some value', 'key2' => 'some other value' ) PHP does that for you, this is ...


4

There is no difference. This is a complete shortcode plugin: /* Plugin Name: blogname */ add_shortcode( 'blogname', 'get_bloginfo' ); Usually, you should never register shortcodes in a theme, because the content will be useless after a a theme switch. So, a plugin is the better option.


2

This is a serialized value, so you should run it through maybe_unserialize() or just unserialize() before you edit it. When you work in plugins or themes, always use the API: update_option() and get_option() for example. These functions will un/serialize the values for you, so you don’t have to worry about the database. See also: Settings API with ...


2

Shortcode is definitely a good start. It is very flexible in terms of where you output the content (widget, post, page, inside php function, etc). You can also override the template output easily by using action hooks and custom post type that you create: add_action('the_content', 'add_project_content'); function add_project_content($content) { // ...


1

The taxonomy system doesn't have any meta_data feature. Without constructing another table, your option seems to me to be to store the taxonomy information in the $wpdb->options table using the appropriate functions. Honestly, I can't help but think that you are trying to use the taxonomy system for something beyond what it was meant for and that you ...


1

use get_page_by_title to get post by title. I check for it on my system $post_exist=get_page_by_title( 'Hello world!', ARRAY_A, 'post' ); if( ! empty( $post_exist ) ) { echo 'title exist'; } else { echo 'title not exist'; } Running successfully. In your case it may be like $title=trim($titles_arr[$i]); ...


1

Create a static getter for your class instance: class DD_Awesome_Plugin { /** * Plugin main instance. * * @type object */ protected static $instance = NULL; /** * Access plugin instance. You can create further instances by calling * the constructor directly. * * @wp-hook wp_loaded * @return object ...


1

Technically, this is possible. Just make sure to use your strings after the parent plugin has loaded its language file. In terms of maintainability, this is not optimal. Your create a very strond dependency here: each time the parent plugin changes a string (adding a dot, removing a white space), you have to change your strings too. I would do this only to ...


1

This 2 functions will work with custom mime uploaded files (like PSD, EPS) when meta not avaible. It also returns more then just a lot of bytes, means, 2 decimal logic unit. The 99 places the info last in the meta box. // Helper function ua_formatBytes($bytes, $precision = 2) { $units = array('B', 'kB', 'mB', 'GB', 'TB'); $bytes = ...



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