Tag Info

Hot answers tagged

3

<?php function modified_post_gallery( $blank = NULL, $attr ) { echo '<pre>'; print_r( $attr ); echo '</pre>'; } add_filter( 'post_gallery', 'modified_post_gallery', 10, 2); ?> In media.php it shows the filter like this: // Allow plugins/themes to override the default gallery template. $output = ...


3

I think I've worked this out. First of all, you need to define your taxonomy. I'm pulling this code directly from the codex; however, I've added one parameter update_count_callback. I've set this to the cleverly titled my_update_count_callback. This just specifies that when a post of type post (this will be whatever CPTs you associate the taxonomy with) is ...


3

Your url should be pointing to admin-ajax.php echo admin_url('admin-ajax.php');


3

Short answer: no. Long answer: also no. Actions don't work that way. Edit: To elaborate and make your question totally generic: function foo() { bar(); return 1; } function bar() { // stuff } There is nothing you can put in stuff that will prevent a call to foo() from returning 1, other than halting script execution entirely with die or exit. ...


3

Look at the declaration for the function: function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) The last parameter takes your arguments and passes them to the callback function. Example from my plugin Public Contact Data foreach ( $this->fields as $type => $desc ) { $handle = ...


3

While your answer is very interesting and I like it, I still want to post another proposal, just let you have another choice :) IMHO, if the data contains only simple fields, like: array( 'name' => 'my name', 'address' => 'my address', 'phone' => '01234', ); then you can use the code below: add_filter( 'wpse63692_example_filter', ...


3

There is a FileUploaded event being fired in wp-includes/js/plupload/wp-plupload.js. Alternatively (and propably the better way) you may want extend wp.Uploader with your own success callback . (function($){ $.extend( wp.Uploader.prototype, { success : function( file_attachment ){ console.log( file_attachment ); } }); ...


2

Try this code in your complete callback of the load function: $(".postbox_wrapper").load( jQuery(this).attr("href") + " .postbox_wrapper", function(response, status, xhr) { // complete callback // create a empty div var div = document.createElement('div'); // fill div with response div.innerHTML = response; ...


2

You can only return one chunk of data from a function. That is a PHP enforced rule. If you need to return multiple pieces of data you need to return an array or an object. With filters, though, you can't just decide what to return. You have to return what the filter is meant to return. For example, the_content callbacks need to return a string. Returning a ...


2

You can’t. Create a function that loads that file: function load_admin_page_file() { require 'admin-members.php'; } Then use that function name as callback argument. In PHP 5.3 you can use a lambda: add_menu_page( 'Members', 'Members', 'manage_options', 'members', function() { require 'admin-members.php'; } );


2

Programming and machines As machines are "stupid", they need to be programmed. And programming languages don't work like languages spoken by humans as programs/machines as they can't interpret what the human thinks. They need a clear and unique advice what and when to something we order them. If you for e.g. define the function getBlock() twice, the machine ...


2

$post_id = wp_insert_post( $arg ); #returns post ID $permalink = get_permalink( $post_id ); #returns the permalink Codex: http://codex.wordpress.org/Function_Reference/wp_insert_post


2

A creative solution would be to modify the actual form_id in the database during gform_before_delete_form so none of the proceeding actions will modify the form. Then you can hook into gform_after_delete_form and modify the form_id back. gform_before_delete_form form_id = form_id + 1000000 gform_after_delete_form form_id = form_id - 1000000 ...


2

$this is not defined in the scope of a closure. Change it to: add_action('add_meta_boxes', function() use ($this) { add_meta_box('model', 'Parent', array($this,'parent_meta_box'), 'model', 'side', 'high'); }); Or better separate both and create a real method instead of a closure.


2

If you have a look at function do_meta_boxes() in wp-admin/includes/template.php then you'll see this line close to the end of the function: call_user_func($box['callback'], $object, $box); That calls the callback function and provides the two arguments. The $box argument holds all the information about the metabox, like ID, title, callback function. In ...


2

In your update_count_callback function do a check for $post->post_status and don't increment your count if post_status is not private. See this excellent answer on writing a custom update_count_callback callback function. Edit: Misread the question. To override the existing default for the category taxonomy you can create a function that overrides the ...


2

The last optional $args argument the you can pass to add_settings_fields() is passed to callback. So it seems you can use same callback just fine. Hope I am right because I just stumbled onto this two minutes ago because of discussion in chat. :) PS looked through code and it's indeed relatively recent, before ~2.9 arguments weren't passed.


1

Are you sure you have created that menu and associated it with with "secondary" menu location? Just asking...


1

EDIT: I found several problems with your method. This is how it should be done for your case, I went ahead and rewrote some things. function my_button() { echo "<script type = 'text/javascript'> jQuery( document ).ready( function() { jQuery('input.sendajax').click( function() { var sendData = { action: ...


1

Do not use different callbacks, use the the sixth parameter for add_settings_field() instead. That is an array, and you can pass any data to the callback here. Example: foreach( $theOptions as $k => $v ) { add_settings_field( $k, $v, 'my_callback', $the_options, $the_group, array ( ...


1

Hi @Loni Huff: Your Code, Reformatted: It appear you are trying to call your callback with call_user_func() instead of just passing it. Reformatting your code, this is what you have: add_settings_section( 'expansion_' . $row->expansion_id, '', call_user_func(array(&$this, 'display_expansion'), $row->expansion), 'warpress_progression' ...


1

By default WordPress does not display an avatar for a pingback or a trackback - do they even contain an e-mail address? You can add these to the get_avatar_comment_types filter if you want to change this.


1

Solution : hover on the title bar of your widget, then click configure Don't ask me why this works like this but it does.


1

A Web site that I recently worked on for a client involved tying WordPress together with another CMS including tight login integration. Because of clashes with internal functions, I could not call the WordPress logout function directly from the CMS. Intead, I created a special logout page in the WordPress root which I redirected to from the CMS. Following is ...


1

You can use add_feed( $url, $callback ). Despite its name it sends a text/html Content-Type. Basic example: add_action( 'init', 'wpse_50841_register_extra_page' ); function wpse_50841_register_extra_page() { add_feed( 'wpse50841', 'wpse_50841_callback' ); } function wpse_50841_callback() { print '<p>It works!</p>'; } Visit the ...


1

This is untested, but the callback function is provided with an array of arguments, $args which give (if any) the paramters provided with the shortocode. The zeroth entry sometimes contains the name of the shortcode used (e.g. public_email). By sometimes I mean... The zeroeth entry of the attributes array ($atts[0]) will contain the string that matched ...


1

It looks like you need to break down what you are doing into two parts. 1 / Query your external api, and then return your API key 2 / Associate the API key with a user. So, I would first query your API via a standard ajax call, and then in the success handler of that first ajax call, run your internal wp admin-ajax call to associate the user with the API ...


1

Ok, after searching a while, I've found out that the "easy" solution to my problem would be to start by creating tabs (like in the appearence menu) and option sections. While I'm still no expert in that matter, I followed this 3 part guide that explains pretty much everything related to the matter. I just had to adjust to a plugin, since he wrote his guide ...


1

The reason my code was failing was due to it reaching a memory limit. I was adding a filter to the_content, and was calling another plugin's API (Custom Field Suite) to get some meta data that was of the WYSIWYG type. This type of field runs through the_content filter, so I was hitting an infinite loop. I couldn't find this out on WP Engine because they ...


1

I'd use a filter. You can remove this: if (function_exists('bf_new_defaults')) { return bf_new_defaults( $default_settings ); } else { return $default_settings; } and replace it with something like this: return apply_filters('bf_filter', $default_settings) The following is a truncated, proof of concept version of the code so you can see how ...



Only top voted, non community-wiki answers of a minimum length are eligible