Bridging TinyMCE js and WordPress PHP?
I have integrated buttons to TinyMCE with WordPress functionality, let me know if this material would add some context with code samples to your use case.
I have integrated buttons to TinyMCE with WordPress functionality, let me know if this material would add some context with code samples to your use case.
Basically what you’re looking to do is create a separate page within a WordPress site that (I’m sort of guessing here) you’re not creating within WordPress itself, but you want to pull WordPress data. There’s a “cheater” method and an officially sanctioned method to do what you want. The “cheater” method is to call wp-load.php … Read more
To prevent multiple button clicks, you can use JavaScript to disable the button. jQuery(‘#review_member_button’).on(‘click’, function(evt) { jQuery(this).attr(‘disabled’, ‘disabled’); }); On the WordPress end, you can set a unique key for the form every time it’s generated and check to see if a form with that key has been resubmitted. I would recommend setting a transient, … Read more
So this goes in your themes functions.php file. This adds a metabox on the right side of your editscreen within posts called “Enable Post Views on this Post”: // Hook into WordPress add_action( ‘admin_init’, ‘add_custom_metabox’ ); add_action( ‘save_post’, ‘wpse_16722_save_post_views_value’ ); /** * Add meta box */ function add_custom_metabox() { add_meta_box( ‘enable_post_views’, __( ‘Enable Post Views … Read more
The function get_avatar‘s 3rd argument is the default image, which you can also pass a function’s return value to, so wherever you run get_avatar in your theme you can set a function that changes the default avatar as a 3rd argument. get_avatar( get_the_author_meta( ‘user_email’ ), 64, ‘http://example.com/path/to/image.jpg’ ); Or, with a function’s return value as … Read more
I do this pretty regularly and have no issue with using functions in WordPress core. You can hook a bit earlier though and skip the 404 and header bits. In functions.php: function wpa88013_parse_query( $wp ){ if ( ‘nlm-admin-thumbnail’ == $wp->query_vars[‘pagename’] ) { include( dirname( __FILE__ ) . ‘/thumbnail.php’ ); exit; } } add_action( ‘parse_query’, ‘wpa88013_parse_query’ … Read more
I actually solved it myself, it turns out there was this piece of code which I removed that solved my problem: function custom_excerpt_length( $length ) { return 0; } add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 ); Not sure what it does though, but it doesn’t seem like I need it.
Use has_nav_menu to check if a location has been assigned a menu or not <?php if ( has_nav_menu( $location ) ) { echo “Also in this section”; } ?> http://codex.wordpress.org/Function_Reference/has_nav_menu For more advanced checks you’ll need to do a call to wp_get_nav_menu_items and process the items it returns to see if any of them are … Read more
comments_number doesn’t return the number of comments, it echos it out. As the codex clearly states: Use get_comments_number() to retrieve the value.
On the profile page exists a global variable $profileuser. The member $profileuser->roles is an array of all roles for that user. <?php # -*- coding: utf-8 -*- // Plugin Name: personal_options add_action( ‘personal_options’, ‘print_user_roles’); function print_user_roles() { global $profileuser; print ‘<pre>$profileuser->roles=” . htmlspecialchars( var_export( $profileuser->roles, TRUE ), ENT_QUOTES, “utf-8’, FALSE ) . ‘</pre>’; } Output: … Read more