Changeset 1785773
- Timestamp:
- 12/12/2017 09:14:07 PM (8 years ago)
- Location:
- widget-display-conditions/trunk
- Files:
-
- 8 edited
-
includes/admin.php (modified) (4 diffs)
-
js/main.js (modified) (1 diff)
-
src/WDC/API.php (modified) (4 diffs)
-
src/WDC/Condition/Base.php (modified) (4 diffs)
-
src/WDC/Manager/Base.php (modified) (2 diffs)
-
src/WDC/Manager/Condition.php (modified) (1 diff)
-
src/WDC/Operator/Base.php (modified) (1 diff)
-
src/WDC/Registrable/Base.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
widget-display-conditions/trunk/includes/admin.php
r1777132 r1785773 161 161 <optgroup label="<?php echo esc_attr( $category['title'] ); ?>"> 162 162 <?php foreach ( $conditions as $condition ) : ?> 163 <option value="<?php echo esc_attr( get_class( $condition) ); ?>"><?php echo esc_html( $condition->get_title() ); ?></option>163 <option value="<?php echo esc_attr( $condition->get_id() ); ?>"><?php echo esc_html( $condition->get_title() ); ?></option> 164 164 <?php endforeach; ?> 165 165 </optgroup> … … 199 199 } 200 200 201 $param _id= isset( $_POST['param'] ) ? $_POST['param'] : '';201 $param = isset( $_POST['param'] ) ? $_POST['param'] : ''; 202 202 203 203 $items = array(); 204 204 205 if ( ! empty( $param _id) )206 { 207 foreach ( (array) $param _id as $class)205 if ( ! empty( $param ) ) 206 { 207 foreach ( (array) $param as $condition_id ) 208 208 { 209 $condition = WDC_API::get_condition( $c lass);209 $condition = WDC_API::get_condition( $condition_id ); 210 210 211 211 if ( ! $condition ) … … 227 227 $operator_choices[] = array 228 228 ( 229 'id' => get_class( $operator),229 'id' => $operator->get_id(), 230 230 'text' => $operator->get_title() 231 231 ); … … 241 241 /* ---------------------------------------------------- */ 242 242 243 $items[ $c lass] = array243 $items[ $condition_id ] = array 244 244 ( 245 245 'operators' => $operator_choices, -
widget-display-conditions/trunk/js/main.js
r1777230 r1785773 314 314 success : function( response ) 315 315 { 316 console.log( response ); 317 316 318 var items = response.data; 317 319 -
widget-display-conditions/trunk/src/WDC/API.php
r1776540 r1785773 16 16 } 17 17 18 static public function get_condition( $ class)18 static public function get_condition( $id ) 19 19 { 20 20 $manager = WDC_Manager_Condition::get_instance(); 21 21 22 return $manager->get( $ class);22 return $manager->get( $id ); 23 23 } 24 24 … … 30 30 } 31 31 32 static public function unregister_condition( $ class)32 static public function unregister_condition( $id ) 33 33 { 34 34 $manager = WDC_Manager_Condition::get_instance(); 35 35 36 $manager->remove( $ class);36 $manager->remove( $id ); 37 37 } 38 38 … … 85 85 } 86 86 87 static public function get_operator( $ class)87 static public function get_operator( $id ) 88 88 { 89 89 $manager = WDC_Manager_Operator::get_instance(); 90 90 91 return $manager->get( $ class);91 return $manager->get( $id ); 92 92 } 93 93 … … 99 99 } 100 100 101 static public function unregister_operator( $ class)101 static public function unregister_operator( $id ) 102 102 { 103 103 $manager = WDC_Manager_Operator::get_instance(); 104 104 105 $manager->remove( $ class);105 $manager->remove( $id ); 106 106 } 107 107 } -
widget-display-conditions/trunk/src/WDC/Condition/Base.php
r1778990 r1785773 3 3 class WDC_Condition_Base extends WDC_Registrable_Base 4 4 { 5 protected $id = null;6 5 protected $title = null; 7 6 protected $category = null; … … 10 9 public function __construct( $id, $title, $args = null ) 11 10 { 12 parent::__construct( );11 parent::__construct( $id ); 13 12 14 13 $defaults = array … … 17 16 'operators' => apply_filters( 'wdc_default_operators', array 18 17 ( 19 ' WDC_Operator_IsEqualTo',20 ' WDC_Operator_IsNotEqualTo'18 '==', 19 '!=' 21 20 )) 22 21 ); … … 26 25 extract( $args, EXTR_SKIP ); 27 26 28 $this->id = $id;29 27 $this->title = $title; 30 28 $this->category = $category; 31 29 $this->operators = (array) $operators; 32 }33 34 public function get_id()35 {36 return $this->id;37 30 } 38 31 -
widget-display-conditions/trunk/src/WDC/Manager/Base.php
r1776540 r1785773 15 15 } 16 16 17 public function get( $ class)17 public function get( $id ) 18 18 { 19 if ( isset( $this->objects[ $ class] ) )19 if ( isset( $this->objects[ $id ] ) ) 20 20 { 21 return $this->objects[ $ class];21 return $this->objects[ $id ]; 22 22 } 23 23 … … 34 34 } 35 35 36 $this->objects[ $class ] = new $class(); 36 $instance = new $class(); 37 38 $this->objects[ $instance->get_id() ] = $instance; 37 39 } 38 40 39 public function remove( $ class)41 public function remove( $id ) 40 42 { 41 if ( isset( $this->objects[ $ class] ) )43 if ( isset( $this->objects[ $id ] ) ) 42 44 { 43 unset( $this->objects[ $ class] );45 unset( $this->objects[ $id ] ); 44 46 } 45 47 -
widget-display-conditions/trunk/src/WDC/Manager/Condition.php
r1776540 r1785773 43 43 $conditions = array(); 44 44 45 foreach ( $this->objects as $ class=> $condition )45 foreach ( $this->objects as $id => $condition ) 46 46 { 47 47 if ( $condition->get_category() == $category ) 48 48 { 49 $conditions[ $ class] = $condition;49 $conditions[ $id ] = $condition; 50 50 } 51 51 } -
widget-display-conditions/trunk/src/WDC/Operator/Base.php
r1776540 r1785773 3 3 class WDC_Operator_Base extends WDC_Registrable_Base 4 4 { 5 protected $id = null;6 5 protected $title = null; 7 6 8 7 public function __construct( $id, $title ) 9 8 { 10 parent::__construct( );9 parent::__construct( $id ); 11 10 12 $this->id = $id;13 11 $this->title = $title; 14 }15 16 public function get_id()17 {18 return $this->id;19 12 } 20 13 -
widget-display-conditions/trunk/src/WDC/Registrable/Base.php
r1776540 r1785773 3 3 class WDC_Registrable_Base extends WDC_Base 4 4 { 5 public function __construct() 5 protected $id = null; 6 7 public function __construct( $id ) 6 8 { 7 9 parent::__construct(); 10 11 $this->id = $id; 12 } 13 14 public function get_id() 15 { 16 return $this->id; 8 17 } 9 18 }
Note: See TracChangeset
for help on using the changeset viewer.