Articles of filters

How to make a widget expand wider than the column width when editing its settings in the admin

The WordPress Text widget expands horizontally beyond the margin of the sidebar when added to a sidebar and opened in the admin and I am trying to apply that function to a widget. I see inline css is being dynamically injected when the widget tab is opened and inserts as div style=”z-index: 100; margin-left: -88px;” […]

return values from hooks do_action and apply_filters, which is better

Myself wondering among the following methods which is better to update an option value where value to be updated is coming from an ajax callback. Since WordPress Codex clearly says apply_filters is used to return the formatted values where as do_actions for logic function executions. add_action(‘wp_ajax_test_action’, ‘testAction’); ///****** Method 1 ********/// function testAction() { $test […]

add_filter() function misunderstanding

I’m studying the theme “one page” and there is the following code: function onepage_sections() { $sections = array(); $sections[‘service_section’] = array( ‘id’ => ‘service_section’, ‘label’ => __(‘Service Section’, ‘one-page’), ‘callback’ => ‘onepage_service_section’, ); $sections[‘blog_section’] = array( ‘id’ => ‘blog_section’, ‘label’ => __(‘Blog Section’, ‘one-page’), ‘callback’ => ‘onepage_blog_section’, ); return apply_filters(‘onepage_sections’, $sections); } From what I […]

IF Statement in WordPress

I can’t seem how to correctly use the php if statemnt in my add filter function below. This code works perfectly if all (3) of my $_POST inputs have values however it has a fatal error if any are empty. So I’d like to tell it to not run any code of any of these […]

Limit filter upgrader_post_install to a single plugin

I am using the following filter to run a function that generates a CSS file after a plugin gets updated. Currently the CSS gets generated when any plugin gets updated. Is there a simple way to limit this running to a particular plugin? add_filter(‘upgrader_post_install’, ‘generate_my_css’, 100, 0); function generate_my_css() { $ss_dir = get_stylesheet_directory(); $pi_dir = […]

Woocommerce filter cart and category specific quantity

So basically, I’m trying to filter my cart. I would like the message below displayed if products from the “cuvees” category are at the number of 4,5,7,8,9,10,11,13,14,15,16,17,19,21 in the cart. So far here what I’ve did but it only works for one value : 7 . Do I need to put an array when I […]

Filter on the_content ignores shortcodes

My function only affects the Page content and not the page content from the posts in page plugin which I call with a shortcode in the page. My plugin function add_filter(‘the_content’, ‘modify_tables’, 10, 1); function modify_tables($content) { //modifications… return $content; } // function modify_tables My template code to ouput page while (have_posts()) : the_post(); the_content(); […]

Change default settings used by gallery shortcode

I need to change the default gallery shortcode settings so that “columns” = 5 & “link” = ‘file’. Which filter to add to the file functions.php? Source code: $atts = shortcode_atts( array( ‘order’ => ‘ASC’, ‘orderby’ => ‘menu_order ID’, ‘id’ => $post ? $post->ID : 0, ‘itemtag’ => $html5 ? ‘figure’ : ‘dl’, ‘icontag’ => […]

How to set a custom path, for ajax image upload folder in admin?

I am coding my first WordPress plugin that handles some data for a custom (shop-like) post type. It also has an image uploader within a metabox, where you simply drag in your images and it automatically handles the uploads, filename and media-library integration without reloading the page. (AJAX) To do this I use Javascript for […]

How can I show more than 15 themes at a time in the admin menu?

I have a lot of themes in my test wordpress site. I get a little frustrated that I can’t show more than 15 at a time. Picture.png http://img820.imageshack.us/img820/5982/picturef.png In pages and posts you can click “screen options” to choose the number, but it looks like “Themes” has no such option. Picture-1.jpg http://img853.imageshack.us/img853/9582/picture1bbg.jpg Is there another […]