array()); private static $search_action_has_fired = false; /** * @static * @param $type - Can only be "exclude" at the moment (Arlima_PostSearchModifier::TYPE_EXCLUDE) * @param $column * @param $value * @param $label */ public static function modifySearch($type, $column, $value, $label) { self::$modifications[$type][$column.'_'.$value] = array('value'=>$value, 'column'=>$column, 'label' => $label); } /** * @static * @return array */ private static function getSearchModifications() { if( !self::$search_action_has_fired ) { do_action('arlima_post_search'); // Let theme or plugins modify this search form self::$search_action_has_fired = true; } return self::$modifications; } /** * Will echo the part of the modified search form * @static */ public static function outputSearchModifiyingInputs() { foreach( Arlima_PostSearchModifier::getSearchModifications() as $type => $modifications) { switch ($type) { // The only type of modification we're supporting at the moment case Arlima_PostSearchModifier::TYPE_EXCLUDE: foreach($modifications as $mod) { echo sprintf('%s ', $mod['label'], $mod['value'], $mod['column']); } break; } } } /** * @static * @param array $args * @param array $posted_data * @return array */ public static function modifyWPQueryArgs($args, $posted_data) { if( !empty($posted_data['arlima_'.self::TYPE_EXCLUDE]) ) { foreach($posted_data['arlima_'.self::TYPE_EXCLUDE] as $column => $value) { if(empty($args[$column])) $args[$column] = $value; } } return $args; } }