count + 1) * 100). * This filter is called once for each filter as the item-specific substitution parameters * are calculated. * * @since 1.00 * * @param float default scaled count for the tag * @param array the shortcode parameters passed in to the shortcode * @param array shortcode arguments merged with gallery display defaults, so every possible parameter is present * @param object tag object for the current item * * @return array updated scaled count */ public static function mla_tag_cloud_scale_filter( $scaled_count, $shortcode_attributes, $all_display_parameters, $tag ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_scale_filter $scaled_count = ' . var_export( $scaled_count, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_scale_filter $shortcode_attributes = ' . var_export( $shortcode_attributes, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_scale_filter $all_display_parameters = ' . var_export( $all_display_parameters, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_scale_filter $tag = ' . var_export( $tag, true ), 0 ); return $scaled_count; } // mla_tag_cloud_scale_filter /** * Use MLA Tag Cloud Style * * You can use this filter to allow or suppress the inclusion of CSS styles in the * gallery output. Return 'true' to allow the styles, false to suppress them. You can also * suppress styles by returning an empty string from the mla_tag_cloud_style_parse_filter below. * * @since 1.00 * * @param boolean true unless the mla_style parameter is "none" * @param string value of the mla_style parameter * * @return boolean true to fetch and parse the style template, false to leave it empty */ public static function use_mla_tag_cloud_style_filter( $use_style_template, $style_template_name ) { //error_log( 'MLATagCloudHooksExample::use_mla_tag_cloud_style_filter $use_style_template = ' . var_export( $use_style_template, true ), 0 ); //error_log( 'MLATagCloudHooksExample::use_mla_tag_cloud_style_filter $style_template_name = ' . var_export( $style_template_name, true ), 0 ); return $use_style_template; } // use_mla_tag_cloud_style_filter /** * MLA Tag Cloud Style Values * * The "Values" series of filters gives you a chance to modify the substitution parameter values * before they are used to complete the associated template (in the corresponding "Parse" filter). * It is called just before the values are used to parse the associated template. * You can add, change or delete parameters as needed. * * @since 1.00 * * @param array parameter_name => parameter_value pairs * * @return array updated substitution parameter name => value pairs */ public static function mla_tag_cloud_style_values_filter( $style_values ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_values_filter $style_values = ' . var_export( $style_values, true ), 0 ); /* * You also have access to the PHP Super Globals, e.g., $_REQUEST, $_SERVER */ //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_values_filter $_REQUEST = ' . var_export( $_REQUEST, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_values_filter $_SERVER[ REQUEST_URI ] = ' . var_export( $_SERVER['REQUEST_URI'], true ), 0 ); /* * You can use the WordPress globals like $wp_query, $wpdb and $table_prefix as well. * Note that $wp_query contains values for the post/page query, NOT the [mla_tag_cloud] query. */ global $wp_query; //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_values_filter $wp_query->query = ' . var_export( $wp_query->query, true ), 0 ); return $style_values; } // mla_tag_cloud_style_values_filter /** * MLA Tag Cloud Style Template * * The "Template" series of filters gives you a chance to modify the template value before * it is used to generate the HTML markup (in the corresponding "Parse" filter). * It is called just before the template is used to generate the markup. * You can modify the template as needed. * * @since 1.00 * * @param string template used to generate the HTML markup * * @return string updated template */ public static function mla_tag_cloud_style_template_filter( $style_template ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_template_filter $style_template = ' . var_export( $style_template, true ), 0 ); return $style_template; } // mla_tag_cloud_style_template_filter /** * MLA Tag Cloud Style Parse * * The "Parse" series of filters gives you a chance to modify or replace the HTML markup * that will be added to the [mla_tag_cloud] output. It is called just after the values array * (updated in the corresponding "Values" filter) is combined (parsed) with the template. * You can modify the HTML markup already prepared or start over with the template and the * substitution values. * * @since 1.00 * * @param string HTML markup returned by the template parser * @param string template used to generate the HTML markup * @param array parameter_name => parameter_value pairs * * @return array updated HTML markup for gallery output */ public static function mla_tag_cloud_style_parse_filter( $html_markup, $style_template, $style_values ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_parse_filter $html_markup = ' . var_export( $html_markup, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_parse_filter $style_template = ' . var_export( $style_template, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_parse_filter $style_values = ' . var_export( $style_values, true ), 0 ); return $html_markup; } // mla_tag_cloud_style_parse_filter /** * MLA Tag Cloud Open Values * * Note: The $markup_values array is shared among the open, row open, row close and close functions. * It is also used to initialize the $item_values array. * * @since 1.00 * * @param array parameter_name => parameter_value pairs * * @return array updated substitution parameter name => value pairs */ public static function mla_tag_cloud_open_values_filter( $markup_values ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_open_values_filter $markup_values = ' . var_export( $markup_values, true ), 0 ); return $markup_values; } // mla_tag_cloud_open_values_filter /** * MLA Tag Cloud Open Template * * @since 1.00 * * @param string template used to generate the HTML markup * * @return string updated template */ public static function mla_tag_cloud_open_template_filter( $open_template ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_open_template_filter $open_template = ' . var_export( $open_template, true ), 0 ); return $open_template; } // mla_tag_cloud_open_template_filter /** * MLA Tag Cloud Open Parse * * @since 1.00 * * @param string HTML markup returned by the template parser * @param string template used to generate the HTML markup * @param array parameter_name => parameter_value pairs * * @return array updated HTML markup for gallery output */ public static function mla_tag_cloud_open_parse_filter( $html_markup, $open_template, $markup_values ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_open_parse_filter $html_markup = ' . var_export( $html_markup, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_open_parse_filter $open_template = ' . var_export( $open_template, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_open_parse_filter $markup_values = ' . var_export( $markup_values, true ), 0 ); return $html_markup; } // mla_tag_cloud_open_parse_filter /** * MLA Tag Cloud Style * * This is an old filter retained for compatibility with earlier MLA versions. * You will probably find the "Values" and "Parse" filters more useful. * * @since 1.00 * * @param string HTML markup for "gallery style" and "gallery open", combined * @param array parameter_name => parameter_value pairs for gallery style * @param array parameter_name => parameter_value pairs for gallery open * @param string template used to generate the HTML markup for gallery style * @param string template used to generate the HTML markup for gallery open * * @return array updated HTML markup for "gallery style" and "gallery open" output */ public static function mla_tag_cloud_style_filter( $html_markup, $style_values, $open_values, $style_template, $open_template ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_filter $html_markup = ' . var_export( $html_markup, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_filter $style_values = ' . var_export( $style_values, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_filter $open_values = ' . var_export( $open_values, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_filter $style_template = ' . var_export( $style_template, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_style_filter $open_template = ' . var_export( $open_template, true ), 0 ); return $html_markup; } // mla_tag_cloud_style_filter /** * MLA Tag Cloud Row Open Values * * @since 1.00 * * @param array parameter_name => parameter_value pairs * * @return array updated substitution parameter name => value pairs */ public static function mla_tag_cloud_row_open_values_filter( $markup_values ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_row_open_values_filter $markup_values = ' . var_export( $markup_values, true ), 0 ); return $markup_values; } // mla_tag_cloud_row_open_values_filter /** * MLA Tag Cloud Row Open Template * * @since 1.00 * * @param string template used to generate the HTML markup * * @return string updated template */ public static function mla_tag_cloud_row_open_template_filter( $row_open_template ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_row_open_template_filter $row_open_template = ' . var_export( $row_open_template, true ), 0 ); return $row_open_template; } // mla_tag_cloud_row_open_template_filter /** * MLA Tag Cloud Row Open Parse * * @since 1.00 * * @param string HTML markup returned by the template parser * @param string template used to generate the HTML markup * @param array parameter_name => parameter_value pairs * * @return array updated HTML markup for gallery output */ public static function mla_tag_cloud_row_open_parse_filter( $html_markup, $row_open_template, $markup_values ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_row_open_parse_filter $html_markup = ' . var_export( $html_markup, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_row_open_parse_filter $row_open_template = ' . var_export( $row_open_template, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_row_open_parse_filter $markup_values = ' . var_export( $markup_values, true ), 0 ); return $html_markup; } // mla_tag_cloud_row_open_parse_filter /** * MLA Tag Cloud Item Values * * @since 1.00 * * @param array parameter_name => parameter_value pairs * * @return array updated substitution parameter name => value pairs */ public static function mla_tag_cloud_item_values_filter( $item_values ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_item_values_filter $item_values = ' . var_export( $item_values, true ), 0 ); /* * For this example, we will color the "heat map" of cloud item size values. We use a shortcode parameter of our * own to do this on a gallery-by-gallery basis, leaving other [mla_tag_cloud] instances untouched. */ if ( isset( self::$shortcode_attributes['my_filter'] ) && 'color cloud' == self::$shortcode_attributes['my_filter'] ) { /* * Calculate red, green and blue so smallest items are red, middle items are green and biggest items are blue */ $spread = (float) $item_values['max_scaled_count'] - $item_values['min_scaled_count']; $half_spread = (float) $spread / 2; $mid_point = (float) $item_values['min_scaled_count'] + $half_spread; $scaled_count = (float) $item_values['scaled_count']; $green = 255; $red = $blue = 0; if ( $half_spread ) { $green = (integer) 255.0 - ( 255.0 * ( absint( $scaled_count - $mid_point ) / $half_spread ) ); if ( $scaled_count < $mid_point ) { $red = (integer) 255.0 * ( ( $mid_point - $scaled_count ) / $half_spread ); } elseif ( $scaled_count > $mid_point ) { $blue = (integer) 255.0 * ( ( $scaled_count - $mid_point ) / $half_spread ); } } /* * 'editlink', 'viewlink' and 'thelink' are already composed at this point, so we must update all of them */ $old_style = $item_values['link_style']; $new_style = $old_style . sprintf( '; color: #%02x%02x%02x', $red, $green, $blue ); $item_values['link_style'] = $new_style; $item_values['editlink'] = str_replace( $old_style, $new_style, $item_values['editlink'] ); $item_values['viewlink'] = str_replace( $old_style, $new_style, $item_values['viewlink'] ); $item_values['thelink'] = str_replace( $old_style, $new_style, $item_values['thelink'] ); } return $item_values; } // mla_tag_cloud_item_values_filter /** * MLA Tag Cloud Item Template * * @since 1.00 * * @param string template used to generate the HTML markup * * @return string updated template */ public static function mla_tag_cloud_item_template_filter( $item_template ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_item_template_filter $item_template = ' . var_export( $item_template, true ), 0 ); return $item_template; } // mla_tag_cloud_item_template_filter /** * MLA Tag Cloud Item Parse * * @since 1.00 * * @param string HTML markup returned by the template parser * @param string template used to generate the HTML markup * @param array parameter_name => parameter_value pairs * * @return array updated HTML markup for gallery output */ public static function mla_tag_cloud_item_parse_filter( $html_markup, $item_template, $item_values ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_item_parse_filter $html_markup = ' . var_export( $html_markup, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_item_parse_filter $item_template = ' . var_export( $item_template, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_item_parse_filter $item_values = ' . var_export( $item_values, true ), 0 ); return $html_markup; } // mla_tag_cloud_item_parse_filter /** * MLA Tag Cloud Row Close Values * * @since 1.00 * * @param array parameter_name => parameter_value pairs * * @return array updated substitution parameter name => value pairs */ public static function mla_tag_cloud_row_close_values_filter( $markup_values ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_row_close_values_filter $markup_values = ' . var_export( $markup_values, true ), 0 ); return $markup_values; } // mla_tag_cloud_row_close_values_filter /** * MLA Tag Cloud Row Close Template * * @since 1.00 * * @param string template used to generate the HTML markup * * @return string updated template */ public static function mla_tag_cloud_row_close_template_filter( $row_close_template ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_row_close_template_filter $row_close_template = ' . var_export( $row_close_template, true ), 0 ); return $row_close_template; } // mla_tag_cloud_row_close_template_filter /** * MLA Tag Cloud Row Close Parse * * @since 1.00 * * @param string HTML markup returned by the template parser * @param string template used to generate the HTML markup * @param array parameter_name => parameter_value pairs * * @return array updated HTML markup for gallery output */ public static function mla_tag_cloud_row_close_parse_filter( $html_markup, $row_close_template, $markup_values ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_row_close_parse_filter $html_markup = ' . var_export( $html_markup, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_row_close_parse_filter $row_close_template = ' . var_export( $row_close_template, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_row_close_parse_filter $markup_values = ' . var_export( $markup_values, true ), 0 ); return $html_markup; } // mla_tag_cloud_row_close_parse_filter /** * MLA Tag Cloud Close Values * * @since 1.00 * * @param array parameter_name => parameter_value pairs * * @return array updated substitution parameter name => value pairs */ public static function mla_tag_cloud_close_values_filter( $markup_values ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_close_values_filter $markup_values = ' . var_export( $markup_values, true ), 0 ); return $markup_values; } // mla_tag_cloud_close_values_filter /** * MLA Tag Cloud Close Template * * @since 1.00 * * @param string template used to generate the HTML markup * * @return string updated template */ public static function mla_tag_cloud_close_template_filter( $close_template ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_close_template_filter $close_template = ' . var_export( $close_template, true ), 0 ); return $close_template; } // mla_tag_cloud_close_template_filter /** * MLA Tag Cloud Close Parse * * @since 1.00 * * @param string HTML markup returned by the template parser * @param string template used to generate the HTML markup * @param array parameter_name => parameter_value pairs * * @return array updated HTML markup for gallery output */ public static function mla_tag_cloud_close_parse_filter( $html_markup, $close_template, $markup_values ) { //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_close_parse_filter $html_markup = ' . var_export( $html_markup, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_close_parse_filter $close_template = ' . var_export( $close_template, true ), 0 ); //error_log( 'MLATagCloudHooksExample::mla_tag_cloud_close_parse_filter $markup_values = ' . var_export( $markup_values, true ), 0 ); return $html_markup; } // mla_tag_cloud_close_parse_filter } // Class MLATagCloudHooksExample /* * Install the filters at an early opportunity */ add_action('init', 'MLATagCloudHooksExample::initialize'); ?>