Articles of functions

How can I get $id variable in widget's form function?

How can I get $id variable in widget’s form function? According to widget’s structure I see that widget function have $args as a parameter, which will be extracted in function’s body. In my case i want to use $id variable (from extracted $args) which contains current sidebar’s id. How can I make ‘visible’ $id variable […]

Display custom comments field for first level only

I have simple fuction that adds additional comment form field called “Subject”: add_action( ‘comment_form_logged_in_before’, ‘additional_fields’ ); add_action( ‘comment_form_before_fields’, ‘additional_fields’ ); function additional_fields () { echo ‘<p class=”comment-form-subject”>’. ‘<label for=”subject”>’ . __( ‘Your subject’ ) . ‘</label>’. ‘<input id=”subject” name=”subject” type=”text” size=”30″ tabindex=”5″ /></p>’; } It works fine, but just now it adds “Subject” field to […]

WordPress Enqueue for homepage only, functions.php, wp-framework

I’d like to replace my: if(is_home()) { wp_enqueue_script( ‘homestuff’, get_theme_part( THEME_JS . ‘/home.js’ ), array( ‘jquery’ ), null, true ); wp_enqueue_script( ‘jquerycolor’, get_theme_part( THEME_JS . ‘/jquery.color.js’ ), array( ‘jquery’ ), null, true ); }; Which is currently in header.php, by putting it in a functions.php file instead. Trying to tidy everything up on a sprawling […]

Displaying Logged-In User Name in WordPress Menu

I’m using WordPress with UserPro, and want my menu to display the logged-in user’s first name, linked to the user profile page. The problem is that in my menu structure, the “Profile” menu option is supposed to have a sub-menu containing “edit profile”, “submit”, and “logout”. This is the code I’m currently using: /*earlier code, […]

Add custom template page programmatically

I’m trying to add template page from a plugin,and my template page is in this plugin folder.Is this posible?Here is my code: global $user_ID; $new_post = array( ‘post_title’ => ‘Test Template Page’, ‘post_content’ => ‘Some text’, ‘post_status’ => ‘publish’, ‘post_date’ => date(‘Y-m-d H:i:s’), ‘post_author’ => $user_ID, ‘post_type’ => ‘page’, ‘post_category’ => array(0) ); $post_id = […]

Removing default image size list in Media Box

I trying to remove unused image size (Thumbnail, Medium, Large) in MediaBox Any function can i use in functions.php ? or some trick ? PS : I know i can use jQuery trick but any better function to use ?

How to not allow users to create new tags, but allow to them to use existing ones

I want a certain role to be able to add new tags, but other users should just be able to use the text bar to search for existing tags. I know I can hide the tag bar in the sidebar, but I don’t want that. I just want it to say “Sorry, this tag does […]

Set media upload attachment link to none and hide it in WP v3.5

In the Media upload popup page, how do I set the attachment link to none and hide it in WordPress version 3.5? The following filter worked fine in earlier versions of WP: function my_attachment_fields_edit($form_fields,$post){ // Set attachment link to none and hide it. $html = “<input type=’hidden’ name=’attachments[“.$post->ID.”][url]’ value=”/>”; $form_fields[‘url’][‘html’] = $html; //Replace html $form_fields[‘url’][‘label’] […]

syntax for remove_filter in parent theme with class

I’m trying to remove a filter on the register_url hook a parent theme added, that seems to have a class nomenclature I can’t figure out. Ordinarily, a filter for this hook would be easily added like so: add_filter( ‘register_url’, ‘custom_register_url’ ); function custom_register_url( $register_url ) { $register_url = “YOUR_PAGE_URL”; return $register_url; } However, the parent […]

Plugin update error message

I’m working on a client website where the framework requires a specific plugin version to work properly. With the follow lines of code in my functions.php file, it stops the plugin from updating itself and displaying an update message to the admin user: // Disable Cherry Plugin Updates function filter_plugin_updates( $value ) { if(isset($value->response[‘cherry-plugin/cherry-plugin.php’])) { […]