Automattic/jetpack — pull request #434 by simonwheatley (2014-03-28 19:34:07+00:00)
Title: Feature/widget conditions extra hooks (second time lucky)

See previous Pull Request: https://github.com/Automattic/jetpack/pull/167 (I got too far your repo with my delay, and a new branch/PR was the quickest cleanest way to catch up)

Copy paste of #167 follows:

These hooks would allow us to add in more type conditions to Widget Visibility, save them, and process them on the front end.

Here's the addition of a "type" control:

![140203-185953](https://f.cloud.github.com/assets/233434/2068106/697c9580-8d05-11e3-9158-38eedd96514c.png)

![140203-190032](https://f.cloud.github.com/assets/233434/2068115/841b7064-8d05-11e3-8a9f-911de98389b1.png)

Here's the code to add it:

```php
/**
*
*
* @package
**/
class Widget_Visibility_Types {

/**
* Singleton stuff.
*
* @access @static
*
* @return Widget_Visibility_Types object
*/
static public function init() {
static $instance = false;

if ( ! $instance )
$instance = new Widget_Visibility_Types;

return $instance;

}

/**
* Class constructor
*
* @return null
*/
public function __construct() {
add_action( 'widget_conditions_before_admin_form', array( $this, 'action_widget_conditions_before_admin_form' ), 10, 3 );
add_filter( 'widget_conditions_condition_result', array( $this, 'filter_widget_conditions_condition_result' ), 10, 2 );
add_filter( 'widget_conditions_update', array( $this, 'filter_widget_conditions_update' ), 10, 4 );
}

// HOOKS
// =====

/**
* Hooks the Widget Conditions action widget_conditions_before_admin_form
* Adds the additional type condition UI.
*
* @action widget_conditions_before_admin_form
*
* @param array $instance
* @param $return not used
* @param $widget not used
*
* @return void
* @author Simon Wheatley
**/
public function action_widget_conditions_before_admin_form( $instance, $return, $widget ) {
$type = '';
if ( isset( $instance['conditions']['type'] ) )
$type = $instance['conditions']['type'];

?>

>

>

>

>

>