parameter_value pairs * * @return array updated substitution parameter name => value pairs */ public static function mla_gallery_item_values_filter( $item_values ) { /* * We use shortcode parameters of our own to apply our filters on a * gallery-by-gallery basis, leaving other [mla_gallery] instances untouched. * If no "mla_fixed_" parameters are present, we have nothing to do. Here is * an example of how the custom parameter can be used: * * [mla_gallery ids="2621,2622" mla_fixed_title="array('my title','my other title')" mla_image_attributes="title='{+mla_fixed_title+}'"] * * You can have as many "mla_fixed_" parameters as you need for different values. */ if ( false === self::$mla_fixed_values ) { return $item_values; // leave them unchanged } /* * Evaluate the parameter value(s) once per page load. */ if ( NULL === self::$mla_fixed_values ) { self::$mla_fixed_values = array(); foreach ( self::$shortcode_attributes as $parmkey => $parmvalue ) { if ( 'mla_fixed_' == substr( $parmkey, 0, 10 ) ) { if ( 'array(' == substr( $parmvalue, 0, 6 ) ) { $function = @create_function( '', 'return ' . self::$shortcode_attributes[ $parmkey ] . ';' ); if ( is_callable( $function ) ) { self::$mla_fixed_values[ $parmkey ] = $function(); if ( ! is_array( self::$mla_fixed_values[ $parmkey ] ) ) { self::$mla_fixed_values[ $parmkey ] = array(); } } else { self::$mla_fixed_values[ $parmkey ] = array(); } } else { self::$mla_fixed_values[ $parmkey ] = explode( ",", $parmvalue ); if ( false === self::$mla_fixed_values[ $parmkey ] ) { self::$mla_fixed_values[ $parmkey ] = array(); } } } // found mla_fixed_ } // foreach parameter if ( empty( self::$mla_fixed_values ) ) { self::$mla_fixed_values = false; return $item_values; } } // initialization code /* * Apply the appropriate value to the current item. */ foreach ( self::$mla_fixed_values as $mla_fixed_key => $mla_fixed_value ) { /* * Apply the appropriate value to the current item. */ if ( isset( $mla_fixed_value[ $item_values['index'] - 1 ] ) ) { $item_values[ $mla_fixed_key ] = $mla_fixed_value[ $item_values['index'] - 1 ]; } } return $item_values; } // mla_gallery_item_values_filter /** * MLA Gallery Close Values * * @since 1.02 * * @param array parameter_name => parameter_value pairs * * @return array updated substitution parameter name => value pairs */ public static function mla_gallery_close_values_filter( $markup_values ) { /* * Reset $mla_fixed_values for multiple shortcodes on the same post/page */ self::$mla_fixed_values = NULL; return $markup_values; } // mla_gallery_close_values_filter } // Class MLAFixedValuesExample /* * Install the filters at an early opportunity */ add_action('init', 'MLAFixedValuesExample::initialize'); ?>