Post visibility option to theme front-end for author to select?

Wherever you want to provide this functionality, put the following: <?php if (is_user_logged_in() && current_user_can(‘publish_posts’)) { $ID = get_the_ID(); $status = get_post_status($ID); ?> Visibility: <form id=”update_post_visibility” name=”update_post_visibility” method=”post” action=”/update-post-visibility”> <input id=”visibility-radio-public” type=”radio” <?php if ((‘publish’ === $status) && ! post_password_required($ID)) echo ‘checked=”checked” ‘; ?>value=”public” name=”visibility” /> <label for=”visibility-radio-public”>Public</label> <br /> <input id=”visibility-radio-password” type=”radio” <?php if … Read more

Add a select-option to the default widgets

The default widgets do not offer any hooks for that. You have to replace the default widget and add your field to the new class. The other option would be using JavaScript to insert the field, and a filter for ‘update_option_widget_’ . $widget->id_base to save the value. I think the separate class is the cleaner … Read more

Strip from or something better?

Manipulating HTML with regular expressions is not a good idea. I suggest you use DOMDocument: // input $html = apply_filters(‘the_content’, get_the_content()); $dom = new \DomDocument(); $dom->loadHtml($html); $blockquotes = $dom->getElementsByTagName(‘blockquote’); foreach($blockquotes as $blockquote){ foreach($blockquote->childNodes as $e){ if($e->nodeName === ‘p’){ // create a text node with the contents of the <p> $blockquote->insertBefore($dom->createTextNode($e->textContent), $e); // remove <p> $blockquote->removeChild($e); … Read more

How Can I add a menu to the theme from withen the function.php file

I think your current call to wp_nav_menu() may be echoing the menu when the code is seen and not returning it in the function. Try this call: wp_nav_menu( array( ‘theme_location’ => ‘legal_footer_navigation’, ‘echo’ => false, ) ); If that works, you can also probably remove the echo parameter from the register_nav_menus() call.

WordPress Check User Role Function (multiple roles)?

if ( wpse_99666_check_user_roles( array( ‘customrole’, ‘author’ ) ) ) _e( “You’ve got access dude!”, ‘appthemes’ ); else _e( ‘Sorry man, no luck.’, ‘appthemes’ ); /** * Checks if a particular user has one or more roles. * * Returns true on first matching role. Returns false if no roles match. * * @uses get_userdata() * … Read more

making php value numeric

Your question is more about SQL than WordPress. If you want to sort your term names as numbers, you can in general try SELECT * FROM wp_terms ORDER BY name+0 ASC or SELECT * FROM wp_terms ORDER BY name*1 ASC or use CAST: SELECT * FROM wp_terms ORDER BY CAST(name AS SIGNED) ASC where you … Read more

Internal linking to posts permalink fail because of spaces and stripe at postname

Spaces are invalid characters in URLs. Your links are broken, whether the posts exist or not and regardless of whether you want the spaces or not. And uppercase/lowercase can get you in trouble too. Some servers are case sensitive so if you have a permalink to http://somesite.com/hello-world a link like http://somesite.com/Hello-World might work or it … Read more

How to call custom function outside from the admin page?

Out of context, it is hard to say anything definitive. There is a lot of information missing. If you saved an Array to the $wpdb->options table (add_option or update_option) then get_option will return an Array. If you saved a string, it will return a string. If you want a string then you are saving the … Read more