Verify nonce in REST API?

You should pass the special wp_rest nonce as part of the request. Without it, the global $current_user object will not be available in your REST class. You can pass this from several ways, from $_GET to $_POST to headers. The action nonce is optional. If you add it, you can’t use the REST endpoint from … Read more

What is the quickest way to make a widget?

The Widgets API is the quickest way to make a widget that’s reusable. Example use: class My_Widget extends WP_Widget { /** * PHP4 constructor */ function My_Widget() { My_Widget::__construct(); } /** * PHP5 constructor */ function __construct() { // actual widget processes } /** * Echo the settings update form * * @param array $instance … Read more

How to customize the default HTML for WordPress Attachments

I want to change the default HTML code structure so that I can insert additional tags Run a filter on img_caption_shortcode, you can find that hook in the source here. http://core.trac.wordpress.org/browser/tags/3.0.1/wp-includes/media.php#L720 Example add_filter( ‘img_caption_shortcode’, ‘my_caption_html’, 10, 3 ); function my_caption_html( $current_html, $attr, $content ) { extract(shortcode_atts(array( ‘id’ => ”, ‘align’ => ‘alignnone’, ‘width’ => ”, … Read more

How to delete the Hello Dolly plugin automatically?

While I appreciate the idea, isn’t this just replacing one plugin with another? Rarst’s link already has the answer — it just needs to be reworked a bit to check for the plugin periodically, like so: function goodbye_dolly() { if (file_exists(WP_PLUGIN_DIR.’/hello.php’)) { require_once(ABSPATH.’wp-admin/includes/plugin.php’); require_once(ABSPATH.’wp-admin/includes/file.php’); delete_plugins(array(‘hello.php’)); } } add_action(‘admin_init’,’goodbye_dolly’); Slap that into your functions.php file (in … Read more

Get author full name

Try the following: <?php $fname = get_the_author_meta(‘first_name’); $lname = get_the_author_meta(‘last_name’); $full_name=””; if( empty($fname)){ $full_name = $lname; } elseif( empty( $lname )){ $full_name = $fname; } else { //both first name and last name are present $full_name = “{$fname} {$lname}”; } echo $full_name; ?>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)