Save user-specific options in WordPress admin

When you register your setting (assuming you’re using the settings API), you can get the current user object with wp_get_current_user. It returns a user object, and the property you’ll want to use in your setting is user_nicename — think of it like the user slug. <?php add_action( ‘admin_init’, ‘wpse27690_register_setting’ ); function wpse27690_register_setting() { $user = … Read more

Build dynamic page from cURL (HTML page) response with plugin

To make this work with WordPress use the AJAX API. While that technically refers to Javascript it will handle any request if the appropriate values are sent. You would create a callback like this one form the Codex: add_action(‘wp_ajax_my_action’, ‘my_action_callback’); function my_action_callback() { global $wpdb; // this is how you get access to the database … Read more

Sample — test — data for large WordPress install

Few built-in wp-cli generate commands from the docs: # Generate posts with fetched content. # See https://developer.wordpress.org/cli/commands/post/generate/ $ curl -N http://loripsum.net/api/5 | wp post generate –post_content –count=10 # Add meta to every generated term. # See https://developer.wordpress.org/cli/commands/term/generate/ $ wp term generate category –format=ids –count=3 | xargs -d ‘ ‘ -I % wp term meta add … Read more

Converting theme widgets to plugins?

Other than order of execution it doesn’t really matter where code is run. In general case you can move code to Functions File (functions.php) of theme or create simple plugin and it will still work. In this specific case the code seems to be part of WooFramework so you will need to additionally check so … Read more