Multiple textdomains

You can call load_plugin_textdomain() multiple times in each plugin, but I would not do that. Put the common files into a separate plugin, for example luke-carbis-library. In that plugin create two simple functions for setup and loading extra files: add_action( ‘plugins_loaded’, ‘lcl_init’ ); function lcl_init() { $dir = plugin_dir_path( __FILE__ ); $url = plugins_url( __FILE__ … Read more

Conditional add_filter?

From the looks of your code, clicking on the #customAttachments field is firing a jQuery event that calls a tb_show() method to load the media-upload.php file with certain GET parameters already set (post_id, type, TB_iframe). What you could do is add another GET parameter and check if that’s set in order to execute your add_filter() … Read more

Creating a theme option page?

An example code for an options-page for a theme. Copy this code in the functions.php of the theme. if ( !function_exists(‘localizing_theme_setup’) ) { function localizing_theme_setup() { localizing_constants(); // Make theme available for translation // Translations can be filed in the /languages/ directory load_theme_textdomain( FB_LT_TEXTDOMAIN, TEMPLATEPATH . ‘/languages’ ); // instance class $localizing_theme_options = new localizing_theme_options(); … Read more

How to get posts by content?

You have to extend the db query to search in the post_content column. There is a filter: ‘posts_where’ you can use. I would write a simple wrapper for get_posts() to extends its arguments an run the filter once. Example: class T5_Posts_By_Content { protected static $content=””; protected static $like = TRUE; /** * Mapper for get_posts() … Read more

How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’

Updated: First, you will need to return a bool value on your notifications method so we can reliably set a marker for the message method. Then, you will need to set a $_POST array element to pass on to the redirection filter. public function save_post($post_id){ //Add a $_POST key if you syndicated successfully if($this->send_group_notifications()) //return … Read more

Filters ‘request’ and ‘parse_query’ not firing in sites.php nor link-manager.php

I managed to order the link-manager.php by a custom column using this: /* * Sort links using the custom column link_image */ function sort_on_field(&$objects, $on, $order=”ASC”) { $comparer = ($order === ‘DESC’) ? “return -strcmp(\$a->{$on},\$b->{$on});” : “return strcmp(\$a->{$on},\$b->{$on});”; usort($objects, create_function(‘$a,$b’, $comparer)); } function brsfl_link_manager_order($links) { global $current_screen; if($current_screen->id == ‘link-manager’ && $_GET[‘orderby’] == ‘link_image’) { … Read more

Plugin Development: WordPress processes twice on post update. How to skip process on the first?

@Steve Functions hook to save_post are always called twice, WordPress call functions hooked to save_post twice because: first time it saves the post revision. second time it saves the actual post. NOTE: If you have disabled post revisions using define(‘WP_POST_REVISIONS’, false); then the save_post hook will be fired only once when the actual post will … Read more

Shortcode display outside the div

Use this instead: Concatenate the html then return it. function check_my_login( $atts) { $html=”<form action=”” name=”” method=”post” enctype=”multipart/form-data”>”; $html .= ‘<div class=”form-group”>’; $html .= ‘<label for=”description”>Project Description</label>’; $html .= ‘<textarea name=”p_description” placeholder=”Project Description” class=”form-control”>’; if(isset($_POST[‘p_description’]) && $_POST[‘p_description’] != ”){ $html .= $_POST[‘p_description’]; } $html .= ‘</textarea>’; $html .= ‘</div>’; $html .= ‘<div class=”form-group”>’; $html .= … Read more