@@ -118,10 +118,11 @@ discard block |
||
| 118 | 118 | $instance['listing_width'] = strip_tags($new_instance['listing_width']); |
| 119 | 119 | $instance['list_sort'] = strip_tags($new_instance['list_sort']); |
| 120 | 120 | $instance['character_count'] = $new_instance['character_count']; |
| 121 | - if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '') |
|
| 122 | - $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']); |
|
| 123 | - else |
|
| 124 | - $instance['add_location_filter'] = '0'; |
|
| 121 | + if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '') { |
|
| 122 | + $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']); |
|
| 123 | + } else { |
|
| 124 | + $instance['add_location_filter'] = '0'; |
|
| 125 | + } |
|
| 125 | 126 | |
| 126 | 127 | return $instance; |
| 127 | 128 | } |
@@ -279,7 +280,10 @@ discard block |
||
| 279 | 280 | <label for="<?php echo $this->get_field_id('add_location_filter'); ?>"> |
| 280 | 281 | <?php _e('Enable Location Filter:', 'geodirectory');?> |
| 281 | 282 | <input type="checkbox" id="<?php echo $this->get_field_id('add_location_filter'); ?>" |
| 282 | - name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) echo 'checked="checked"';?> |
|
| 283 | + name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) { |
|
| 284 | + echo 'checked="checked"'; |
|
| 285 | +} |
|
| 286 | +?> |
|
| 283 | 287 | value="1"/> |
| 284 | 288 | </label> |
| 285 | 289 | </p> |
@@ -14,160 +14,160 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class geodir_related_listing_postview extends WP_Widget |
| 16 | 16 | { |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * Register the related listing widget. |
| 19 | 19 | * |
| 20 | 20 | * @since 1.0.0 |
| 21 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
| 21 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
| 22 | 22 | */ |
| 23 | - public function __construct() { |
|
| 24 | - $widget_ops = array('classname' => 'geodir_related_listing_post_view', 'description' => __('GD > Related Listing', 'geodirectory')); |
|
| 25 | - parent::__construct( |
|
| 26 | - 'post_related_listing', // Base ID |
|
| 27 | - __('GD > Related Listing', 'geodirectory'), // Name |
|
| 28 | - $widget_ops// Args |
|
| 29 | - ); |
|
| 30 | - } |
|
| 23 | + public function __construct() { |
|
| 24 | + $widget_ops = array('classname' => 'geodir_related_listing_post_view', 'description' => __('GD > Related Listing', 'geodirectory')); |
|
| 25 | + parent::__construct( |
|
| 26 | + 'post_related_listing', // Base ID |
|
| 27 | + __('GD > Related Listing', 'geodirectory'), // Name |
|
| 28 | + $widget_ops// Args |
|
| 29 | + ); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Front-end display content for related listing widget. |
| 34 | 34 | * |
| 35 | 35 | * @since 1.0.0 |
| 36 | - * @since 1.5.1 Declare function public. |
|
| 36 | + * @since 1.5.1 Declare function public. |
|
| 37 | 37 | * |
| 38 | 38 | * @param array $args Widget arguments. |
| 39 | 39 | * @param array $instance Saved values from database. |
| 40 | 40 | */ |
| 41 | - public function widget($args, $instance) |
|
| 42 | - { |
|
| 41 | + public function widget($args, $instance) |
|
| 42 | + { |
|
| 43 | 43 | |
| 44 | - // prints the widget |
|
| 45 | - extract($args, EXTR_SKIP); |
|
| 44 | + // prints the widget |
|
| 45 | + extract($args, EXTR_SKIP); |
|
| 46 | 46 | |
| 47 | - /** This filter is documented in geodirectory_widgets.php */ |
|
| 48 | - $title = empty($instance['title']) ? __('Related Listing', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory')); |
|
| 47 | + /** This filter is documented in geodirectory_widgets.php */ |
|
| 48 | + $title = empty($instance['title']) ? __('Related Listing', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory')); |
|
| 49 | 49 | |
| 50 | - /** This filter is documented in geodirectory-functions/general_functions.php */ |
|
| 50 | + /** This filter is documented in geodirectory-functions/general_functions.php */ |
|
| 51 | 51 | $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']); |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Filter the relation type to get related listing. |
|
| 55 | - * |
|
| 56 | - * @since 1.0.0 |
|
| 57 | - * @param string $instance['relate_to'] Can be tags or category. |
|
| 58 | - */ |
|
| 53 | + /** |
|
| 54 | + * Filter the relation type to get related listing. |
|
| 55 | + * |
|
| 56 | + * @since 1.0.0 |
|
| 57 | + * @param string $instance['relate_to'] Can be tags or category. |
|
| 58 | + */ |
|
| 59 | 59 | $relate_to = empty($instance['relate_to']) ? 'category' : apply_filters('widget_relate_to', $instance['relate_to']); |
| 60 | 60 | |
| 61 | - /** This filter is documented in geodirectory-functions/general_functions.php */ |
|
| 61 | + /** This filter is documented in geodirectory-functions/general_functions.php */ |
|
| 62 | 62 | $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']); |
| 63 | 63 | |
| 64 | - /** This filter is documented in geodirectory-functions/general_functions.php */ |
|
| 64 | + /** This filter is documented in geodirectory-functions/general_functions.php */ |
|
| 65 | 65 | $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']); |
| 66 | 66 | |
| 67 | - /** This filter is documented in geodirectory-functions/general_functions.php */ |
|
| 67 | + /** This filter is documented in geodirectory-functions/general_functions.php */ |
|
| 68 | 68 | $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']); |
| 69 | 69 | |
| 70 | - /** This filter is documented in geodirectory-functions/general_functions.php */ |
|
| 70 | + /** This filter is documented in geodirectory-functions/general_functions.php */ |
|
| 71 | 71 | $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']); |
| 72 | 72 | |
| 73 | - /** This filter is documented in geodirectory-functions/general_functions.php */ |
|
| 73 | + /** This filter is documented in geodirectory-functions/general_functions.php */ |
|
| 74 | 74 | $character_count = empty($instance['character_count']) ? 20 : apply_filters('widget_list_character_count', $instance['character_count']); |
| 75 | 75 | |
| 76 | - $arr = array( |
|
| 77 | - 'before_title' => $before_title, |
|
| 78 | - 'after_title' => $after_title, |
|
| 79 | - 'title' => $title, |
|
| 80 | - 'post_number' => $post_number, |
|
| 81 | - 'relate_to' => $relate_to, |
|
| 82 | - 'layout' => $layout, |
|
| 83 | - 'add_location_filter' => $add_location_filter, |
|
| 84 | - 'listing_width' => $listing_width, |
|
| 85 | - 'list_sort' => $list_sort, |
|
| 86 | - 'character_count' => $character_count, |
|
| 87 | - 'is_widget' => '1' |
|
| 88 | - ); |
|
| 89 | - |
|
| 90 | - if ($widget_display = geodir_related_posts_display($arr)) { |
|
| 91 | - |
|
| 92 | - echo $before_widget; |
|
| 93 | - echo $widget_display; |
|
| 94 | - echo $after_widget; |
|
| 95 | - } |
|
| 96 | - } |
|
| 76 | + $arr = array( |
|
| 77 | + 'before_title' => $before_title, |
|
| 78 | + 'after_title' => $after_title, |
|
| 79 | + 'title' => $title, |
|
| 80 | + 'post_number' => $post_number, |
|
| 81 | + 'relate_to' => $relate_to, |
|
| 82 | + 'layout' => $layout, |
|
| 83 | + 'add_location_filter' => $add_location_filter, |
|
| 84 | + 'listing_width' => $listing_width, |
|
| 85 | + 'list_sort' => $list_sort, |
|
| 86 | + 'character_count' => $character_count, |
|
| 87 | + 'is_widget' => '1' |
|
| 88 | + ); |
|
| 89 | + |
|
| 90 | + if ($widget_display = geodir_related_posts_display($arr)) { |
|
| 91 | + |
|
| 92 | + echo $before_widget; |
|
| 93 | + echo $widget_display; |
|
| 94 | + echo $after_widget; |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * Sanitize related listing widget form values as they are saved. |
| 100 | 100 | * |
| 101 | 101 | * @since 1.0.0 |
| 102 | - * @since 1.5.1 Declare function public. |
|
| 102 | + * @since 1.5.1 Declare function public. |
|
| 103 | 103 | * |
| 104 | 104 | * @param array $new_instance Values just sent to be saved. |
| 105 | 105 | * @param array $old_instance Previously saved values from database. |
| 106 | 106 | * |
| 107 | 107 | * @return array Updated safe values to be saved. |
| 108 | 108 | */ |
| 109 | - public function update($new_instance, $old_instance) |
|
| 110 | - { |
|
| 111 | - //save the widget |
|
| 112 | - $instance = $old_instance; |
|
| 113 | - |
|
| 114 | - $instance['title'] = strip_tags($new_instance['title']); |
|
| 115 | - $instance['post_number'] = strip_tags($new_instance['post_number']); |
|
| 116 | - $instance['relate_to'] = strip_tags($new_instance['relate_to']); |
|
| 117 | - $instance['layout'] = strip_tags($new_instance['layout']); |
|
| 118 | - $instance['listing_width'] = strip_tags($new_instance['listing_width']); |
|
| 119 | - $instance['list_sort'] = strip_tags($new_instance['list_sort']); |
|
| 120 | - $instance['character_count'] = $new_instance['character_count']; |
|
| 121 | - if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '') |
|
| 122 | - $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']); |
|
| 123 | - else |
|
| 124 | - $instance['add_location_filter'] = '0'; |
|
| 125 | - |
|
| 126 | - return $instance; |
|
| 127 | - } |
|
| 109 | + public function update($new_instance, $old_instance) |
|
| 110 | + { |
|
| 111 | + //save the widget |
|
| 112 | + $instance = $old_instance; |
|
| 113 | + |
|
| 114 | + $instance['title'] = strip_tags($new_instance['title']); |
|
| 115 | + $instance['post_number'] = strip_tags($new_instance['post_number']); |
|
| 116 | + $instance['relate_to'] = strip_tags($new_instance['relate_to']); |
|
| 117 | + $instance['layout'] = strip_tags($new_instance['layout']); |
|
| 118 | + $instance['listing_width'] = strip_tags($new_instance['listing_width']); |
|
| 119 | + $instance['list_sort'] = strip_tags($new_instance['list_sort']); |
|
| 120 | + $instance['character_count'] = $new_instance['character_count']; |
|
| 121 | + if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '') |
|
| 122 | + $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']); |
|
| 123 | + else |
|
| 124 | + $instance['add_location_filter'] = '0'; |
|
| 125 | + |
|
| 126 | + return $instance; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | 129 | /** |
| 130 | 130 | * Back-end related listing widget settings form. |
| 131 | 131 | * |
| 132 | 132 | * @since 1.0.0 |
| 133 | - * @since 1.5.1 Declare function public. |
|
| 133 | + * @since 1.5.1 Declare function public. |
|
| 134 | 134 | * |
| 135 | 135 | * @param array $instance Previously saved values from database. |
| 136 | 136 | */ |
| 137 | - public function form($instance) |
|
| 138 | - { |
|
| 139 | - //widgetform in backend |
|
| 140 | - $instance = wp_parse_args((array)$instance, |
|
| 141 | - array('title' => '', |
|
| 142 | - 'list_sort' => '', |
|
| 143 | - 'list_order' => '', |
|
| 144 | - 'post_number' => '5', |
|
| 145 | - 'relate_to' => '', |
|
| 146 | - 'layout' => 'gridview_onehalf', |
|
| 147 | - 'listing_width' => '', |
|
| 148 | - 'add_location_filter' => '1', |
|
| 149 | - 'character_count' => '20') |
|
| 150 | - ); |
|
| 137 | + public function form($instance) |
|
| 138 | + { |
|
| 139 | + //widgetform in backend |
|
| 140 | + $instance = wp_parse_args((array)$instance, |
|
| 141 | + array('title' => '', |
|
| 142 | + 'list_sort' => '', |
|
| 143 | + 'list_order' => '', |
|
| 144 | + 'post_number' => '5', |
|
| 145 | + 'relate_to' => '', |
|
| 146 | + 'layout' => 'gridview_onehalf', |
|
| 147 | + 'listing_width' => '', |
|
| 148 | + 'add_location_filter' => '1', |
|
| 149 | + 'character_count' => '20') |
|
| 150 | + ); |
|
| 151 | 151 | |
| 152 | - $title = strip_tags($instance['title']); |
|
| 152 | + $title = strip_tags($instance['title']); |
|
| 153 | 153 | |
| 154 | - $list_sort = strip_tags($instance['list_sort']); |
|
| 154 | + $list_sort = strip_tags($instance['list_sort']); |
|
| 155 | 155 | |
| 156 | - $list_order = strip_tags($instance['list_order']); |
|
| 156 | + $list_order = strip_tags($instance['list_order']); |
|
| 157 | 157 | |
| 158 | - $post_number = strip_tags($instance['post_number']); |
|
| 158 | + $post_number = strip_tags($instance['post_number']); |
|
| 159 | 159 | |
| 160 | - $relate_to = strip_tags($instance['relate_to']); |
|
| 160 | + $relate_to = strip_tags($instance['relate_to']); |
|
| 161 | 161 | |
| 162 | - $layout = strip_tags($instance['layout']); |
|
| 162 | + $layout = strip_tags($instance['layout']); |
|
| 163 | 163 | |
| 164 | - $listing_width = strip_tags($instance['listing_width']); |
|
| 164 | + $listing_width = strip_tags($instance['listing_width']); |
|
| 165 | 165 | |
| 166 | - $add_location_filter = strip_tags($instance['add_location_filter']); |
|
| 166 | + $add_location_filter = strip_tags($instance['add_location_filter']); |
|
| 167 | 167 | |
| 168 | - $character_count = $instance['character_count']; |
|
| 168 | + $character_count = $instance['character_count']; |
|
| 169 | 169 | |
| 170 | - ?> |
|
| 170 | + ?> |
|
| 171 | 171 | <p> |
| 172 | 172 | <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory');?> |
| 173 | 173 | |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | <select class="widefat" id="<?php echo $this->get_field_id('relate_to'); ?>" |
| 204 | 204 | name="<?php echo $this->get_field_name('relate_to'); ?>"> |
| 205 | 205 | <option <?php if ($relate_to == 'category') { |
| 206 | - echo 'selected="selected"'; |
|
| 207 | - } ?> value="category"><?php _e('Categories', 'geodirectory'); ?></option> |
|
| 206 | + echo 'selected="selected"'; |
|
| 207 | + } ?> value="category"><?php _e('Categories', 'geodirectory'); ?></option> |
|
| 208 | 208 | <option <?php if ($relate_to == 'tags') { |
| 209 | - echo 'selected="selected"'; |
|
| 210 | - } ?> value="tags"><?php _e('Tags', 'geodirectory'); ?></option> |
|
| 209 | + echo 'selected="selected"'; |
|
| 210 | + } ?> value="tags"><?php _e('Tags', 'geodirectory'); ?></option> |
|
| 211 | 211 | </select> |
| 212 | 212 | </label> |
| 213 | 213 | </p> |
@@ -218,24 +218,24 @@ discard block |
||
| 218 | 218 | <select class="widefat" id="<?php echo $this->get_field_id('layout'); ?>" |
| 219 | 219 | name="<?php echo $this->get_field_name('layout'); ?>"> |
| 220 | 220 | <option <?php if ($layout == 'gridview_onehalf') { |
| 221 | - echo 'selected="selected"'; |
|
| 222 | - } ?> |
|
| 221 | + echo 'selected="selected"'; |
|
| 222 | + } ?> |
|
| 223 | 223 | value="gridview_onehalf"><?php _e('Grid View (Two Columns)', 'geodirectory'); ?></option> |
| 224 | 224 | <option <?php if ($layout == 'gridview_onethird') { |
| 225 | - echo 'selected="selected"'; |
|
| 226 | - } ?> |
|
| 225 | + echo 'selected="selected"'; |
|
| 226 | + } ?> |
|
| 227 | 227 | value="gridview_onethird"><?php _e('Grid View (Three Columns)', 'geodirectory'); ?></option> |
| 228 | 228 | <option <?php if ($layout == 'gridview_onefourth') { |
| 229 | - echo 'selected="selected"'; |
|
| 230 | - } ?> |
|
| 229 | + echo 'selected="selected"'; |
|
| 230 | + } ?> |
|
| 231 | 231 | value="gridview_onefourth"><?php _e('Grid View (Four Columns)', 'geodirectory'); ?></option> |
| 232 | 232 | <option <?php if ($layout == 'gridview_onefifth') { |
| 233 | - echo 'selected="selected"'; |
|
| 234 | - } ?> |
|
| 233 | + echo 'selected="selected"'; |
|
| 234 | + } ?> |
|
| 235 | 235 | value="gridview_onefifth"><?php _e('Grid View (Five Columns)', 'geodirectory'); ?></option> |
| 236 | 236 | <option <?php if ($layout == 'list') { |
| 237 | - echo 'selected="selected"'; |
|
| 238 | - } ?> value="list"><?php _e('List view', 'geodirectory'); ?></option> |
|
| 237 | + echo 'selected="selected"'; |
|
| 238 | + } ?> value="list"><?php _e('List view', 'geodirectory'); ?></option> |
|
| 239 | 239 | |
| 240 | 240 | </select> |
| 241 | 241 | </label> |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | </p> |
| 268 | 268 | |
| 269 | 269 | <?php |
| 270 | - } |
|
| 270 | + } |
|
| 271 | 271 | } // class geodir_related_listing_postview |
| 272 | 272 | |
| 273 | 273 | register_widget('geodir_related_listing_postview'); |
| 274 | 274 | \ No newline at end of file |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | public function form($instance) |
| 138 | 138 | { |
| 139 | 139 | //widgetform in backend |
| 140 | - $instance = wp_parse_args((array)$instance, |
|
| 140 | + $instance = wp_parse_args((array) $instance, |
|
| 141 | 141 | array('title' => '', |
| 142 | 142 | 'list_sort' => '', |
| 143 | 143 | 'list_order' => '', |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | ?> |
| 171 | 171 | <p> |
| 172 | - <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory');?> |
|
| 172 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory'); ?> |
|
| 173 | 173 | |
| 174 | 174 | <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" |
| 175 | 175 | name="<?php echo $this->get_field_name('title'); ?>" type="text" |
@@ -177,20 +177,20 @@ discard block |
||
| 177 | 177 | </label> |
| 178 | 178 | </p> |
| 179 | 179 | <p> |
| 180 | - <label for="<?php echo $this->get_field_id('list_sort'); ?>"><?php _e('Sort by:', 'geodirectory');?> |
|
| 180 | + <label for="<?php echo $this->get_field_id('list_sort'); ?>"><?php _e('Sort by:', 'geodirectory'); ?> |
|
| 181 | 181 | <select class="widefat" id="<?php echo $this->get_field_id('list_sort'); ?>" name="<?php echo $this->get_field_name('list_sort'); ?>"> |
| 182 | - <option value="latest"<?php selected( $list_sort, 'latest' ); ?>><?php _e('Latest', 'geodirectory'); ?></option> |
|
| 183 | - <option value="featured"<?php selected( $list_sort, 'featured' ); ?>><?php _e('Featured', 'geodirectory'); ?></option> |
|
| 184 | - <option value="high_review"<?php selected( $list_sort, 'high_review' ); ?>><?php _e('Review', 'geodirectory'); ?></option> |
|
| 185 | - <option value="high_rating"<?php selected( $list_sort, 'high_rating' ); ?>><?php _e('Rating', 'geodirectory'); ?></option> |
|
| 186 | - <option value="random"<?php selected( $list_sort, 'random' ); ?>><?php _e('Random', 'geodirectory'); ?></option> |
|
| 187 | - <option value="nearest"<?php selected( $list_sort, 'nearest' ); ?>><?php _e('Nearest', 'geodirectory'); ?></option> |
|
| 182 | + <option value="latest"<?php selected($list_sort, 'latest'); ?>><?php _e('Latest', 'geodirectory'); ?></option> |
|
| 183 | + <option value="featured"<?php selected($list_sort, 'featured'); ?>><?php _e('Featured', 'geodirectory'); ?></option> |
|
| 184 | + <option value="high_review"<?php selected($list_sort, 'high_review'); ?>><?php _e('Review', 'geodirectory'); ?></option> |
|
| 185 | + <option value="high_rating"<?php selected($list_sort, 'high_rating'); ?>><?php _e('Rating', 'geodirectory'); ?></option> |
|
| 186 | + <option value="random"<?php selected($list_sort, 'random'); ?>><?php _e('Random', 'geodirectory'); ?></option> |
|
| 187 | + <option value="nearest"<?php selected($list_sort, 'nearest'); ?>><?php _e('Nearest', 'geodirectory'); ?></option> |
|
| 188 | 188 | </select> |
| 189 | 189 | </label> |
| 190 | 190 | </p> |
| 191 | 191 | <p> |
| 192 | 192 | <label |
| 193 | - for="<?php echo $this->get_field_id('post_number'); ?>"><?php _e('Number of posts:', 'geodirectory');?> |
|
| 193 | + for="<?php echo $this->get_field_id('post_number'); ?>"><?php _e('Number of posts:', 'geodirectory'); ?> |
|
| 194 | 194 | |
| 195 | 195 | <input class="widefat" id="<?php echo $this->get_field_id('post_number'); ?>" |
| 196 | 196 | name="<?php echo $this->get_field_name('post_number'); ?>" type="text" |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | </p> |
| 200 | 200 | <p> |
| 201 | 201 | <label for="<?php echo $this->get_field_id('relate_to'); ?>"> |
| 202 | - <?php _e('Relate to:', 'geodirectory');?> |
|
| 202 | + <?php _e('Relate to:', 'geodirectory'); ?> |
|
| 203 | 203 | <select class="widefat" id="<?php echo $this->get_field_id('relate_to'); ?>" |
| 204 | 204 | name="<?php echo $this->get_field_name('relate_to'); ?>"> |
| 205 | 205 | <option <?php if ($relate_to == 'category') { |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | <p> |
| 215 | 215 | <p> |
| 216 | 216 | <label for="<?php echo $this->get_field_id('layout'); ?>"> |
| 217 | - <?php _e('Layout:', 'geodirectory');?> |
|
| 217 | + <?php _e('Layout:', 'geodirectory'); ?> |
|
| 218 | 218 | <select class="widefat" id="<?php echo $this->get_field_id('layout'); ?>" |
| 219 | 219 | name="<?php echo $this->get_field_name('layout'); ?>"> |
| 220 | 220 | <option <?php if ($layout == 'gridview_onehalf') { |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | </p> |
| 243 | 243 | <p> |
| 244 | 244 | <label |
| 245 | - for="<?php echo $this->get_field_id('listing_width'); ?>"><?php _e('Listing width:', 'geodirectory');?> |
|
| 245 | + for="<?php echo $this->get_field_id('listing_width'); ?>"><?php _e('Listing width:', 'geodirectory'); ?> |
|
| 246 | 246 | |
| 247 | 247 | <input class="widefat" id="<?php echo $this->get_field_id('listing_width'); ?>" |
| 248 | 248 | name="<?php echo $this->get_field_name('listing_width'); ?>" type="text" |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | </p> |
| 252 | 252 | <p> |
| 253 | 253 | <label |
| 254 | - for="<?php echo $this->get_field_id('character_count'); ?>"><?php _e('Post Content excerpt character count :', 'geodirectory');?> |
|
| 254 | + for="<?php echo $this->get_field_id('character_count'); ?>"><?php _e('Post Content excerpt character count :', 'geodirectory'); ?> |
|
| 255 | 255 | <input class="widefat" id="<?php echo $this->get_field_id('character_count'); ?>" |
| 256 | 256 | name="<?php echo $this->get_field_name('character_count'); ?>" type="text" |
| 257 | 257 | value="<?php echo esc_attr($character_count); ?>"/> |
@@ -259,9 +259,9 @@ discard block |
||
| 259 | 259 | </p> |
| 260 | 260 | <p> |
| 261 | 261 | <label for="<?php echo $this->get_field_id('add_location_filter'); ?>"> |
| 262 | - <?php _e('Enable Location Filter:', 'geodirectory');?> |
|
| 262 | + <?php _e('Enable Location Filter:', 'geodirectory'); ?> |
|
| 263 | 263 | <input type="checkbox" id="<?php echo $this->get_field_id('add_location_filter'); ?>" |
| 264 | - name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) echo 'checked="checked"';?> |
|
| 264 | + name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) echo 'checked="checked"'; ?> |
|
| 265 | 265 | value="1"/> |
| 266 | 266 | </label> |
| 267 | 267 | </p> |
@@ -14,37 +14,37 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class geodir_recent_reviews_widget extends WP_Widget |
| 16 | 16 | {
|
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * Register the recent reviews widget. |
| 19 | 19 | * |
| 20 | 20 | * @since 1.0.0 |
| 21 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
| 21 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
| 22 | 22 | */ |
| 23 | - public function __construct() {
|
|
| 24 | - $widget_ops = array('classname' => 'geodir_recent_reviews', 'description' => __('GD > Recent Reviews', 'geodirectory'));
|
|
| 25 | - parent::__construct( |
|
| 26 | - 'geodir_recent_reviews', // Base ID |
|
| 27 | - __('GD > Recent Reviews', 'geodirectory'), // Name
|
|
| 28 | - $widget_ops// Args |
|
| 29 | - ); |
|
| 30 | - } |
|
| 23 | + public function __construct() {
|
|
| 24 | + $widget_ops = array('classname' => 'geodir_recent_reviews', 'description' => __('GD > Recent Reviews', 'geodirectory'));
|
|
| 25 | + parent::__construct( |
|
| 26 | + 'geodir_recent_reviews', // Base ID |
|
| 27 | + __('GD > Recent Reviews', 'geodirectory'), // Name
|
|
| 28 | + $widget_ops// Args |
|
| 29 | + ); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Front-end display content for recent reviews widget. |
| 34 | 34 | * |
| 35 | 35 | * @since 1.0.0 |
| 36 | - * @since 1.5.1 Declare function public. |
|
| 36 | + * @since 1.5.1 Declare function public. |
|
| 37 | 37 | * |
| 38 | 38 | * @param array $args Widget arguments. |
| 39 | 39 | * @param array $instance Saved values from database. |
| 40 | 40 | */ |
| 41 | 41 | public function widget($args, $instance) |
| 42 | - {
|
|
| 43 | - // prints the widget |
|
| 44 | - extract($args, EXTR_SKIP); |
|
| 42 | + {
|
|
| 43 | + // prints the widget |
|
| 44 | + extract($args, EXTR_SKIP); |
|
| 45 | 45 | |
| 46 | - /** This filter is documented in geodirectory_widgets.php */ |
|
| 47 | - $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 46 | + /** This filter is documented in geodirectory_widgets.php */ |
|
| 47 | + $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Filter the number of reviews to display. |
@@ -63,35 +63,35 @@ discard block |
||
| 63 | 63 | * @param int $g_size Height and width of the avatar image in pixels. Default 30. |
| 64 | 64 | */ |
| 65 | 65 | $g_size = apply_filters('geodir_recent_reviews_g_size', 30);
|
| 66 | - /** |
|
| 67 | - * Filter the excerpt length |
|
| 68 | - * |
|
| 69 | - * @since 1.0.0 |
|
| 70 | - * |
|
| 71 | - * @param int $excerpt_length Excerpt length. Default 100. |
|
| 72 | - */ |
|
| 73 | - $excerpt_length = apply_filters('geodir_recent_reviews_excerpt_length', 100);
|
|
| 74 | - $comments_li = geodir_get_recent_reviews($g_size, $count, $excerpt_length, false); |
|
| 66 | + /** |
|
| 67 | + * Filter the excerpt length |
|
| 68 | + * |
|
| 69 | + * @since 1.0.0 |
|
| 70 | + * |
|
| 71 | + * @param int $excerpt_length Excerpt length. Default 100. |
|
| 72 | + */ |
|
| 73 | + $excerpt_length = apply_filters('geodir_recent_reviews_excerpt_length', 100);
|
|
| 74 | + $comments_li = geodir_get_recent_reviews($g_size, $count, $excerpt_length, false); |
|
| 75 | 75 | |
| 76 | - if ($comments_li) {
|
|
| 77 | - echo $before_widget; |
|
| 78 | - ?> |
|
| 76 | + if ($comments_li) {
|
|
| 77 | + echo $before_widget; |
|
| 78 | + ?> |
|
| 79 | 79 | <div class="widget geodir_recent_reviews_section"> |
| 80 | 80 | <?php if ($title) {
|
| 81 | - echo $before_title . $title . $after_title; |
|
| 82 | - } ?> |
|
| 81 | + echo $before_title . $title . $after_title; |
|
| 82 | + } ?> |
|
| 83 | 83 | <ul class="geodir_recent_reviews"><?php echo $comments_li; ?></ul> |
| 84 | 84 | </div> |
| 85 | 85 | <?php |
| 86 | - echo $after_widget; |
|
| 87 | - } |
|
| 88 | - } |
|
| 86 | + echo $after_widget; |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * Sanitize recent reviews widget form values as they are saved. |
| 92 | 92 | * |
| 93 | 93 | * @since 1.0.0 |
| 94 | - * @since 1.5.1 Declare function public. |
|
| 94 | + * @since 1.5.1 Declare function public. |
|
| 95 | 95 | * |
| 96 | 96 | * @param array $new_instance Values just sent to be saved. |
| 97 | 97 | * @param array $old_instance Previously saved values from database. |
@@ -99,29 +99,29 @@ discard block |
||
| 99 | 99 | * @return array Updated safe values to be saved. |
| 100 | 100 | */ |
| 101 | 101 | public function update($new_instance, $old_instance) |
| 102 | - {
|
|
| 103 | - //save the widget |
|
| 104 | - $instance = $old_instance; |
|
| 105 | - $instance['title'] = strip_tags($new_instance['title']); |
|
| 106 | - $instance['count'] = strip_tags($new_instance['count']); |
|
| 107 | - return $instance; |
|
| 108 | - } |
|
| 102 | + {
|
|
| 103 | + //save the widget |
|
| 104 | + $instance = $old_instance; |
|
| 105 | + $instance['title'] = strip_tags($new_instance['title']); |
|
| 106 | + $instance['count'] = strip_tags($new_instance['count']); |
|
| 107 | + return $instance; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * Back-end recent reviews widget settings form. |
| 112 | 112 | * |
| 113 | 113 | * @since 1.0.0 |
| 114 | - * @since 1.5.1 Declare function public. |
|
| 114 | + * @since 1.5.1 Declare function public. |
|
| 115 | 115 | * |
| 116 | 116 | * @param array $instance Previously saved values from database. |
| 117 | 117 | */ |
| 118 | 118 | public function form($instance) |
| 119 | - {
|
|
| 120 | - //widgetform in backend |
|
| 121 | - $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'count' => ''));
|
|
| 122 | - $title = strip_tags($instance['title']); |
|
| 123 | - $count = strip_tags($instance['count']); |
|
| 124 | - ?> |
|
| 119 | + {
|
|
| 120 | + //widgetform in backend |
|
| 121 | + $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'count' => ''));
|
|
| 122 | + $title = strip_tags($instance['title']); |
|
| 123 | + $count = strip_tags($instance['count']); |
|
| 124 | + ?> |
|
| 125 | 125 | <p><label for="<?php echo $this->get_field_id('title'); ?>">Widget Title: <input class="widefat"
|
| 126 | 126 | id="<?php echo $this->get_field_id('title'); ?>"
|
| 127 | 127 | name="<?php echo $this->get_field_name('title'); ?>"
|
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | value="<?php echo esc_attr($count); ?>"/></label> |
| 136 | 136 | </p> |
| 137 | 137 | <?php |
| 138 | - } |
|
| 138 | + } |
|
| 139 | 139 | } // class geodir_recent_reviews_widget |
| 140 | 140 | |
| 141 | 141 | register_widget('geodir_recent_reviews_widget'); |
| 142 | 142 | \ No newline at end of file |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | ?> |
| 79 | 79 | <div class="widget geodir_recent_reviews_section"> |
| 80 | 80 | <?php if ($title) {
|
| 81 | - echo $before_title . $title . $after_title; |
|
| 81 | + echo $before_title.$title.$after_title; |
|
| 82 | 82 | } ?> |
| 83 | 83 | <ul class="geodir_recent_reviews"><?php echo $comments_li; ?></ul> |
| 84 | 84 | </div> |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | public function form($instance) |
| 119 | 119 | {
|
| 120 | 120 | //widgetform in backend |
| 121 | - $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'count' => ''));
|
|
| 121 | + $instance = wp_parse_args((array) $instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'count' => ''));
|
|
| 122 | 122 | $title = strip_tags($instance['title']); |
| 123 | 123 | $count = strip_tags($instance['count']); |
| 124 | 124 | ?> |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | function geodir_activation() |
| 25 | 25 | {
|
| 26 | 26 | |
| 27 | - geodir_install(); |
|
| 28 | - add_action('wp_loaded', 'geodir_flush_activation');
|
|
| 27 | + geodir_install(); |
|
| 28 | + add_action('wp_loaded', 'geodir_flush_activation');
|
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | function geodir_flush_activation() |
| 38 | 38 | {
|
| 39 | - // Remove rewrite rules and then recreate rewrite rules. |
|
| 40 | - // flush late so everything is loaded |
|
| 41 | - flush_rewrite_rules(); |
|
| 39 | + // Remove rewrite rules and then recreate rewrite rules. |
|
| 40 | + // flush late so everything is loaded |
|
| 41 | + flush_rewrite_rules(); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -50,44 +50,44 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | function geodir_install() |
| 52 | 52 | {
|
| 53 | - global $geodir_settings; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Called before the GD installation scripts have run. |
|
| 57 | - * |
|
| 58 | - * @since 1.0.0 |
|
| 59 | - * @see 'geodir_installation_end' |
|
| 60 | - */ |
|
| 61 | - do_action('geodir_installation_start');
|
|
| 62 | - |
|
| 63 | - // Do install |
|
| 64 | - if (!get_option('geodir_default_data_installed')) {
|
|
| 65 | - geodir_create_tables(); // in admin db install.php |
|
| 66 | - geodir_register_defaults(); // geodir_functions/ taxonomy_functions.php |
|
| 67 | - geodir_create_default_fields(); |
|
| 68 | - //geodir_default_taxonomies(); |
|
| 69 | - geodir_set_default_options(); |
|
| 70 | - geodir_create_pages(); |
|
| 71 | - geodir_set_default_widgets(); |
|
| 72 | - gd_install_theme_compat(); |
|
| 73 | - |
|
| 74 | - update_option('geodir_default_data_installed', 1);
|
|
| 75 | - |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - if (!get_option('geodir_default_data_installed_1.2.8')) {
|
|
| 79 | - //geodir_create_tables(); // in admin db install.php |
|
| 80 | - update_option('geodir_default_data_installed_1.2.8', 1);
|
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - geodir_installation_end(); |
|
| 84 | - /** |
|
| 85 | - * Called after the GD installation scripts have run. |
|
| 86 | - * |
|
| 87 | - * @since 1.0.0 |
|
| 88 | - * @see 'geodir_installation_start' |
|
| 89 | - */ |
|
| 90 | - do_action('geodir_installation_end');
|
|
| 53 | + global $geodir_settings; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Called before the GD installation scripts have run. |
|
| 57 | + * |
|
| 58 | + * @since 1.0.0 |
|
| 59 | + * @see 'geodir_installation_end' |
|
| 60 | + */ |
|
| 61 | + do_action('geodir_installation_start');
|
|
| 62 | + |
|
| 63 | + // Do install |
|
| 64 | + if (!get_option('geodir_default_data_installed')) {
|
|
| 65 | + geodir_create_tables(); // in admin db install.php |
|
| 66 | + geodir_register_defaults(); // geodir_functions/ taxonomy_functions.php |
|
| 67 | + geodir_create_default_fields(); |
|
| 68 | + //geodir_default_taxonomies(); |
|
| 69 | + geodir_set_default_options(); |
|
| 70 | + geodir_create_pages(); |
|
| 71 | + geodir_set_default_widgets(); |
|
| 72 | + gd_install_theme_compat(); |
|
| 73 | + |
|
| 74 | + update_option('geodir_default_data_installed', 1);
|
|
| 75 | + |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + if (!get_option('geodir_default_data_installed_1.2.8')) {
|
|
| 79 | + //geodir_create_tables(); // in admin db install.php |
|
| 80 | + update_option('geodir_default_data_installed_1.2.8', 1);
|
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + geodir_installation_end(); |
|
| 84 | + /** |
|
| 85 | + * Called after the GD installation scripts have run. |
|
| 86 | + * |
|
| 87 | + * @since 1.0.0 |
|
| 88 | + * @see 'geodir_installation_start' |
|
| 89 | + */ |
|
| 90 | + do_action('geodir_installation_end');
|
|
| 91 | 91 | |
| 92 | 92 | |
| 93 | 93 | } |
@@ -104,16 +104,16 @@ discard block |
||
| 104 | 104 | function geodir_create_pages() |
| 105 | 105 | {
|
| 106 | 106 | |
| 107 | - //geodir_create_page( esc_sql( _x('home-map', 'page_slug', 'geodirectory') ), 'geodir_home_map_page', __('Home Map', 'geodirectory'), '',0,'publish' );
|
|
| 108 | - geodir_create_page(esc_sql(_x('gd-home', 'page_slug', 'geodirectory')), 'geodir_home_page', __('GD Home page', 'geodirectory'), '');
|
|
| 109 | - geodir_create_page(esc_sql(_x('add-listing', 'page_slug', 'geodirectory')), 'geodir_add_listing_page', __('Add Listing', 'geodirectory'), '');
|
|
| 110 | - geodir_create_page(esc_sql(_x('listing-preview', 'page_slug', 'geodirectory')), 'geodir_preview_page', __('Listing Preview', 'geodirectory'), '');
|
|
| 111 | - geodir_create_page(esc_sql(_x('listing-success', 'page_slug', 'geodirectory')), 'geodir_success_page', __('Listing Success', 'geodirectory'), '');
|
|
| 112 | - geodir_create_page(esc_sql(_x('location', 'page_slug', 'geodirectory')), 'geodir_location_page', __('Location', 'geodirectory'), '');
|
|
| 107 | + //geodir_create_page( esc_sql( _x('home-map', 'page_slug', 'geodirectory') ), 'geodir_home_map_page', __('Home Map', 'geodirectory'), '',0,'publish' );
|
|
| 108 | + geodir_create_page(esc_sql(_x('gd-home', 'page_slug', 'geodirectory')), 'geodir_home_page', __('GD Home page', 'geodirectory'), '');
|
|
| 109 | + geodir_create_page(esc_sql(_x('add-listing', 'page_slug', 'geodirectory')), 'geodir_add_listing_page', __('Add Listing', 'geodirectory'), '');
|
|
| 110 | + geodir_create_page(esc_sql(_x('listing-preview', 'page_slug', 'geodirectory')), 'geodir_preview_page', __('Listing Preview', 'geodirectory'), '');
|
|
| 111 | + geodir_create_page(esc_sql(_x('listing-success', 'page_slug', 'geodirectory')), 'geodir_success_page', __('Listing Success', 'geodirectory'), '');
|
|
| 112 | + geodir_create_page(esc_sql(_x('location', 'page_slug', 'geodirectory')), 'geodir_location_page', __('Location', 'geodirectory'), '');
|
|
| 113 | 113 | |
| 114 | - //New since 1.5.3 |
|
| 115 | - geodir_create_page(esc_sql(_x('gd-info', 'page_slug', 'geodirectory')), 'geodir_info_page', __('Info', 'geodirectory'), '');
|
|
| 116 | - geodir_create_page(esc_sql(_x('gd-login', 'page_slug', 'geodirectory')), 'geodir_login_page', __('Login', 'geodirectory'), '');
|
|
| 114 | + //New since 1.5.3 |
|
| 115 | + geodir_create_page(esc_sql(_x('gd-info', 'page_slug', 'geodirectory')), 'geodir_info_page', __('Info', 'geodirectory'), '');
|
|
| 116 | + geodir_create_page(esc_sql(_x('gd-login', 'page_slug', 'geodirectory')), 'geodir_login_page', __('Login', 'geodirectory'), '');
|
|
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | } |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | function geodir_installation_end() |
| 131 | 131 | {
|
| 132 | - //update_option( "geodir_db_version", GEODIRECTORY_VERSION ); |
|
| 132 | + //update_option( "geodir_db_version", GEODIRECTORY_VERSION ); |
|
| 133 | 133 | |
| 134 | - update_option("geodir_installed", 1);
|
|
| 135 | - update_option("geodir_installation_redirect", 1);
|
|
| 136 | - update_option('skip_install_geodir_pages', 0);
|
|
| 134 | + update_option("geodir_installed", 1);
|
|
| 135 | + update_option("geodir_installation_redirect", 1);
|
|
| 136 | + update_option('skip_install_geodir_pages', 0);
|
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -147,45 +147,45 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | function geodir_set_default_options() |
| 149 | 149 | {
|
| 150 | - global $geodir_settings; |
|
| 151 | - /** |
|
| 152 | - * Contains settings array for general tab. |
|
| 153 | - * |
|
| 154 | - * @since 1.0.0 |
|
| 155 | - * @package GeoDirectory |
|
| 156 | - */ |
|
| 157 | - include_once("option-pages/general_settings_array.php");
|
|
| 158 | - /** |
|
| 159 | - * Contains settings array for design tab. |
|
| 160 | - * |
|
| 161 | - * @since 1.0.0 |
|
| 162 | - * @package GeoDirectory |
|
| 163 | - */ |
|
| 164 | - include_once("option-pages/design_settings_array.php");
|
|
| 165 | - /** |
|
| 166 | - * Contains settings array for notifications tab. |
|
| 167 | - * |
|
| 168 | - * @since 1.0.0 |
|
| 169 | - * @package GeoDirectory |
|
| 170 | - */ |
|
| 171 | - include_once("option-pages/notifications_settings_array.php");
|
|
| 172 | - /** |
|
| 173 | - * Contains settings array for permalink tab. |
|
| 174 | - * |
|
| 175 | - * @since 1.0.0 |
|
| 176 | - * @package GeoDirectory |
|
| 177 | - */ |
|
| 178 | - include_once("option-pages/permalink_settings_array.php");
|
|
| 179 | - /** |
|
| 180 | - * Contains settings array for title / meta tab. |
|
| 181 | - * |
|
| 182 | - * @since 1.5.4 |
|
| 183 | - * @package GeoDirectory |
|
| 184 | - */ |
|
| 185 | - include_once("option-pages/title_meta_settings_array.php");
|
|
| 186 | - foreach ($geodir_settings as $value) {
|
|
| 187 | - geodir_update_options($value, true); |
|
| 188 | - } |
|
| 150 | + global $geodir_settings; |
|
| 151 | + /** |
|
| 152 | + * Contains settings array for general tab. |
|
| 153 | + * |
|
| 154 | + * @since 1.0.0 |
|
| 155 | + * @package GeoDirectory |
|
| 156 | + */ |
|
| 157 | + include_once("option-pages/general_settings_array.php");
|
|
| 158 | + /** |
|
| 159 | + * Contains settings array for design tab. |
|
| 160 | + * |
|
| 161 | + * @since 1.0.0 |
|
| 162 | + * @package GeoDirectory |
|
| 163 | + */ |
|
| 164 | + include_once("option-pages/design_settings_array.php");
|
|
| 165 | + /** |
|
| 166 | + * Contains settings array for notifications tab. |
|
| 167 | + * |
|
| 168 | + * @since 1.0.0 |
|
| 169 | + * @package GeoDirectory |
|
| 170 | + */ |
|
| 171 | + include_once("option-pages/notifications_settings_array.php");
|
|
| 172 | + /** |
|
| 173 | + * Contains settings array for permalink tab. |
|
| 174 | + * |
|
| 175 | + * @since 1.0.0 |
|
| 176 | + * @package GeoDirectory |
|
| 177 | + */ |
|
| 178 | + include_once("option-pages/permalink_settings_array.php");
|
|
| 179 | + /** |
|
| 180 | + * Contains settings array for title / meta tab. |
|
| 181 | + * |
|
| 182 | + * @since 1.5.4 |
|
| 183 | + * @package GeoDirectory |
|
| 184 | + */ |
|
| 185 | + include_once("option-pages/title_meta_settings_array.php");
|
|
| 186 | + foreach ($geodir_settings as $value) {
|
|
| 187 | + geodir_update_options($value, true); |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | 190 | } |
| 191 | 191 | |
@@ -199,103 +199,103 @@ discard block |
||
| 199 | 199 | function geodir_set_default_widgets() |
| 200 | 200 | {
|
| 201 | 201 | |
| 202 | - $widget_option_list = array(); |
|
| 203 | - $widgetinfo = array(); |
|
| 204 | - $sidebarvalue_array = array(); |
|
| 205 | - $sidebars_widgets = array(); |
|
| 202 | + $widget_option_list = array(); |
|
| 203 | + $widgetinfo = array(); |
|
| 204 | + $sidebarvalue_array = array(); |
|
| 205 | + $sidebars_widgets = array(); |
|
| 206 | 206 | |
| 207 | - /*===========================*/ |
|
| 208 | - /* Widgets ON HOME PAGE */ |
|
| 209 | - /*===========================*/ |
|
| 207 | + /*===========================*/ |
|
| 208 | + /* Widgets ON HOME PAGE */ |
|
| 209 | + /*===========================*/ |
|
| 210 | 210 | |
| 211 | - $widget_option_list['geodir_home_top'] = |
|
| 212 | - array('popular_post_category' => array("title" => __('Popular Categories', 'geodirectory')),
|
|
| 213 | - 'geodir_map_v3_home_map' => array("autozoom" => 1, "width" => '100%', "heigh" => '425'),
|
|
| 214 | - 'geodir_advance_search' => array()); |
|
| 211 | + $widget_option_list['geodir_home_top'] = |
|
| 212 | + array('popular_post_category' => array("title" => __('Popular Categories', 'geodirectory')),
|
|
| 213 | + 'geodir_map_v3_home_map' => array("autozoom" => 1, "width" => '100%', "heigh" => '425'),
|
|
| 214 | + 'geodir_advance_search' => array()); |
|
| 215 | 215 | |
| 216 | - $widget_option_list['geodir_home_content'] = |
|
| 217 | - array('popular_post_view' => array("title" => __('Popular Places', 'geodirectory'), "layout" => 'list', "add_location_filter" => '1'));
|
|
| 216 | + $widget_option_list['geodir_home_content'] = |
|
| 217 | + array('popular_post_view' => array("title" => __('Popular Places', 'geodirectory'), "layout" => 'list', "add_location_filter" => '1'));
|
|
| 218 | 218 | |
| 219 | - $widget_option_list['geodir_home_right'] = |
|
| 220 | - array('geodir_loginbox' => array("title" => __('My Dashboard', 'geodirectory')),
|
|
| 221 | - 'popular_post_view' => array("title" => __('Latest Places', 'geodirectory'), "add_location_filter" => '1'));
|
|
| 219 | + $widget_option_list['geodir_home_right'] = |
|
| 220 | + array('geodir_loginbox' => array("title" => __('My Dashboard', 'geodirectory')),
|
|
| 221 | + 'popular_post_view' => array("title" => __('Latest Places', 'geodirectory'), "add_location_filter" => '1'));
|
|
| 222 | 222 | |
| 223 | - /*===========================*/ |
|
| 224 | - /* Widgets ON LISTING PAGE */ |
|
| 225 | - /*===========================*/ |
|
| 223 | + /*===========================*/ |
|
| 224 | + /* Widgets ON LISTING PAGE */ |
|
| 225 | + /*===========================*/ |
|
| 226 | 226 | |
| 227 | - $widget_option_list['geodir_listing_top'] = |
|
| 228 | - array('popular_post_category' => array("title" => __('Popular Categories', 'geodirectory')),
|
|
| 229 | - 'geodir_advance_search' => array()); |
|
| 227 | + $widget_option_list['geodir_listing_top'] = |
|
| 228 | + array('popular_post_category' => array("title" => __('Popular Categories', 'geodirectory')),
|
|
| 229 | + 'geodir_advance_search' => array()); |
|
| 230 | 230 | |
| 231 | - $widget_option_list['geodir_listing_right_sidebar'] = |
|
| 232 | - array('geodir_loginbox' => array("title" => __('My Dashboard', 'geodirectory')),
|
|
| 233 | - 'geodir_map_v3_listing_map' => array("autozoom" => 1, "sticky" => 1),
|
|
| 234 | - 'popular_post_view' => array("title" => __('Latest Places', 'geodirectory'), "add_location_filter" => '1'));
|
|
| 231 | + $widget_option_list['geodir_listing_right_sidebar'] = |
|
| 232 | + array('geodir_loginbox' => array("title" => __('My Dashboard', 'geodirectory')),
|
|
| 233 | + 'geodir_map_v3_listing_map' => array("autozoom" => 1, "sticky" => 1),
|
|
| 234 | + 'popular_post_view' => array("title" => __('Latest Places', 'geodirectory'), "add_location_filter" => '1'));
|
|
| 235 | 235 | |
| 236 | 236 | |
| 237 | - /*===========================*/ |
|
| 238 | - /* Widgets ON SEARCH PAGE */ |
|
| 239 | - /*===========================*/ |
|
| 237 | + /*===========================*/ |
|
| 238 | + /* Widgets ON SEARCH PAGE */ |
|
| 239 | + /*===========================*/ |
|
| 240 | 240 | |
| 241 | - $widget_option_list['geodir_search_top'] = |
|
| 242 | - array('popular_post_category' => array("title" => __('Popular Categories', 'geodirectory')),
|
|
| 243 | - 'geodir_advance_search' => array()); |
|
| 241 | + $widget_option_list['geodir_search_top'] = |
|
| 242 | + array('popular_post_category' => array("title" => __('Popular Categories', 'geodirectory')),
|
|
| 243 | + 'geodir_advance_search' => array()); |
|
| 244 | 244 | |
| 245 | - $widget_option_list['geodir_search_right_sidebar'] = |
|
| 246 | - array('geodir_loginbox' => array("title" => __('My Dashboard', 'geodirectory')),
|
|
| 247 | - 'geodir_map_v3_listing_map' => array("autozoom" => 1, "sticky" => 1),
|
|
| 248 | - 'popular_post_view' => array("title" => __('Latest Places', 'geodirectory'), "add_location_filter" => '1'));
|
|
| 245 | + $widget_option_list['geodir_search_right_sidebar'] = |
|
| 246 | + array('geodir_loginbox' => array("title" => __('My Dashboard', 'geodirectory')),
|
|
| 247 | + 'geodir_map_v3_listing_map' => array("autozoom" => 1, "sticky" => 1),
|
|
| 248 | + 'popular_post_view' => array("title" => __('Latest Places', 'geodirectory'), "add_location_filter" => '1'));
|
|
| 249 | 249 | |
| 250 | - /*===========================*/ |
|
| 251 | - /* Widgets ON DETAIL/SINGLE PAGE */ |
|
| 252 | - /*===========================*/ |
|
| 250 | + /*===========================*/ |
|
| 251 | + /* Widgets ON DETAIL/SINGLE PAGE */ |
|
| 252 | + /*===========================*/ |
|
| 253 | 253 | |
| 254 | - $widget_option_list['geodir_detail_sidebar'] = |
|
| 255 | - array('geodir_loginbox' => array("title" => __('My Dashboard', 'geodirectory')),
|
|
| 256 | - 'geodir_map_v3_listing_map' => array("autozoom" => 1, "sticky" => 1),
|
|
| 257 | - 'popular_post_view' => array("title" => __('Latest Places', 'geodirectory'), "add_location_filter" => '1'));
|
|
| 254 | + $widget_option_list['geodir_detail_sidebar'] = |
|
| 255 | + array('geodir_loginbox' => array("title" => __('My Dashboard', 'geodirectory')),
|
|
| 256 | + 'geodir_map_v3_listing_map' => array("autozoom" => 1, "sticky" => 1),
|
|
| 257 | + 'popular_post_view' => array("title" => __('Latest Places', 'geodirectory'), "add_location_filter" => '1'));
|
|
| 258 | 258 | |
| 259 | 259 | |
| 260 | - /*===========================*/ |
|
| 261 | - /* Widgets ON AUTHOR PAGE */ |
|
| 262 | - /*===========================*/ |
|
| 260 | + /*===========================*/ |
|
| 261 | + /* Widgets ON AUTHOR PAGE */ |
|
| 262 | + /*===========================*/ |
|
| 263 | 263 | |
| 264 | 264 | |
| 265 | - $widget_option_list['geodir_author_right_sidebar'] = |
|
| 266 | - array('geodir_loginbox' => array("title" => __('My Dashboard', 'geodirectory')));
|
|
| 265 | + $widget_option_list['geodir_author_right_sidebar'] = |
|
| 266 | + array('geodir_loginbox' => array("title" => __('My Dashboard', 'geodirectory')));
|
|
| 267 | 267 | |
| 268 | 268 | |
| 269 | - $sidebars_widgets = get_option('sidebars_widgets');
|
|
| 269 | + $sidebars_widgets = get_option('sidebars_widgets');
|
|
| 270 | 270 | |
| 271 | - foreach ($widget_option_list as $key => $widget_options) {
|
|
| 271 | + foreach ($widget_option_list as $key => $widget_options) {
|
|
| 272 | 272 | |
| 273 | - foreach ($widget_options as $key2 => $widget_options_obj) {
|
|
| 274 | - $widgetid = 'widget_' . $key2; |
|
| 273 | + foreach ($widget_options as $key2 => $widget_options_obj) {
|
|
| 274 | + $widgetid = 'widget_' . $key2; |
|
| 275 | 275 | |
| 276 | - $widgetinfo[$widgetid][] = $widget_options_obj; |
|
| 276 | + $widgetinfo[$widgetid][] = $widget_options_obj; |
|
| 277 | 277 | |
| 278 | - $sidebarvalue_array[$key][] = $key2 . "-" . (count($widgetinfo[$widgetid])); |
|
| 278 | + $sidebarvalue_array[$key][] = $key2 . "-" . (count($widgetinfo[$widgetid])); |
|
| 279 | 279 | |
| 280 | - $widget_update[$widgetid][count($widgetinfo[$widgetid])] = $widget_options_obj; |
|
| 280 | + $widget_update[$widgetid][count($widgetinfo[$widgetid])] = $widget_options_obj; |
|
| 281 | 281 | |
| 282 | - } |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | - if (!empty($sidebarvalue_array[$key])) {
|
|
| 284 | + if (!empty($sidebarvalue_array[$key])) {
|
|
| 285 | 285 | |
| 286 | - $sidebars_widgets = get_option('sidebars_widgets');
|
|
| 287 | - $sidebars_widgets[$key] = $sidebarvalue_array[$key]; |
|
| 288 | - update_option('sidebars_widgets', $sidebars_widgets);
|
|
| 286 | + $sidebars_widgets = get_option('sidebars_widgets');
|
|
| 287 | + $sidebars_widgets[$key] = $sidebarvalue_array[$key]; |
|
| 288 | + update_option('sidebars_widgets', $sidebars_widgets);
|
|
| 289 | 289 | |
| 290 | - foreach ($widget_update as $key => $value) {
|
|
| 290 | + foreach ($widget_update as $key => $value) {
|
|
| 291 | 291 | |
| 292 | - update_option($key, $value); |
|
| 292 | + update_option($key, $value); |
|
| 293 | 293 | |
| 294 | - } |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | - } |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - } |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | 300 | |
| 301 | 301 | } |
@@ -271,11 +271,11 @@ |
||
| 271 | 271 | foreach ($widget_option_list as $key => $widget_options) {
|
| 272 | 272 | |
| 273 | 273 | foreach ($widget_options as $key2 => $widget_options_obj) {
|
| 274 | - $widgetid = 'widget_' . $key2; |
|
| 274 | + $widgetid = 'widget_'.$key2; |
|
| 275 | 275 | |
| 276 | 276 | $widgetinfo[$widgetid][] = $widget_options_obj; |
| 277 | 277 | |
| 278 | - $sidebarvalue_array[$key][] = $key2 . "-" . (count($widgetinfo[$widgetid])); |
|
| 278 | + $sidebarvalue_array[$key][] = $key2."-".(count($widgetinfo[$widgetid])); |
|
| 279 | 279 | |
| 280 | 280 | $widget_update[$widgetid][count($widgetinfo[$widgetid])] = $widget_options_obj; |
| 281 | 281 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | global $gd_session; |
| 13 | 13 | |
| 14 | 14 | if (!isset($_REQUEST['backandedit'])) { |
| 15 | - $gd_session->un_set('listing'); |
|
| 15 | + $gd_session->un_set('listing'); |
|
| 16 | 16 | } |
| 17 | 17 | // call header |
| 18 | 18 | get_header(); |
@@ -80,7 +80,10 @@ discard block |
||
| 80 | 80 | echo ' geodir-listview '; |
| 81 | 81 | } ?> <?php if ($post_view_class) {
|
| 82 | 82 | echo $post_view_class; |
| 83 | - } ?>" <?php if (isset($listing_width) && $listing_width) echo "style='width:{$listing_width}%;'"; // Width for widget listing
|
|
| 83 | + } ?>" <?php if (isset($listing_width) && $listing_width) { |
|
| 84 | + echo "style='width:{$listing_width}%;'"; |
|
| 85 | + } |
|
| 86 | + // Width for widget listing |
|
| 84 | 87 | |
| 85 | 88 | echo " data-post-id='$post->ID' "; |
| 86 | 89 | /** |
@@ -402,8 +405,10 @@ discard block |
||
| 402 | 405 | */ |
| 403 | 406 | do_action('geodir_after_listing_post_listview');
|
| 404 | 407 | |
| 405 | - else: |
|
| 406 | - $favorite = isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' ? true : false; |
|
| 408 | + else { |
|
| 409 | + : |
|
| 410 | + $favorite = isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' ? true : false; |
|
| 411 | + } |
|
| 407 | 412 | |
| 408 | 413 | /** |
| 409 | 414 | * Called inside the `ul` of the listings template, when no listing found. |
@@ -44,57 +44,57 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | <?php if (have_posts()) : |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Called inside the `ul` of the listings template, but before any `li` elements. |
|
| 49 | - * |
|
| 50 | - * When used by the widget view template then it will only show if there are listings to be shown. |
|
| 51 | - * |
|
| 52 | - * @since 1.0.0 |
|
| 53 | - * @see 'geodir_after_listing_post_listview' |
|
| 54 | - */ |
|
| 55 | - do_action('geodir_before_listing_post_listview');
|
|
| 56 | - |
|
| 57 | - while (have_posts()) : the_post(); |
|
| 58 | - global $post, $wpdb, $preview; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Add a class to the `li` element of the listings list template. |
|
| 62 | - * |
|
| 63 | - * @since 1.0.0 |
|
| 64 | - * @param string $class The extra class for the `li` element, default empty. |
|
| 65 | - */ |
|
| 66 | - $post_view_class = apply_filters('geodir_post_view_extra_class', '');
|
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Add a class to the `article` tag inside the `li` element on the listings list template. |
|
| 70 | - * |
|
| 71 | - * @since 1.0.0 |
|
| 72 | - * @param string $class The extra class for the `article` element, default empty. |
|
| 73 | - */ |
|
| 74 | - $post_view_article_class = apply_filters('geodir_post_view_article_extra_class', '');
|
|
| 75 | - ?> |
|
| 47 | + /** |
|
| 48 | + * Called inside the `ul` of the listings template, but before any `li` elements. |
|
| 49 | + * |
|
| 50 | + * When used by the widget view template then it will only show if there are listings to be shown. |
|
| 51 | + * |
|
| 52 | + * @since 1.0.0 |
|
| 53 | + * @see 'geodir_after_listing_post_listview' |
|
| 54 | + */ |
|
| 55 | + do_action('geodir_before_listing_post_listview');
|
|
| 56 | + |
|
| 57 | + while (have_posts()) : the_post(); |
|
| 58 | + global $post, $wpdb, $preview; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Add a class to the `li` element of the listings list template. |
|
| 62 | + * |
|
| 63 | + * @since 1.0.0 |
|
| 64 | + * @param string $class The extra class for the `li` element, default empty. |
|
| 65 | + */ |
|
| 66 | + $post_view_class = apply_filters('geodir_post_view_extra_class', '');
|
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Add a class to the `article` tag inside the `li` element on the listings list template. |
|
| 70 | + * |
|
| 71 | + * @since 1.0.0 |
|
| 72 | + * @param string $class The extra class for the `article` element, default empty. |
|
| 73 | + */ |
|
| 74 | + $post_view_article_class = apply_filters('geodir_post_view_article_extra_class', '');
|
|
| 75 | + ?> |
|
| 76 | 76 | |
| 77 | 77 | <li class="clearfix <?php if ($grid_view_class) {
|
| 78 | - echo 'geodir-gridview ' . $grid_view_class; |
|
| 79 | - } else {
|
|
| 80 | - echo ' geodir-listview '; |
|
| 81 | - } ?> <?php if ($post_view_class) {
|
|
| 82 | - echo $post_view_class; |
|
| 83 | - } ?>" <?php if (isset($listing_width) && $listing_width) echo "style='width:{$listing_width}%;'"; // Width for widget listing
|
|
| 84 | - |
|
| 85 | - echo " data-post-id='$post->ID' "; |
|
| 86 | - /** |
|
| 87 | - * Called inside the `<li>` tag for listing outputs. |
|
| 88 | - * |
|
| 89 | - * @since 1.5.9 |
|
| 90 | - * @param object $post The post object. |
|
| 91 | - * @param string $string If called on the listing or widget template. |
|
| 92 | - */ |
|
| 93 | - do_action('geodir_listview_inside_li', $post, 'listing');
|
|
| 94 | - ?> > |
|
| 78 | + echo 'geodir-gridview ' . $grid_view_class; |
|
| 79 | + } else {
|
|
| 80 | + echo ' geodir-listview '; |
|
| 81 | + } ?> <?php if ($post_view_class) {
|
|
| 82 | + echo $post_view_class; |
|
| 83 | + } ?>" <?php if (isset($listing_width) && $listing_width) echo "style='width:{$listing_width}%;'"; // Width for widget listing
|
|
| 84 | + |
|
| 85 | + echo " data-post-id='$post->ID' "; |
|
| 86 | + /** |
|
| 87 | + * Called inside the `<li>` tag for listing outputs. |
|
| 88 | + * |
|
| 89 | + * @since 1.5.9 |
|
| 90 | + * @param object $post The post object. |
|
| 91 | + * @param string $string If called on the listing or widget template. |
|
| 92 | + */ |
|
| 93 | + do_action('geodir_listview_inside_li', $post, 'listing');
|
|
| 94 | + ?> > |
|
| 95 | 95 | <article class="geodir-category-listing <?php if ($post_view_article_class) {
|
| 96 | - echo $post_view_article_class; |
|
| 97 | - } ?>"> |
|
| 96 | + echo $post_view_article_class; |
|
| 97 | + } ?>"> |
|
| 98 | 98 | <div class="geodir-post-img <?php echo apply_filters('geodir_listing_listview_thumb_extra_class', '', 'listing'); ?>">
|
| 99 | 99 | <?php if ($fimage = geodir_show_featured_image($post->ID, 'list-thumb', true, false, $post->featured_image)) { ?>
|
| 100 | 100 | |
@@ -102,37 +102,37 @@ discard block |
||
| 102 | 102 | <?php echo $fimage; ?> |
| 103 | 103 | </a> |
| 104 | 104 | <?php |
| 105 | - /** |
|
| 106 | - * Called before badges are output. |
|
| 107 | - * |
|
| 108 | - * Called on the listings template after the image has been output and before the badges like `new` or `featured` are output. |
|
| 109 | - * |
|
| 110 | - * @since 1.0.0 |
|
| 111 | - * @param object $post The post object. |
|
| 112 | - * @see 'geodir_after_badge_on_image' |
|
| 113 | - */ |
|
| 114 | - do_action('geodir_before_badge_on_image', $post);
|
|
| 115 | - if (isset($post->is_featured) && $post->is_featured) {
|
|
| 116 | - echo geodir_show_badges_on_image('featured', $post, get_permalink());
|
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - $geodir_days_new = (int)get_option('geodir_listing_new_days');
|
|
| 120 | - |
|
| 121 | - if (round(abs(strtotime($post->post_date) - strtotime(date('Y-m-d'))) / 86400) < $geodir_days_new) {
|
|
| 122 | - echo geodir_show_badges_on_image('new', $post, get_permalink());
|
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Called after badges are output. |
|
| 127 | - * |
|
| 128 | - * Called on the listings template after the image and badges like `new` or `featured` have been output. |
|
| 129 | - * |
|
| 130 | - * @since 1.0.0 |
|
| 131 | - * @param object $post The post object. |
|
| 132 | - * @see 'geodir_before_badge_on_image' |
|
| 133 | - */ |
|
| 134 | - do_action('geodir_after_badge_on_image', $post);
|
|
| 135 | - ?> |
|
| 105 | + /** |
|
| 106 | + * Called before badges are output. |
|
| 107 | + * |
|
| 108 | + * Called on the listings template after the image has been output and before the badges like `new` or `featured` are output. |
|
| 109 | + * |
|
| 110 | + * @since 1.0.0 |
|
| 111 | + * @param object $post The post object. |
|
| 112 | + * @see 'geodir_after_badge_on_image' |
|
| 113 | + */ |
|
| 114 | + do_action('geodir_before_badge_on_image', $post);
|
|
| 115 | + if (isset($post->is_featured) && $post->is_featured) {
|
|
| 116 | + echo geodir_show_badges_on_image('featured', $post, get_permalink());
|
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + $geodir_days_new = (int)get_option('geodir_listing_new_days');
|
|
| 120 | + |
|
| 121 | + if (round(abs(strtotime($post->post_date) - strtotime(date('Y-m-d'))) / 86400) < $geodir_days_new) {
|
|
| 122 | + echo geodir_show_badges_on_image('new', $post, get_permalink());
|
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Called after badges are output. |
|
| 127 | + * |
|
| 128 | + * Called on the listings template after the image and badges like `new` or `featured` have been output. |
|
| 129 | + * |
|
| 130 | + * @since 1.0.0 |
|
| 131 | + * @param object $post The post object. |
|
| 132 | + * @see 'geodir_before_badge_on_image' |
|
| 133 | + */ |
|
| 134 | + do_action('geodir_after_badge_on_image', $post);
|
|
| 135 | + ?> |
|
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | <?php } ?> |
@@ -142,15 +142,15 @@ discard block |
||
| 142 | 142 | <div class="geodir-content <?php echo apply_filters('geodir_listing_listview_content_extra_class', '', 'listing'); ?>">
|
| 143 | 143 | |
| 144 | 144 | <?php |
| 145 | - /** |
|
| 146 | - * Called before the post title on the listings view template. |
|
| 147 | - * |
|
| 148 | - * @since 1.0.0 |
|
| 149 | - * @param string $type The template type, default 'listview'. |
|
| 150 | - * @param object $post The post object. |
|
| 151 | - * @see 'geodir_after_listing_post_title' |
|
| 152 | - */ |
|
| 153 | - do_action('geodir_before_listing_post_title', 'listview', $post); ?>
|
|
| 145 | + /** |
|
| 146 | + * Called before the post title on the listings view template. |
|
| 147 | + * |
|
| 148 | + * @since 1.0.0 |
|
| 149 | + * @param string $type The template type, default 'listview'. |
|
| 150 | + * @param object $post The post object. |
|
| 151 | + * @see 'geodir_after_listing_post_title' |
|
| 152 | + */ |
|
| 153 | + do_action('geodir_before_listing_post_title', 'listview', $post); ?>
|
|
| 154 | 154 | |
| 155 | 155 | <header class="geodir-entry-header"><h2 class="geodir-entry-title"> |
| 156 | 156 | <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> |
@@ -162,225 +162,225 @@ discard block |
||
| 162 | 162 | <!-- .entry-header --> |
| 163 | 163 | |
| 164 | 164 | <?php |
| 165 | - /** |
|
| 166 | - * Called after the post title on the listings view template. |
|
| 167 | - * |
|
| 168 | - * @since 1.0.0 |
|
| 169 | - * @param string $type The template type, default 'listview'. |
|
| 170 | - * @param object $post The post object. |
|
| 171 | - * @see 'geodir_before_listing_post_title' |
|
| 172 | - */ |
|
| 173 | - do_action('geodir_after_listing_post_title', 'listview', $post); ?>
|
|
| 165 | + /** |
|
| 166 | + * Called after the post title on the listings view template. |
|
| 167 | + * |
|
| 168 | + * @since 1.0.0 |
|
| 169 | + * @param string $type The template type, default 'listview'. |
|
| 170 | + * @param object $post The post object. |
|
| 171 | + * @see 'geodir_before_listing_post_title' |
|
| 172 | + */ |
|
| 173 | + do_action('geodir_after_listing_post_title', 'listview', $post); ?>
|
|
| 174 | 174 | |
| 175 | 175 | <?php /// Print Distance |
| 176 | - if ( ( isset( $_REQUEST['sgeo_lat'] ) && $_REQUEST['sgeo_lat'] != '' ) || ( $related_nearest && $related_parent_lat ) ) {
|
|
| 177 | - if ( $related_nearest && $related_parent_lat ) {
|
|
| 178 | - $startPoint = array('latitude' => $related_parent_lat, 'longitude' => $related_parent_lon);
|
|
| 179 | - } else {
|
|
| 180 | - $startPoint = array('latitude' => $_REQUEST['sgeo_lat'], 'longitude' => $_REQUEST['sgeo_lon']);
|
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - $endLat = $post->post_latitude; |
|
| 184 | - $endLon = $post->post_longitude; |
|
| 185 | - $endPoint = array('latitude' => $endLat, 'longitude' => $endLon);
|
|
| 186 | - $uom = get_option('geodir_search_dist_1');
|
|
| 187 | - $distance = geodir_calculateDistanceFromLatLong($startPoint, $endPoint, $uom); ?> |
|
| 176 | + if ( ( isset( $_REQUEST['sgeo_lat'] ) && $_REQUEST['sgeo_lat'] != '' ) || ( $related_nearest && $related_parent_lat ) ) {
|
|
| 177 | + if ( $related_nearest && $related_parent_lat ) {
|
|
| 178 | + $startPoint = array('latitude' => $related_parent_lat, 'longitude' => $related_parent_lon);
|
|
| 179 | + } else {
|
|
| 180 | + $startPoint = array('latitude' => $_REQUEST['sgeo_lat'], 'longitude' => $_REQUEST['sgeo_lon']);
|
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + $endLat = $post->post_latitude; |
|
| 184 | + $endLon = $post->post_longitude; |
|
| 185 | + $endPoint = array('latitude' => $endLat, 'longitude' => $endLon);
|
|
| 186 | + $uom = get_option('geodir_search_dist_1');
|
|
| 187 | + $distance = geodir_calculateDistanceFromLatLong($startPoint, $endPoint, $uom); ?> |
|
| 188 | 188 | <h3> |
| 189 | 189 | <?php |
| 190 | 190 | |
| 191 | - if (round($distance, 2) == 0) {
|
|
| 192 | - $uom = get_option('geodir_search_dist_2');
|
|
| 193 | - |
|
| 194 | - $distance = geodir_calculateDistanceFromLatLong($startPoint, $endPoint, $uom); |
|
| 195 | - if ($uom == 'feet') {
|
|
| 196 | - $uom = __('feet', 'geodirectory');
|
|
| 197 | - } else {
|
|
| 198 | - $uom = __('meters', 'geodirectory');
|
|
| 199 | - } |
|
| 200 | - echo round($distance) . ' ' . $uom . '<br />'; |
|
| 201 | - } else {
|
|
| 202 | - if ($uom == 'miles') {
|
|
| 203 | - $uom = __('miles', 'geodirectory');
|
|
| 204 | - } else {
|
|
| 205 | - $uom = __('km', 'geodirectory');
|
|
| 206 | - } |
|
| 207 | - echo round($distance, 2) . ' ' . $uom . '<br />'; |
|
| 208 | - } |
|
| 209 | - ?> |
|
| 191 | + if (round($distance, 2) == 0) {
|
|
| 192 | + $uom = get_option('geodir_search_dist_2');
|
|
| 193 | + |
|
| 194 | + $distance = geodir_calculateDistanceFromLatLong($startPoint, $endPoint, $uom); |
|
| 195 | + if ($uom == 'feet') {
|
|
| 196 | + $uom = __('feet', 'geodirectory');
|
|
| 197 | + } else {
|
|
| 198 | + $uom = __('meters', 'geodirectory');
|
|
| 199 | + } |
|
| 200 | + echo round($distance) . ' ' . $uom . '<br />'; |
|
| 201 | + } else {
|
|
| 202 | + if ($uom == 'miles') {
|
|
| 203 | + $uom = __('miles', 'geodirectory');
|
|
| 204 | + } else {
|
|
| 205 | + $uom = __('km', 'geodirectory');
|
|
| 206 | + } |
|
| 207 | + echo round($distance, 2) . ' ' . $uom . '<br />'; |
|
| 208 | + } |
|
| 209 | + ?> |
|
| 210 | 210 | </h3> |
| 211 | 211 | <?php } ?> |
| 212 | 212 | |
| 213 | 213 | |
| 214 | 214 | <?php |
| 215 | - /** |
|
| 216 | - * Called before the post excerpt on the listings view template. |
|
| 217 | - * |
|
| 218 | - * @since 1.0.0 |
|
| 219 | - * @param object $post The post object. |
|
| 220 | - * @see 'geodir_after_listing_post_excerpt' |
|
| 221 | - */ |
|
| 222 | - do_action('geodir_before_listing_post_excerpt', $post); ?>
|
|
| 215 | + /** |
|
| 216 | + * Called before the post excerpt on the listings view template. |
|
| 217 | + * |
|
| 218 | + * @since 1.0.0 |
|
| 219 | + * @param object $post The post object. |
|
| 220 | + * @see 'geodir_after_listing_post_excerpt' |
|
| 221 | + */ |
|
| 222 | + do_action('geodir_before_listing_post_excerpt', $post); ?>
|
|
| 223 | 223 | <?php echo geodir_show_listing_info('listing'); ?>
|
| 224 | 224 | <div class="geodir-entry-content"> |
| 225 | 225 | |
| 226 | 226 | <?php |
| 227 | - /** |
|
| 228 | - * Filter to hide the listing excerpt |
|
| 229 | - * |
|
| 230 | - * @since 1.5.3 |
|
| 231 | - * @param bool $display Display the excerpt or not. Default true. |
|
| 232 | - * @param string $view The view type, default 'listview'. |
|
| 233 | - * @param object $post The post object. |
|
| 234 | - */ |
|
| 235 | - $show_listing_excerpt = apply_filters('geodir_show_listing_post_excerpt', true, 'listview', $post);
|
|
| 236 | - if ($show_listing_excerpt) {
|
|
| 237 | - if ( isset( $character_count ) && ( $character_count || $character_count == '0' ) ) {
|
|
| 238 | - $content_out = geodir_max_excerpt( $character_count ); |
|
| 239 | - } else {
|
|
| 240 | - $content_out = get_the_excerpt(); |
|
| 241 | - } |
|
| 242 | - if ( ! empty( $content_out ) ) {
|
|
| 243 | - echo "<p>" . $content_out . "</p>"; |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - ?></div> |
|
| 227 | + /** |
|
| 228 | + * Filter to hide the listing excerpt |
|
| 229 | + * |
|
| 230 | + * @since 1.5.3 |
|
| 231 | + * @param bool $display Display the excerpt or not. Default true. |
|
| 232 | + * @param string $view The view type, default 'listview'. |
|
| 233 | + * @param object $post The post object. |
|
| 234 | + */ |
|
| 235 | + $show_listing_excerpt = apply_filters('geodir_show_listing_post_excerpt', true, 'listview', $post);
|
|
| 236 | + if ($show_listing_excerpt) {
|
|
| 237 | + if ( isset( $character_count ) && ( $character_count || $character_count == '0' ) ) {
|
|
| 238 | + $content_out = geodir_max_excerpt( $character_count ); |
|
| 239 | + } else {
|
|
| 240 | + $content_out = get_the_excerpt(); |
|
| 241 | + } |
|
| 242 | + if ( ! empty( $content_out ) ) {
|
|
| 243 | + echo "<p>" . $content_out . "</p>"; |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + ?></div> |
|
| 247 | 247 | |
| 248 | 248 | <?php |
| 249 | - /** |
|
| 250 | - * Called after the post excerpt on the listings view template. |
|
| 251 | - * |
|
| 252 | - * @since 1.0.0 |
|
| 253 | - * @param object $post The post object. |
|
| 254 | - * @see 'geodir_before_listing_post_excerpt' |
|
| 255 | - */ |
|
| 256 | - do_action('geodir_after_listing_post_excerpt', $post); ?>
|
|
| 249 | + /** |
|
| 250 | + * Called after the post excerpt on the listings view template. |
|
| 251 | + * |
|
| 252 | + * @since 1.0.0 |
|
| 253 | + * @param object $post The post object. |
|
| 254 | + * @see 'geodir_before_listing_post_excerpt' |
|
| 255 | + */ |
|
| 256 | + do_action('geodir_after_listing_post_excerpt', $post); ?>
|
|
| 257 | 257 | </div> |
| 258 | 258 | <!-- gd-content ends here--> |
| 259 | 259 | <?php |
| 260 | - /** |
|
| 261 | - * Called after printing listing content. |
|
| 262 | - * |
|
| 263 | - * @since 1.5.3 |
|
| 264 | - * @param object $post The post object. |
|
| 265 | - * @param string $view The view type, default 'listing'. |
|
| 266 | - */ |
|
| 267 | - do_action( 'geodir_after_listing_content', $post, 'listing' ); ?> |
|
| 260 | + /** |
|
| 261 | + * Called after printing listing content. |
|
| 262 | + * |
|
| 263 | + * @since 1.5.3 |
|
| 264 | + * @param object $post The post object. |
|
| 265 | + * @param string $view The view type, default 'listing'. |
|
| 266 | + */ |
|
| 267 | + do_action( 'geodir_after_listing_content', $post, 'listing' ); ?> |
|
| 268 | 268 | <footer class="geodir-entry-meta <?php echo apply_filters('geodir_listing_listview_meta_extra_class', '', 'listing'); ?>">
|
| 269 | 269 | <div class="geodir-addinfo clearfix <?php echo apply_filters('geodir_listing_listview_addinfo_extra_class', '', 'listing'); ?>">
|
| 270 | 270 | |
| 271 | 271 | <?php |
| 272 | - /** |
|
| 273 | - * Called before printing review stars html. |
|
| 274 | - * |
|
| 275 | - * @since 1.5.3 |
|
| 276 | - * @param object $post The post object. |
|
| 277 | - * @param string $view The view type, default 'listing'. |
|
| 278 | - */ |
|
| 279 | - do_action( 'geodir_before_review_html', $post, 'listing' ); |
|
| 280 | - |
|
| 281 | - $review_show = geodir_is_reviews_show('listview');
|
|
| 282 | - |
|
| 283 | - if ($review_show) {
|
|
| 284 | - |
|
| 285 | - if (!$preview) {
|
|
| 286 | - $post_avgratings = geodir_get_post_rating($post->ID); |
|
| 287 | - /** |
|
| 288 | - * Called before the rating stars are output on the listings view template. |
|
| 289 | - * |
|
| 290 | - * @since 1.0.0 |
|
| 291 | - * @param float $post_avgratings The average rating for the post. |
|
| 292 | - * @param int $post->ID The post ID. |
|
| 293 | - * @see 'geodir_after_review_rating_stars_on_listview' |
|
| 294 | - */ |
|
| 295 | - do_action('geodir_before_review_rating_stars_on_listview', $post_avgratings, $post->ID);
|
|
| 296 | - |
|
| 297 | - echo geodir_get_rating_stars($post_avgratings, $post->ID); |
|
| 298 | - |
|
| 299 | - /** |
|
| 300 | - * Called after the rating stars are output on the listings view template. |
|
| 301 | - * |
|
| 302 | - * @since 1.0.0 |
|
| 303 | - * @param float $post_avgratings The average rating for the post. |
|
| 304 | - * @param int $post->ID The post ID. |
|
| 305 | - * @see 'geodir_before_review_rating_stars_on_listview' |
|
| 306 | - */ |
|
| 307 | - do_action('geodir_after_review_rating_stars_on_listview', $post_avgratings, $post->ID);
|
|
| 308 | - } |
|
| 309 | - ?> |
|
| 272 | + /** |
|
| 273 | + * Called before printing review stars html. |
|
| 274 | + * |
|
| 275 | + * @since 1.5.3 |
|
| 276 | + * @param object $post The post object. |
|
| 277 | + * @param string $view The view type, default 'listing'. |
|
| 278 | + */ |
|
| 279 | + do_action( 'geodir_before_review_html', $post, 'listing' ); |
|
| 280 | + |
|
| 281 | + $review_show = geodir_is_reviews_show('listview');
|
|
| 282 | + |
|
| 283 | + if ($review_show) {
|
|
| 284 | + |
|
| 285 | + if (!$preview) {
|
|
| 286 | + $post_avgratings = geodir_get_post_rating($post->ID); |
|
| 287 | + /** |
|
| 288 | + * Called before the rating stars are output on the listings view template. |
|
| 289 | + * |
|
| 290 | + * @since 1.0.0 |
|
| 291 | + * @param float $post_avgratings The average rating for the post. |
|
| 292 | + * @param int $post->ID The post ID. |
|
| 293 | + * @see 'geodir_after_review_rating_stars_on_listview' |
|
| 294 | + */ |
|
| 295 | + do_action('geodir_before_review_rating_stars_on_listview', $post_avgratings, $post->ID);
|
|
| 296 | + |
|
| 297 | + echo geodir_get_rating_stars($post_avgratings, $post->ID); |
|
| 298 | + |
|
| 299 | + /** |
|
| 300 | + * Called after the rating stars are output on the listings view template. |
|
| 301 | + * |
|
| 302 | + * @since 1.0.0 |
|
| 303 | + * @param float $post_avgratings The average rating for the post. |
|
| 304 | + * @param int $post->ID The post ID. |
|
| 305 | + * @see 'geodir_before_review_rating_stars_on_listview' |
|
| 306 | + */ |
|
| 307 | + do_action('geodir_after_review_rating_stars_on_listview', $post_avgratings, $post->ID);
|
|
| 308 | + } |
|
| 309 | + ?> |
|
| 310 | 310 | <a href="<?php comments_link(); ?>" class="geodir-pcomments"><i |
| 311 | 311 | class="fas fa-comments"></i> |
| 312 | 312 | <?php geodir_comments_number($post->rating_count); ?></a> |
| 313 | 313 | <?php |
| 314 | - } |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | 316 | |
| 317 | - /** |
|
| 318 | - * Called after printing favorite html. |
|
| 319 | - * |
|
| 320 | - * @since 1.0.0 |
|
| 321 | - */ |
|
| 322 | - do_action( 'geodir_after_favorite_html', $post->ID, 'listing' ); |
|
| 317 | + /** |
|
| 318 | + * Called after printing favorite html. |
|
| 319 | + * |
|
| 320 | + * @since 1.0.0 |
|
| 321 | + */ |
|
| 322 | + do_action( 'geodir_after_favorite_html', $post->ID, 'listing' ); |
|
| 323 | 323 | |
| 324 | 324 | |
| 325 | - /** |
|
| 326 | - * Called after printing map pin point. |
|
| 327 | - * |
|
| 328 | - * @since 1.0.0 |
|
| 329 | - * @since 1.5.9 Added $post as second param. |
|
| 330 | - * @param int $post->ID The post id. |
|
| 331 | - * @param object $post The post object. |
|
| 332 | - */ |
|
| 333 | - do_action( 'geodir_listing_after_pinpoint', $post->ID ,$post); |
|
| 325 | + /** |
|
| 326 | + * Called after printing map pin point. |
|
| 327 | + * |
|
| 328 | + * @since 1.0.0 |
|
| 329 | + * @since 1.5.9 Added $post as second param. |
|
| 330 | + * @param int $post->ID The post id. |
|
| 331 | + * @param object $post The post object. |
|
| 332 | + */ |
|
| 333 | + do_action( 'geodir_listing_after_pinpoint', $post->ID ,$post); |
|
| 334 | 334 | |
| 335 | - if ($post->post_author == get_current_user_id()) { ?>
|
|
| 335 | + if ($post->post_author == get_current_user_id()) { ?>
|
|
| 336 | 336 | <?php |
| 337 | - $addplacelink = get_permalink(geodir_add_listing_page_id()); |
|
| 338 | - $editlink = geodir_getlink($addplacelink, array('pid' => $post->ID), false);
|
|
| 339 | - $upgradelink = geodir_getlink($editlink, array('upgrade' => '1'), false);
|
|
| 337 | + $addplacelink = get_permalink(geodir_add_listing_page_id()); |
|
| 338 | + $editlink = geodir_getlink($addplacelink, array('pid' => $post->ID), false);
|
|
| 339 | + $upgradelink = geodir_getlink($editlink, array('upgrade' => '1'), false);
|
|
| 340 | 340 | |
| 341 | - $ajaxlink = geodir_get_ajax_url(); |
|
| 342 | - $deletelink = geodir_getlink($ajaxlink, array('geodir_ajax' => 'add_listing', 'ajax_action' => 'delete', 'pid' => $post->ID), false);
|
|
| 341 | + $ajaxlink = geodir_get_ajax_url(); |
|
| 342 | + $deletelink = geodir_getlink($ajaxlink, array('geodir_ajax' => 'add_listing', 'ajax_action' => 'delete', 'pid' => $post->ID), false);
|
|
| 343 | 343 | |
| 344 | - ?> |
|
| 344 | + ?> |
|
| 345 | 345 | |
| 346 | 346 | <span class="geodir-authorlink clearfix"> |
| 347 | 347 | |
| 348 | 348 | <?php if (isset($_REQUEST['geodir_dashbord']) && $_REQUEST['geodir_dashbord']) {
|
| 349 | - /** |
|
| 350 | - * Called before the edit post link on the listings view template used on the author page. |
|
| 351 | - * |
|
| 352 | - * @since 1.0.0 |
|
| 353 | - * @see 'geodir_after_edit_post_link_on_listing' |
|
| 354 | - */ |
|
| 355 | - do_action('geodir_before_edit_post_link_on_listing');
|
|
| 356 | - ?> |
|
| 349 | + /** |
|
| 350 | + * Called before the edit post link on the listings view template used on the author page. |
|
| 351 | + * |
|
| 352 | + * @since 1.0.0 |
|
| 353 | + * @see 'geodir_after_edit_post_link_on_listing' |
|
| 354 | + */ |
|
| 355 | + do_action('geodir_before_edit_post_link_on_listing');
|
|
| 356 | + ?> |
|
| 357 | 357 | |
| 358 | 358 | <a href="<?php echo esc_url($editlink); ?>" class="geodir-edit" |
| 359 | 359 | title="<?php _e('Edit Listing', 'geodirectory'); ?>">
|
| 360 | 360 | <?php |
| 361 | - $geodir_listing_edit_icon = apply_filters('geodir_listing_edit_icon', 'fas fa-edit');
|
|
| 362 | - echo '<i class="'. $geodir_listing_edit_icon .'"></i>'; |
|
| 363 | - ?> |
|
| 361 | + $geodir_listing_edit_icon = apply_filters('geodir_listing_edit_icon', 'fas fa-edit');
|
|
| 362 | + echo '<i class="'. $geodir_listing_edit_icon .'"></i>'; |
|
| 363 | + ?> |
|
| 364 | 364 | <?php _e('Edit', 'geodirectory'); ?>
|
| 365 | 365 | </a> |
| 366 | 366 | <a href="<?php echo esc_url($deletelink); ?>" class="geodir-delete" |
| 367 | 367 | title="<?php _e('Delete Listing', 'geodirectory'); ?>">
|
| 368 | 368 | <?php |
| 369 | - $geodir_listing_delete_icon = apply_filters('geodir_listing_delete_icon', 'fas fa-times');
|
|
| 370 | - echo '<i class="'. $geodir_listing_delete_icon .'"></i>'; |
|
| 371 | - ?> |
|
| 369 | + $geodir_listing_delete_icon = apply_filters('geodir_listing_delete_icon', 'fas fa-times');
|
|
| 370 | + echo '<i class="'. $geodir_listing_delete_icon .'"></i>'; |
|
| 371 | + ?> |
|
| 372 | 372 | <?php _e('Delete', 'geodirectory'); ?>
|
| 373 | 373 | </a> |
| 374 | 374 | <?php |
| 375 | 375 | |
| 376 | - /** |
|
| 377 | - * Called after the edit post link on the listings view template used on the author page. |
|
| 378 | - * |
|
| 379 | - * @since 1.0.0 |
|
| 380 | - * @see 'geodir_before_edit_post_link_on_listing' |
|
| 381 | - */ |
|
| 382 | - do_action('geodir_after_edit_post_link_on_listing');
|
|
| 383 | - } ?> |
|
| 376 | + /** |
|
| 377 | + * Called after the edit post link on the listings view template used on the author page. |
|
| 378 | + * |
|
| 379 | + * @since 1.0.0 |
|
| 380 | + * @see 'geodir_before_edit_post_link_on_listing' |
|
| 381 | + */ |
|
| 382 | + do_action('geodir_after_edit_post_link_on_listing');
|
|
| 383 | + } ?> |
|
| 384 | 384 | </span> |
| 385 | 385 | |
| 386 | 386 | <?php } ?> |
@@ -393,32 +393,32 @@ discard block |
||
| 393 | 393 | </li> |
| 394 | 394 | |
| 395 | 395 | <?php |
| 396 | - endwhile; |
|
| 397 | - |
|
| 398 | - /** |
|
| 399 | - * Called inside the `ul` of the listings template, but after all `li` elements. |
|
| 400 | - * |
|
| 401 | - * When used by the widget view template then it will only show if there are listings to be shown. |
|
| 402 | - * |
|
| 403 | - * @since 1.0.0 |
|
| 404 | - * @see 'geodir_before_listing_post_listview' |
|
| 405 | - */ |
|
| 406 | - do_action('geodir_after_listing_post_listview');
|
|
| 407 | - |
|
| 408 | - else: |
|
| 396 | + endwhile; |
|
| 397 | + |
|
| 398 | + /** |
|
| 399 | + * Called inside the `ul` of the listings template, but after all `li` elements. |
|
| 400 | + * |
|
| 401 | + * When used by the widget view template then it will only show if there are listings to be shown. |
|
| 402 | + * |
|
| 403 | + * @since 1.0.0 |
|
| 404 | + * @see 'geodir_before_listing_post_listview' |
|
| 405 | + */ |
|
| 406 | + do_action('geodir_after_listing_post_listview');
|
|
| 407 | + |
|
| 408 | + else: |
|
| 409 | 409 | $favorite = isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' ? true : false; |
| 410 | 410 | |
| 411 | 411 | /** |
| 412 | - * Called inside the `ul` of the listings template, when no listing found. |
|
| 413 | - * |
|
| 414 | - * @since 1.5.5 |
|
| 412 | + * Called inside the `ul` of the listings template, when no listing found. |
|
| 413 | + * |
|
| 414 | + * @since 1.5.5 |
|
| 415 | 415 | * @param string 'listing-listview' Listing listview template. |
| 416 | 416 | * @param bool $favorite Are favorite listings results? |
| 417 | - */ |
|
| 418 | - do_action('geodir_message_not_found_on_listing', 'listing-listview', $favorite);
|
|
| 419 | - endif; |
|
| 417 | + */ |
|
| 418 | + do_action('geodir_message_not_found_on_listing', 'listing-listview', $favorite);
|
|
| 419 | + endif; |
|
| 420 | 420 | |
| 421 | - ?> |
|
| 421 | + ?> |
|
| 422 | 422 | </ul> <!-- geodir_category_list_view ends here--> |
| 423 | 423 | |
| 424 | 424 | <div class="clear"></div> |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | ?> |
| 76 | 76 | |
| 77 | 77 | <li class="clearfix <?php if ($grid_view_class) {
|
| 78 | - echo 'geodir-gridview ' . $grid_view_class; |
|
| 78 | + echo 'geodir-gridview '.$grid_view_class; |
|
| 79 | 79 | } else {
|
| 80 | 80 | echo ' geodir-listview '; |
| 81 | 81 | } ?> <?php if ($post_view_class) {
|
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | echo geodir_show_badges_on_image('featured', $post, get_permalink());
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - $geodir_days_new = (int)get_option('geodir_listing_new_days');
|
|
| 119 | + $geodir_days_new = (int) get_option('geodir_listing_new_days');
|
|
| 120 | 120 | |
| 121 | 121 | if (round(abs(strtotime($post->post_date) - strtotime(date('Y-m-d'))) / 86400) < $geodir_days_new) {
|
| 122 | 122 | echo geodir_show_badges_on_image('new', $post, get_permalink());
|
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | do_action('geodir_after_listing_post_title', 'listview', $post); ?>
|
| 174 | 174 | |
| 175 | 175 | <?php /// Print Distance |
| 176 | - if ( ( isset( $_REQUEST['sgeo_lat'] ) && $_REQUEST['sgeo_lat'] != '' ) || ( $related_nearest && $related_parent_lat ) ) {
|
|
| 177 | - if ( $related_nearest && $related_parent_lat ) {
|
|
| 176 | + if ((isset($_REQUEST['sgeo_lat']) && $_REQUEST['sgeo_lat'] != '') || ($related_nearest && $related_parent_lat)) {
|
|
| 177 | + if ($related_nearest && $related_parent_lat) {
|
|
| 178 | 178 | $startPoint = array('latitude' => $related_parent_lat, 'longitude' => $related_parent_lon);
|
| 179 | 179 | } else {
|
| 180 | 180 | $startPoint = array('latitude' => $_REQUEST['sgeo_lat'], 'longitude' => $_REQUEST['sgeo_lon']);
|
@@ -197,14 +197,14 @@ discard block |
||
| 197 | 197 | } else {
|
| 198 | 198 | $uom = __('meters', 'geodirectory');
|
| 199 | 199 | } |
| 200 | - echo round($distance) . ' ' . $uom . '<br />'; |
|
| 200 | + echo round($distance).' '.$uom.'<br />'; |
|
| 201 | 201 | } else {
|
| 202 | 202 | if ($uom == 'miles') {
|
| 203 | 203 | $uom = __('miles', 'geodirectory');
|
| 204 | 204 | } else {
|
| 205 | 205 | $uom = __('km', 'geodirectory');
|
| 206 | 206 | } |
| 207 | - echo round($distance, 2) . ' ' . $uom . '<br />'; |
|
| 207 | + echo round($distance, 2).' '.$uom.'<br />'; |
|
| 208 | 208 | } |
| 209 | 209 | ?> |
| 210 | 210 | </h3> |
@@ -234,13 +234,13 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | $show_listing_excerpt = apply_filters('geodir_show_listing_post_excerpt', true, 'listview', $post);
|
| 236 | 236 | if ($show_listing_excerpt) {
|
| 237 | - if ( isset( $character_count ) && ( $character_count || $character_count == '0' ) ) {
|
|
| 238 | - $content_out = geodir_max_excerpt( $character_count ); |
|
| 237 | + if (isset($character_count) && ($character_count || $character_count == '0')) {
|
|
| 238 | + $content_out = geodir_max_excerpt($character_count); |
|
| 239 | 239 | } else {
|
| 240 | 240 | $content_out = get_the_excerpt(); |
| 241 | 241 | } |
| 242 | - if ( ! empty( $content_out ) ) {
|
|
| 243 | - echo "<p>" . $content_out . "</p>"; |
|
| 242 | + if (!empty($content_out)) {
|
|
| 243 | + echo "<p>".$content_out."</p>"; |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | ?></div> |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * @param object $post The post object. |
| 265 | 265 | * @param string $view The view type, default 'listing'. |
| 266 | 266 | */ |
| 267 | - do_action( 'geodir_after_listing_content', $post, 'listing' ); ?> |
|
| 267 | + do_action('geodir_after_listing_content', $post, 'listing'); ?>
|
|
| 268 | 268 | <footer class="geodir-entry-meta <?php echo apply_filters('geodir_listing_listview_meta_extra_class', '', 'listing'); ?>">
|
| 269 | 269 | <div class="geodir-addinfo clearfix <?php echo apply_filters('geodir_listing_listview_addinfo_extra_class', '', 'listing'); ?>">
|
| 270 | 270 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | * @param object $post The post object. |
| 277 | 277 | * @param string $view The view type, default 'listing'. |
| 278 | 278 | */ |
| 279 | - do_action( 'geodir_before_review_html', $post, 'listing' ); |
|
| 279 | + do_action('geodir_before_review_html', $post, 'listing');
|
|
| 280 | 280 | |
| 281 | 281 | $review_show = geodir_is_reviews_show('listview');
|
| 282 | 282 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * |
| 320 | 320 | * @since 1.0.0 |
| 321 | 321 | */ |
| 322 | - do_action( 'geodir_after_favorite_html', $post->ID, 'listing' ); |
|
| 322 | + do_action('geodir_after_favorite_html', $post->ID, 'listing');
|
|
| 323 | 323 | |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * @param int $post->ID The post id. |
| 331 | 331 | * @param object $post The post object. |
| 332 | 332 | */ |
| 333 | - do_action( 'geodir_listing_after_pinpoint', $post->ID ,$post); |
|
| 333 | + do_action('geodir_listing_after_pinpoint', $post->ID, $post);
|
|
| 334 | 334 | |
| 335 | 335 | if ($post->post_author == get_current_user_id()) { ?>
|
| 336 | 336 | <?php |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | title="<?php _e('Edit Listing', 'geodirectory'); ?>">
|
| 360 | 360 | <?php |
| 361 | 361 | $geodir_listing_edit_icon = apply_filters('geodir_listing_edit_icon', 'fas fa-edit');
|
| 362 | - echo '<i class="'. $geodir_listing_edit_icon .'"></i>'; |
|
| 362 | + echo '<i class="'.$geodir_listing_edit_icon.'"></i>'; |
|
| 363 | 363 | ?> |
| 364 | 364 | <?php _e('Edit', 'geodirectory'); ?>
|
| 365 | 365 | </a> |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | title="<?php _e('Delete Listing', 'geodirectory'); ?>">
|
| 368 | 368 | <?php |
| 369 | 369 | $geodir_listing_delete_icon = apply_filters('geodir_listing_delete_icon', 'fas fa-times');
|
| 370 | - echo '<i class="'. $geodir_listing_delete_icon .'"></i>'; |
|
| 370 | + echo '<i class="'.$geodir_listing_delete_icon.'"></i>'; |
|
| 371 | 371 | ?> |
| 372 | 372 | <?php _e('Delete', 'geodirectory'); ?>
|
| 373 | 373 | </a> |
@@ -64,6 +64,9 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | class WP_UnitTest_Factory_For_Post extends WP_UnitTest_Factory_For_Thing { |
| 66 | 66 | |
| 67 | + /** |
|
| 68 | + * @param WP_UnitTest_Factory $factory |
|
| 69 | + */ |
|
| 67 | 70 | function __construct( $factory = null ) { |
| 68 | 71 | parent::__construct( $factory ); |
| 69 | 72 | $this->default_generation_definitions = array( |
@@ -127,6 +130,9 @@ discard block |
||
| 127 | 130 | |
| 128 | 131 | class WP_UnitTest_Factory_For_User extends WP_UnitTest_Factory_For_Thing { |
| 129 | 132 | |
| 133 | + /** |
|
| 134 | + * @param WP_UnitTest_Factory $factory |
|
| 135 | + */ |
|
| 130 | 136 | function __construct( $factory = null ) { |
| 131 | 137 | parent::__construct( $factory ); |
| 132 | 138 | $this->default_generation_definitions = array( |
@@ -152,6 +158,9 @@ discard block |
||
| 152 | 158 | |
| 153 | 159 | class WP_UnitTest_Factory_For_Comment extends WP_UnitTest_Factory_For_Thing { |
| 154 | 160 | |
| 161 | + /** |
|
| 162 | + * @param WP_UnitTest_Factory $factory |
|
| 163 | + */ |
|
| 155 | 164 | function __construct( $factory = null ) { |
| 156 | 165 | parent::__construct( $factory ); |
| 157 | 166 | $this->default_generation_definitions = array( |
@@ -183,6 +192,9 @@ discard block |
||
| 183 | 192 | |
| 184 | 193 | class WP_UnitTest_Factory_For_Blog extends WP_UnitTest_Factory_For_Thing { |
| 185 | 194 | |
| 195 | + /** |
|
| 196 | + * @param WP_UnitTest_Factory $factory |
|
| 197 | + */ |
|
| 186 | 198 | function __construct( $factory = null ) { |
| 187 | 199 | global $current_site, $base; |
| 188 | 200 | parent::__construct( $factory ); |
@@ -219,6 +231,9 @@ discard block |
||
| 219 | 231 | |
| 220 | 232 | class WP_UnitTest_Factory_For_Network extends WP_UnitTest_Factory_For_Thing { |
| 221 | 233 | |
| 234 | + /** |
|
| 235 | + * @param WP_UnitTest_Factory $factory |
|
| 236 | + */ |
|
| 222 | 237 | function __construct( $factory = null ) { |
| 223 | 238 | parent::__construct( $factory ); |
| 224 | 239 | $this->default_generation_definitions = array( |
@@ -255,6 +270,10 @@ discard block |
||
| 255 | 270 | private $taxonomy; |
| 256 | 271 | const DEFAULT_TAXONOMY = 'post_tag'; |
| 257 | 272 | |
| 273 | + /** |
|
| 274 | + * @param WP_UnitTest_Factory $factory |
|
| 275 | + * @param string $taxonomy |
|
| 276 | + */ |
|
| 258 | 277 | function __construct( $factory = null, $taxonomy = null ) { |
| 259 | 278 | parent::__construct( $factory ); |
| 260 | 279 | $this->taxonomy = $taxonomy ? $taxonomy : self::DEFAULT_TAXONOMY; |
@@ -342,6 +361,9 @@ discard block |
||
| 342 | 361 | |
| 343 | 362 | abstract function get_object_by_id( $object_id ); |
| 344 | 363 | |
| 364 | + /** |
|
| 365 | + * @param integer $count |
|
| 366 | + */ |
|
| 345 | 367 | function create_many( $count, $args = array(), $generation_definitions = null ) { |
| 346 | 368 | $results = array(); |
| 347 | 369 | for ( $i = 0; $i < $count; $i++ ) { |
@@ -405,6 +427,9 @@ discard block |
||
| 405 | 427 | public $next; |
| 406 | 428 | public $template_string; |
| 407 | 429 | |
| 430 | + /** |
|
| 431 | + * @param integer $start |
|
| 432 | + */ |
|
| 408 | 433 | function __construct( $template_string = '%s', $start = null ) { |
| 409 | 434 | if ( $start ) { |
| 410 | 435 | $this->next = $start; |
@@ -104,8 +104,9 @@ discard block |
||
| 104 | 104 | $type = $upload['type']; |
| 105 | 105 | } else { |
| 106 | 106 | $mime = wp_check_filetype( $upload['file'] ); |
| 107 | - if ($mime) |
|
| 108 | - $type = $mime['type']; |
|
| 107 | + if ($mime) { |
|
| 108 | + $type = $mime['type']; |
|
| 109 | + } |
|
| 109 | 110 | } |
| 110 | 111 | |
| 111 | 112 | $attachment = array( |
@@ -268,15 +269,17 @@ discard block |
||
| 268 | 269 | function create_object( $args ) { |
| 269 | 270 | $args = array_merge( array( 'taxonomy' => $this->taxonomy ), $args ); |
| 270 | 271 | $term_id_pair = wp_insert_term( $args['name'], $args['taxonomy'], $args ); |
| 271 | - if ( is_wp_error( $term_id_pair ) ) |
|
| 272 | - return $term_id_pair; |
|
| 272 | + if ( is_wp_error( $term_id_pair ) ) { |
|
| 273 | + return $term_id_pair; |
|
| 274 | + } |
|
| 273 | 275 | return $term_id_pair['term_id']; |
| 274 | 276 | } |
| 275 | 277 | |
| 276 | 278 | function update_object( $term, $fields ) { |
| 277 | 279 | $fields = array_merge( array( 'taxonomy' => $this->taxonomy ), $fields ); |
| 278 | - if ( is_object( $term ) ) |
|
| 279 | - $taxonomy = $term->taxonomy; |
|
| 280 | + if ( is_object( $term ) ) { |
|
| 281 | + $taxonomy = $term->taxonomy; |
|
| 282 | + } |
|
| 280 | 283 | $term_id_pair = wp_update_term( $term, $taxonomy, $fields ); |
| 281 | 284 | return $term_id_pair['term_id']; |
| 282 | 285 | } |
@@ -318,19 +321,22 @@ discard block |
||
| 318 | 321 | abstract function update_object( $object, $fields ); |
| 319 | 322 | |
| 320 | 323 | function create( $args = array(), $generation_definitions = null ) { |
| 321 | - if ( is_null( $generation_definitions ) ) |
|
| 322 | - $generation_definitions = $this->default_generation_definitions; |
|
| 324 | + if ( is_null( $generation_definitions ) ) { |
|
| 325 | + $generation_definitions = $this->default_generation_definitions; |
|
| 326 | + } |
|
| 323 | 327 | |
| 324 | 328 | $generated_args = $this->generate_args( $args, $generation_definitions, $callbacks ); |
| 325 | 329 | $created = $this->create_object( $generated_args ); |
| 326 | - if ( !$created || is_wp_error( $created ) ) |
|
| 327 | - return $created; |
|
| 330 | + if ( !$created || is_wp_error( $created ) ) { |
|
| 331 | + return $created; |
|
| 332 | + } |
|
| 328 | 333 | |
| 329 | 334 | if ( $callbacks ) { |
| 330 | 335 | $updated_fields = $this->apply_callbacks( $callbacks, $created ); |
| 331 | 336 | $save_result = $this->update_object( $created, $updated_fields ); |
| 332 | - if ( !$save_result || is_wp_error( $save_result ) ) |
|
| 333 | - return $save_result; |
|
| 337 | + if ( !$save_result || is_wp_error( $save_result ) ) { |
|
| 338 | + return $save_result; |
|
| 339 | + } |
|
| 334 | 340 | } |
| 335 | 341 | return $created; |
| 336 | 342 | } |
@@ -352,20 +358,22 @@ discard block |
||
| 352 | 358 | |
| 353 | 359 | function generate_args( $args = array(), $generation_definitions = null, &$callbacks = null ) { |
| 354 | 360 | $callbacks = array(); |
| 355 | - if ( is_null( $generation_definitions ) ) |
|
| 356 | - $generation_definitions = $this->default_generation_definitions; |
|
| 361 | + if ( is_null( $generation_definitions ) ) { |
|
| 362 | + $generation_definitions = $this->default_generation_definitions; |
|
| 363 | + } |
|
| 357 | 364 | |
| 358 | 365 | foreach( array_keys( $generation_definitions ) as $field_name ) { |
| 359 | 366 | if ( !isset( $args[$field_name] ) ) { |
| 360 | 367 | $generator = $generation_definitions[$field_name]; |
| 361 | - if ( is_scalar( $generator ) ) |
|
| 362 | - $args[$field_name] = $generator; |
|
| 363 | - elseif ( is_object( $generator ) && method_exists( $generator, 'call' ) ) { |
|
| 368 | + if ( is_scalar( $generator ) ) { |
|
| 369 | + $args[$field_name] = $generator; |
|
| 370 | + } elseif ( is_object( $generator ) && method_exists( $generator, 'call' ) ) { |
|
| 364 | 371 | $callbacks[$field_name] = $generator; |
| 365 | - } elseif ( is_object( $generator ) ) |
|
| 366 | - $args[$field_name] = $generator->next(); |
|
| 367 | - else |
|
| 368 | - return new WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' ); |
|
| 372 | + } elseif ( is_object( $generator ) ) { |
|
| 373 | + $args[$field_name] = $generator->next(); |
|
| 374 | + } else { |
|
| 375 | + return new WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' ); |
|
| 376 | + } |
|
| 369 | 377 | } |
| 370 | 378 | } |
| 371 | 379 | return $args; |
@@ -48,78 +48,78 @@ discard block |
||
| 48 | 48 | public $network; |
| 49 | 49 | |
| 50 | 50 | function __construct() { |
| 51 | - $this->post = new WP_UnitTest_Factory_For_Post( $this ); |
|
| 52 | - $this->attachment = new WP_UnitTest_Factory_For_Attachment( $this ); |
|
| 53 | - $this->comment = new WP_UnitTest_Factory_For_Comment( $this ); |
|
| 54 | - $this->user = new WP_UnitTest_Factory_For_User( $this ); |
|
| 55 | - $this->term = new WP_UnitTest_Factory_For_Term( $this ); |
|
| 56 | - $this->category = new WP_UnitTest_Factory_For_Term( $this, 'category' ); |
|
| 57 | - $this->tag = new WP_UnitTest_Factory_For_Term( $this, 'post_tag' ); |
|
| 58 | - if ( is_multisite() ) { |
|
| 59 | - $this->blog = new WP_UnitTest_Factory_For_Blog( $this ); |
|
| 60 | - $this->network = new WP_UnitTest_Factory_For_Network( $this ); |
|
| 51 | + $this->post = new WP_UnitTest_Factory_For_Post($this); |
|
| 52 | + $this->attachment = new WP_UnitTest_Factory_For_Attachment($this); |
|
| 53 | + $this->comment = new WP_UnitTest_Factory_For_Comment($this); |
|
| 54 | + $this->user = new WP_UnitTest_Factory_For_User($this); |
|
| 55 | + $this->term = new WP_UnitTest_Factory_For_Term($this); |
|
| 56 | + $this->category = new WP_UnitTest_Factory_For_Term($this, 'category'); |
|
| 57 | + $this->tag = new WP_UnitTest_Factory_For_Term($this, 'post_tag'); |
|
| 58 | + if (is_multisite()) { |
|
| 59 | + $this->blog = new WP_UnitTest_Factory_For_Blog($this); |
|
| 60 | + $this->network = new WP_UnitTest_Factory_For_Network($this); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | class WP_UnitTest_Factory_For_Post extends WP_UnitTest_Factory_For_Thing { |
| 66 | 66 | |
| 67 | - function __construct( $factory = null ) { |
|
| 68 | - parent::__construct( $factory ); |
|
| 67 | + function __construct($factory = null) { |
|
| 68 | + parent::__construct($factory); |
|
| 69 | 69 | $this->default_generation_definitions = array( |
| 70 | 70 | 'post_status' => 'publish', |
| 71 | - 'post_title' => new WP_UnitTest_Generator_Sequence( 'Post title %s' ), |
|
| 72 | - 'post_content' => new WP_UnitTest_Generator_Sequence( 'Post content %s' ), |
|
| 73 | - 'post_excerpt' => new WP_UnitTest_Generator_Sequence( 'Post excerpt %s' ), |
|
| 71 | + 'post_title' => new WP_UnitTest_Generator_Sequence('Post title %s'), |
|
| 72 | + 'post_content' => new WP_UnitTest_Generator_Sequence('Post content %s'), |
|
| 73 | + 'post_excerpt' => new WP_UnitTest_Generator_Sequence('Post excerpt %s'), |
|
| 74 | 74 | 'post_type' => 'post' |
| 75 | 75 | ); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - function create_object( $args ) { |
|
| 79 | - return wp_insert_post( $args ); |
|
| 78 | + function create_object($args) { |
|
| 79 | + return wp_insert_post($args); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - function update_object( $post_id, $fields ) { |
|
| 82 | + function update_object($post_id, $fields) { |
|
| 83 | 83 | $fields['ID'] = $post_id; |
| 84 | - return wp_update_post( $fields ); |
|
| 84 | + return wp_update_post($fields); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - function get_object_by_id( $post_id ) { |
|
| 88 | - return get_post( $post_id ); |
|
| 87 | + function get_object_by_id($post_id) { |
|
| 88 | + return get_post($post_id); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | class WP_UnitTest_Factory_For_Attachment extends WP_UnitTest_Factory_For_Post { |
| 93 | 93 | |
| 94 | - function create_object( $file, $parent = 0, $args = array() ) { |
|
| 95 | - return wp_insert_attachment( $args, $file, $parent ); |
|
| 94 | + function create_object($file, $parent = 0, $args = array()) { |
|
| 95 | + return wp_insert_attachment($args, $file, $parent); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - function create_upload_object( $file, $parent = 0 ) { |
|
| 98 | + function create_upload_object($file, $parent = 0) { |
|
| 99 | 99 | $contents = file_get_contents($file); |
| 100 | 100 | $upload = wp_upload_bits(basename($file), null, $contents); |
| 101 | 101 | |
| 102 | 102 | $type = ''; |
| 103 | - if ( ! empty($upload['type']) ) { |
|
| 103 | + if (!empty($upload['type'])) { |
|
| 104 | 104 | $type = $upload['type']; |
| 105 | 105 | } else { |
| 106 | - $mime = wp_check_filetype( $upload['file'] ); |
|
| 106 | + $mime = wp_check_filetype($upload['file']); |
|
| 107 | 107 | if ($mime) |
| 108 | 108 | $type = $mime['type']; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | $attachment = array( |
| 112 | - 'post_title' => basename( $upload['file'] ), |
|
| 112 | + 'post_title' => basename($upload['file']), |
|
| 113 | 113 | 'post_content' => '', |
| 114 | 114 | 'post_type' => 'attachment', |
| 115 | 115 | 'post_parent' => $parent, |
| 116 | 116 | 'post_mime_type' => $type, |
| 117 | - 'guid' => $upload[ 'url' ], |
|
| 117 | + 'guid' => $upload['url'], |
|
| 118 | 118 | ); |
| 119 | 119 | |
| 120 | 120 | // Save the data |
| 121 | - $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent ); |
|
| 122 | - wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); |
|
| 121 | + $id = wp_insert_attachment($attachment, $upload['file'], $parent); |
|
| 122 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $upload['file'])); |
|
| 123 | 123 | |
| 124 | 124 | return $id; |
| 125 | 125 | } |
@@ -127,126 +127,126 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | class WP_UnitTest_Factory_For_User extends WP_UnitTest_Factory_For_Thing { |
| 129 | 129 | |
| 130 | - function __construct( $factory = null ) { |
|
| 131 | - parent::__construct( $factory ); |
|
| 130 | + function __construct($factory = null) { |
|
| 131 | + parent::__construct($factory); |
|
| 132 | 132 | $this->default_generation_definitions = array( |
| 133 | - 'user_login' => new WP_UnitTest_Generator_Sequence( 'User %s' ), |
|
| 133 | + 'user_login' => new WP_UnitTest_Generator_Sequence('User %s'), |
|
| 134 | 134 | 'user_pass' => 'password', |
| 135 | - 'user_email' => new WP_UnitTest_Generator_Sequence( 'user_%[email protected]' ), |
|
| 135 | + 'user_email' => new WP_UnitTest_Generator_Sequence('user_%[email protected]'), |
|
| 136 | 136 | ); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - function create_object( $args ) { |
|
| 140 | - return wp_insert_user( $args ); |
|
| 139 | + function create_object($args) { |
|
| 140 | + return wp_insert_user($args); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - function update_object( $user_id, $fields ) { |
|
| 143 | + function update_object($user_id, $fields) { |
|
| 144 | 144 | $fields['ID'] = $user_id; |
| 145 | - return wp_update_user( $fields ); |
|
| 145 | + return wp_update_user($fields); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - function get_object_by_id( $user_id ) { |
|
| 149 | - return new WP_User( $user_id ); |
|
| 148 | + function get_object_by_id($user_id) { |
|
| 149 | + return new WP_User($user_id); |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | class WP_UnitTest_Factory_For_Comment extends WP_UnitTest_Factory_For_Thing { |
| 154 | 154 | |
| 155 | - function __construct( $factory = null ) { |
|
| 156 | - parent::__construct( $factory ); |
|
| 155 | + function __construct($factory = null) { |
|
| 156 | + parent::__construct($factory); |
|
| 157 | 157 | $this->default_generation_definitions = array( |
| 158 | - 'comment_author' => new WP_UnitTest_Generator_Sequence( 'Commenter %s' ), |
|
| 159 | - 'comment_author_url' => new WP_UnitTest_Generator_Sequence( 'http://example.com/%s/' ), |
|
| 158 | + 'comment_author' => new WP_UnitTest_Generator_Sequence('Commenter %s'), |
|
| 159 | + 'comment_author_url' => new WP_UnitTest_Generator_Sequence('http://example.com/%s/'), |
|
| 160 | 160 | 'comment_approved' => 1, |
| 161 | 161 | 'comment_content' => 'This is a comment' |
| 162 | 162 | ); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - function create_object( $args ) { |
|
| 166 | - return wp_insert_comment( $this->addslashes_deep( $args ) ); |
|
| 165 | + function create_object($args) { |
|
| 166 | + return wp_insert_comment($this->addslashes_deep($args)); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - function update_object( $comment_id, $fields ) { |
|
| 169 | + function update_object($comment_id, $fields) { |
|
| 170 | 170 | $fields['comment_ID'] = $comment_id; |
| 171 | - return wp_update_comment( $this->addslashes_deep( $fields ) ); |
|
| 171 | + return wp_update_comment($this->addslashes_deep($fields)); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - function create_post_comments( $post_id, $count = 1, $args = array(), $generation_definitions = null ) { |
|
| 174 | + function create_post_comments($post_id, $count = 1, $args = array(), $generation_definitions = null) { |
|
| 175 | 175 | $args['comment_post_ID'] = $post_id; |
| 176 | - return $this->create_many( $count, $args, $generation_definitions ); |
|
| 176 | + return $this->create_many($count, $args, $generation_definitions); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - function get_object_by_id( $comment_id ) { |
|
| 180 | - return get_comment( $comment_id ); |
|
| 179 | + function get_object_by_id($comment_id) { |
|
| 180 | + return get_comment($comment_id); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | class WP_UnitTest_Factory_For_Blog extends WP_UnitTest_Factory_For_Thing { |
| 185 | 185 | |
| 186 | - function __construct( $factory = null ) { |
|
| 186 | + function __construct($factory = null) { |
|
| 187 | 187 | global $current_site, $base; |
| 188 | - parent::__construct( $factory ); |
|
| 188 | + parent::__construct($factory); |
|
| 189 | 189 | $this->default_generation_definitions = array( |
| 190 | 190 | 'domain' => $current_site->domain, |
| 191 | - 'path' => new WP_UnitTest_Generator_Sequence( $base . 'testpath%s' ), |
|
| 192 | - 'title' => new WP_UnitTest_Generator_Sequence( 'Site %s' ), |
|
| 191 | + 'path' => new WP_UnitTest_Generator_Sequence($base.'testpath%s'), |
|
| 192 | + 'title' => new WP_UnitTest_Generator_Sequence('Site %s'), |
|
| 193 | 193 | 'site_id' => $current_site->id, |
| 194 | 194 | ); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - function create_object( $args ) { |
|
| 197 | + function create_object($args) { |
|
| 198 | 198 | global $wpdb; |
| 199 | - $meta = isset( $args['meta'] ) ? $args['meta'] : array(); |
|
| 200 | - $user_id = isset( $args['user_id'] ) ? $args['user_id'] : get_current_user_id(); |
|
| 199 | + $meta = isset($args['meta']) ? $args['meta'] : array(); |
|
| 200 | + $user_id = isset($args['user_id']) ? $args['user_id'] : get_current_user_id(); |
|
| 201 | 201 | // temp tables will trigger db errors when we attempt to reference them as new temp tables |
| 202 | 202 | $suppress = $wpdb->suppress_errors(); |
| 203 | - $blog = wpmu_create_blog( $args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id'] ); |
|
| 204 | - $wpdb->suppress_errors( $suppress ); |
|
| 203 | + $blog = wpmu_create_blog($args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id']); |
|
| 204 | + $wpdb->suppress_errors($suppress); |
|
| 205 | 205 | |
| 206 | 206 | // Tell WP we're done installing. |
| 207 | - wp_installing( false ); |
|
| 207 | + wp_installing(false); |
|
| 208 | 208 | |
| 209 | 209 | return $blog; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - function update_object( $blog_id, $fields ) {} |
|
| 212 | + function update_object($blog_id, $fields) {} |
|
| 213 | 213 | |
| 214 | - function get_object_by_id( $blog_id ) { |
|
| 215 | - return get_blog_details( $blog_id, false ); |
|
| 214 | + function get_object_by_id($blog_id) { |
|
| 215 | + return get_blog_details($blog_id, false); |
|
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | |
| 220 | 220 | class WP_UnitTest_Factory_For_Network extends WP_UnitTest_Factory_For_Thing { |
| 221 | 221 | |
| 222 | - function __construct( $factory = null ) { |
|
| 223 | - parent::__construct( $factory ); |
|
| 222 | + function __construct($factory = null) { |
|
| 223 | + parent::__construct($factory); |
|
| 224 | 224 | $this->default_generation_definitions = array( |
| 225 | 225 | 'domain' => WP_TESTS_DOMAIN, |
| 226 | - 'title' => new WP_UnitTest_Generator_Sequence( 'Network %s' ), |
|
| 227 | - 'path' => new WP_UnitTest_Generator_Sequence( '/testpath%s/' ), |
|
| 228 | - 'network_id' => new WP_UnitTest_Generator_Sequence( '%s', 2 ), |
|
| 226 | + 'title' => new WP_UnitTest_Generator_Sequence('Network %s'), |
|
| 227 | + 'path' => new WP_UnitTest_Generator_Sequence('/testpath%s/'), |
|
| 228 | + 'network_id' => new WP_UnitTest_Generator_Sequence('%s', 2), |
|
| 229 | 229 | 'subdomain_install' => false, |
| 230 | 230 | ); |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - function create_object( $args ) { |
|
| 234 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
|
| 233 | + function create_object($args) { |
|
| 234 | + require_once ABSPATH.'wp-admin/includes/upgrade.php'; |
|
| 235 | 235 | |
| 236 | - if ( ! isset( $args['user'] ) ) { |
|
| 236 | + if (!isset($args['user'])) { |
|
| 237 | 237 | $email = WP_TESTS_EMAIL; |
| 238 | 238 | } else { |
| 239 | - $email = get_userdata( $args['user'] )->user_email; |
|
| 239 | + $email = get_userdata($args['user'])->user_email; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - populate_network( $args['network_id'], $args['domain'], $email, $args['title'], $args['path'], $args['subdomain_install'] ); |
|
| 242 | + populate_network($args['network_id'], $args['domain'], $email, $args['title'], $args['path'], $args['subdomain_install']); |
|
| 243 | 243 | return $args['network_id']; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - function update_object( $network_id, $fields ) {} |
|
| 246 | + function update_object($network_id, $fields) {} |
|
| 247 | 247 | |
| 248 | - function get_object_by_id( $network_id ) { |
|
| 249 | - return wp_get_network( $network_id ); |
|
| 248 | + function get_object_by_id($network_id) { |
|
| 249 | + return wp_get_network($network_id); |
|
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | |
@@ -255,44 +255,44 @@ discard block |
||
| 255 | 255 | private $taxonomy; |
| 256 | 256 | const DEFAULT_TAXONOMY = 'post_tag'; |
| 257 | 257 | |
| 258 | - function __construct( $factory = null, $taxonomy = null ) { |
|
| 259 | - parent::__construct( $factory ); |
|
| 258 | + function __construct($factory = null, $taxonomy = null) { |
|
| 259 | + parent::__construct($factory); |
|
| 260 | 260 | $this->taxonomy = $taxonomy ? $taxonomy : self::DEFAULT_TAXONOMY; |
| 261 | 261 | $this->default_generation_definitions = array( |
| 262 | - 'name' => new WP_UnitTest_Generator_Sequence( 'Term %s' ), |
|
| 262 | + 'name' => new WP_UnitTest_Generator_Sequence('Term %s'), |
|
| 263 | 263 | 'taxonomy' => $this->taxonomy, |
| 264 | - 'description' => new WP_UnitTest_Generator_Sequence( 'Term description %s' ), |
|
| 264 | + 'description' => new WP_UnitTest_Generator_Sequence('Term description %s'), |
|
| 265 | 265 | ); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - function create_object( $args ) { |
|
| 269 | - $args = array_merge( array( 'taxonomy' => $this->taxonomy ), $args ); |
|
| 270 | - $term_id_pair = wp_insert_term( $args['name'], $args['taxonomy'], $args ); |
|
| 271 | - if ( is_wp_error( $term_id_pair ) ) |
|
| 268 | + function create_object($args) { |
|
| 269 | + $args = array_merge(array('taxonomy' => $this->taxonomy), $args); |
|
| 270 | + $term_id_pair = wp_insert_term($args['name'], $args['taxonomy'], $args); |
|
| 271 | + if (is_wp_error($term_id_pair)) |
|
| 272 | 272 | return $term_id_pair; |
| 273 | 273 | return $term_id_pair['term_id']; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - function update_object( $term, $fields ) { |
|
| 277 | - $fields = array_merge( array( 'taxonomy' => $this->taxonomy ), $fields ); |
|
| 278 | - if ( is_object( $term ) ) |
|
| 276 | + function update_object($term, $fields) { |
|
| 277 | + $fields = array_merge(array('taxonomy' => $this->taxonomy), $fields); |
|
| 278 | + if (is_object($term)) |
|
| 279 | 279 | $taxonomy = $term->taxonomy; |
| 280 | - $term_id_pair = wp_update_term( $term, $taxonomy, $fields ); |
|
| 280 | + $term_id_pair = wp_update_term($term, $taxonomy, $fields); |
|
| 281 | 281 | return $term_id_pair['term_id']; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - function add_post_terms( $post_id, $terms, $taxonomy, $append = true ) { |
|
| 285 | - return wp_set_post_terms( $post_id, $terms, $taxonomy, $append ); |
|
| 284 | + function add_post_terms($post_id, $terms, $taxonomy, $append = true) { |
|
| 285 | + return wp_set_post_terms($post_id, $terms, $taxonomy, $append); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - function create_and_get( $args = array(), $generation_definitions = null ) { |
|
| 289 | - $term_id = $this->create( $args, $generation_definitions ); |
|
| 290 | - $taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy; |
|
| 291 | - return get_term( $term_id, $taxonomy ); |
|
| 288 | + function create_and_get($args = array(), $generation_definitions = null) { |
|
| 289 | + $term_id = $this->create($args, $generation_definitions); |
|
| 290 | + $taxonomy = isset($args['taxonomy']) ? $args['taxonomy'] : $this->taxonomy; |
|
| 291 | + return get_term($term_id, $taxonomy); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - function get_object_by_id( $term_id ) { |
|
| 295 | - return get_term( $term_id, $this->taxonomy ); |
|
| 294 | + function get_object_by_id($term_id) { |
|
| 295 | + return get_term($term_id, $this->taxonomy); |
|
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | |
@@ -309,90 +309,90 @@ discard block |
||
| 309 | 309 | * can be generators -- an object with next() method. There are some default generators: {@link WP_UnitTest_Generator_Sequence}, |
| 310 | 310 | * {@link WP_UnitTest_Generator_Locale_Name}, {@link WP_UnitTest_Factory_Callback_After_Create}. |
| 311 | 311 | */ |
| 312 | - function __construct( $factory, $default_generation_definitions = array() ) { |
|
| 312 | + function __construct($factory, $default_generation_definitions = array()) { |
|
| 313 | 313 | $this->factory = $factory; |
| 314 | 314 | $this->default_generation_definitions = $default_generation_definitions; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - abstract function create_object( $args ); |
|
| 318 | - abstract function update_object( $object, $fields ); |
|
| 317 | + abstract function create_object($args); |
|
| 318 | + abstract function update_object($object, $fields); |
|
| 319 | 319 | |
| 320 | - function create( $args = array(), $generation_definitions = null ) { |
|
| 321 | - if ( is_null( $generation_definitions ) ) |
|
| 320 | + function create($args = array(), $generation_definitions = null) { |
|
| 321 | + if (is_null($generation_definitions)) |
|
| 322 | 322 | $generation_definitions = $this->default_generation_definitions; |
| 323 | 323 | |
| 324 | - $generated_args = $this->generate_args( $args, $generation_definitions, $callbacks ); |
|
| 325 | - $created = $this->create_object( $generated_args ); |
|
| 326 | - if ( !$created || is_wp_error( $created ) ) |
|
| 324 | + $generated_args = $this->generate_args($args, $generation_definitions, $callbacks); |
|
| 325 | + $created = $this->create_object($generated_args); |
|
| 326 | + if (!$created || is_wp_error($created)) |
|
| 327 | 327 | return $created; |
| 328 | 328 | |
| 329 | - if ( $callbacks ) { |
|
| 330 | - $updated_fields = $this->apply_callbacks( $callbacks, $created ); |
|
| 331 | - $save_result = $this->update_object( $created, $updated_fields ); |
|
| 332 | - if ( !$save_result || is_wp_error( $save_result ) ) |
|
| 329 | + if ($callbacks) { |
|
| 330 | + $updated_fields = $this->apply_callbacks($callbacks, $created); |
|
| 331 | + $save_result = $this->update_object($created, $updated_fields); |
|
| 332 | + if (!$save_result || is_wp_error($save_result)) |
|
| 333 | 333 | return $save_result; |
| 334 | 334 | } |
| 335 | 335 | return $created; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - function create_and_get( $args = array(), $generation_definitions = null ) { |
|
| 339 | - $object_id = $this->create( $args, $generation_definitions ); |
|
| 340 | - return $this->get_object_by_id( $object_id ); |
|
| 338 | + function create_and_get($args = array(), $generation_definitions = null) { |
|
| 339 | + $object_id = $this->create($args, $generation_definitions); |
|
| 340 | + return $this->get_object_by_id($object_id); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - abstract function get_object_by_id( $object_id ); |
|
| 343 | + abstract function get_object_by_id($object_id); |
|
| 344 | 344 | |
| 345 | - function create_many( $count, $args = array(), $generation_definitions = null ) { |
|
| 345 | + function create_many($count, $args = array(), $generation_definitions = null) { |
|
| 346 | 346 | $results = array(); |
| 347 | - for ( $i = 0; $i < $count; $i++ ) { |
|
| 348 | - $results[] = $this->create( $args, $generation_definitions ); |
|
| 347 | + for ($i = 0; $i < $count; $i++) { |
|
| 348 | + $results[] = $this->create($args, $generation_definitions); |
|
| 349 | 349 | } |
| 350 | 350 | return $results; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - function generate_args( $args = array(), $generation_definitions = null, &$callbacks = null ) { |
|
| 353 | + function generate_args($args = array(), $generation_definitions = null, &$callbacks = null) { |
|
| 354 | 354 | $callbacks = array(); |
| 355 | - if ( is_null( $generation_definitions ) ) |
|
| 355 | + if (is_null($generation_definitions)) |
|
| 356 | 356 | $generation_definitions = $this->default_generation_definitions; |
| 357 | 357 | |
| 358 | - foreach( array_keys( $generation_definitions ) as $field_name ) { |
|
| 359 | - if ( !isset( $args[$field_name] ) ) { |
|
| 358 | + foreach (array_keys($generation_definitions) as $field_name) { |
|
| 359 | + if (!isset($args[$field_name])) { |
|
| 360 | 360 | $generator = $generation_definitions[$field_name]; |
| 361 | - if ( is_scalar( $generator ) ) |
|
| 361 | + if (is_scalar($generator)) |
|
| 362 | 362 | $args[$field_name] = $generator; |
| 363 | - elseif ( is_object( $generator ) && method_exists( $generator, 'call' ) ) { |
|
| 363 | + elseif (is_object($generator) && method_exists($generator, 'call')) { |
|
| 364 | 364 | $callbacks[$field_name] = $generator; |
| 365 | - } elseif ( is_object( $generator ) ) |
|
| 365 | + } elseif (is_object($generator)) |
|
| 366 | 366 | $args[$field_name] = $generator->next(); |
| 367 | 367 | else |
| 368 | - return new WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' ); |
|
| 368 | + return new WP_Error('invalid_argument', 'Factory default value should be either a scalar or an generator object.'); |
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | return $args; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - function apply_callbacks( $callbacks, $created ) { |
|
| 374 | + function apply_callbacks($callbacks, $created) { |
|
| 375 | 375 | $updated_fields = array(); |
| 376 | - foreach( $callbacks as $field_name => $generator ) { |
|
| 377 | - $updated_fields[$field_name] = $generator->call( $created ); |
|
| 376 | + foreach ($callbacks as $field_name => $generator) { |
|
| 377 | + $updated_fields[$field_name] = $generator->call($created); |
|
| 378 | 378 | } |
| 379 | 379 | return $updated_fields; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - function callback( $function ) { |
|
| 383 | - return new WP_UnitTest_Factory_Callback_After_Create( $function ); |
|
| 382 | + function callback($function) { |
|
| 383 | + return new WP_UnitTest_Factory_Callback_After_Create($function); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | function addslashes_deep($value) { |
| 387 | - if ( is_array( $value ) ) { |
|
| 388 | - $value = array_map( array( $this, 'addslashes_deep' ), $value ); |
|
| 389 | - } elseif ( is_object( $value ) ) { |
|
| 390 | - $vars = get_object_vars( $value ); |
|
| 387 | + if (is_array($value)) { |
|
| 388 | + $value = array_map(array($this, 'addslashes_deep'), $value); |
|
| 389 | + } elseif (is_object($value)) { |
|
| 390 | + $vars = get_object_vars($value); |
|
| 391 | 391 | foreach ($vars as $key=>$data) { |
| 392 | - $value->{$key} = $this->addslashes_deep( $data ); |
|
| 392 | + $value->{$key} = $this->addslashes_deep($data); |
|
| 393 | 393 | } |
| 394 | - } elseif ( is_string( $value ) ) { |
|
| 395 | - $value = addslashes( $value ); |
|
| 394 | + } elseif (is_string($value)) { |
|
| 395 | + $value = addslashes($value); |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | return $value; |
@@ -405,8 +405,8 @@ discard block |
||
| 405 | 405 | public $next; |
| 406 | 406 | public $template_string; |
| 407 | 407 | |
| 408 | - function __construct( $template_string = '%s', $start = null ) { |
|
| 409 | - if ( $start ) { |
|
| 408 | + function __construct($template_string = '%s', $start = null) { |
|
| 409 | + if ($start) { |
|
| 410 | 410 | $this->next = $start; |
| 411 | 411 | } else { |
| 412 | 412 | self::$incr++; |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | function next() { |
| 419 | - $generated = sprintf( $this->template_string , $this->next ); |
|
| 419 | + $generated = sprintf($this->template_string, $this->next); |
|
| 420 | 420 | $this->next++; |
| 421 | 421 | return $generated; |
| 422 | 422 | } |
@@ -425,11 +425,11 @@ discard block |
||
| 425 | 425 | class WP_UnitTest_Factory_Callback_After_Create { |
| 426 | 426 | var $callback; |
| 427 | 427 | |
| 428 | - function __construct( $callback ) { |
|
| 428 | + function __construct($callback) { |
|
| 429 | 429 | $this->callback = $callback; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - function call( $object ) { |
|
| 433 | - return call_user_func( $this->callback, $object ); |
|
| 432 | + function call($object) { |
|
| 433 | + return call_user_func($this->callback, $object); |
|
| 434 | 434 | } |
| 435 | 435 | } |
@@ -10,6 +10,9 @@ discard block |
||
| 10 | 10 | return true; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | +/** |
|
| 14 | + * @param integer $priority |
|
| 15 | + */ |
|
| 13 | 16 | function _test_filter_build_unique_id($tag, $function, $priority) { |
| 14 | 17 | global $wp_filter; |
| 15 | 18 | static $filter_id_count = 0; |
@@ -92,6 +95,9 @@ discard block |
||
| 92 | 95 | return '_wp_die_handler'; |
| 93 | 96 | } |
| 94 | 97 | |
| 98 | +/** |
|
| 99 | + * @param string $title |
|
| 100 | + */ |
|
| 95 | 101 | function _wp_die_handler_txt( $message, $title, $args ) { |
| 96 | 102 | echo "\nwp_die called\n"; |
| 97 | 103 | echo "Message : $message\n"; |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | global $wp_filter; |
| 15 | 15 | static $filter_id_count = 0; |
| 16 | 16 | |
| 17 | - if ( is_string($function) ) |
|
| 18 | - return $function; |
|
| 17 | + if ( is_string($function) ) { |
|
| 18 | + return $function; |
|
| 19 | + } |
|
| 19 | 20 | |
| 20 | 21 | if ( is_object($function) ) { |
| 21 | 22 | // Closures are currently implemented as objects |
@@ -37,8 +38,9 @@ discard block |
||
| 37 | 38 | |
| 38 | 39 | $all_posts = $wpdb->get_col("SELECT ID from {$wpdb->posts}"); |
| 39 | 40 | if ($all_posts) { |
| 40 | - foreach ($all_posts as $id) |
|
| 41 | - wp_delete_post( $id, true ); |
|
| 41 | + foreach ($all_posts as $id) { |
|
| 42 | + wp_delete_post( $id, true ); |
|
| 43 | + } |
|
| 42 | 44 | } |
| 43 | 45 | } |
| 44 | 46 | |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | $idx = _test_filter_build_unique_id($tag, $function_to_add, $priority); |
| 8 | 8 | $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); |
| 9 | - unset( $merged_filters[ $tag ] ); |
|
| 9 | + unset($merged_filters[$tag]); |
|
| 10 | 10 | return true; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -14,19 +14,19 @@ discard block |
||
| 14 | 14 | global $wp_filter; |
| 15 | 15 | static $filter_id_count = 0; |
| 16 | 16 | |
| 17 | - if ( is_string($function) ) |
|
| 17 | + if (is_string($function)) |
|
| 18 | 18 | return $function; |
| 19 | 19 | |
| 20 | - if ( is_object($function) ) { |
|
| 20 | + if (is_object($function)) { |
|
| 21 | 21 | // Closures are currently implemented as objects |
| 22 | - $function = array( $function, '' ); |
|
| 22 | + $function = array($function, ''); |
|
| 23 | 23 | } else { |
| 24 | 24 | $function = (array) $function; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if (is_object($function[0]) ) { |
|
| 28 | - return spl_object_hash($function[0]) . $function[1]; |
|
| 29 | - } else if ( is_string($function[0]) ) { |
|
| 27 | + if (is_object($function[0])) { |
|
| 28 | + return spl_object_hash($function[0]).$function[1]; |
|
| 29 | + } else if (is_string($function[0])) { |
|
| 30 | 30 | // Static Calling |
| 31 | 31 | return $function[0].$function[1]; |
| 32 | 32 | } |
@@ -38,31 +38,31 @@ discard block |
||
| 38 | 38 | $all_posts = $wpdb->get_col("SELECT ID from {$wpdb->posts}"); |
| 39 | 39 | if ($all_posts) { |
| 40 | 40 | foreach ($all_posts as $id) |
| 41 | - wp_delete_post( $id, true ); |
|
| 41 | + wp_delete_post($id, true); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | class Basic_Object { |
| 46 | 46 | private $foo = 'bar'; |
| 47 | 47 | |
| 48 | - public function __get( $name ) { |
|
| 48 | + public function __get($name) { |
|
| 49 | 49 | return $this->{$name}; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function __set( $name, $value ) { |
|
| 52 | + public function __set($name, $value) { |
|
| 53 | 53 | return $this->{$name} = $value; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public function __isset( $name ) { |
|
| 57 | - return isset( $this->{$name} ); |
|
| 56 | + public function __isset($name) { |
|
| 57 | + return isset($this->{$name} ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function __unset( $name ) { |
|
| 61 | - unset( $this->{$name} ); |
|
| 60 | + public function __unset($name) { |
|
| 61 | + unset($this->{$name} ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public function __call( $name, $arguments ) { |
|
| 65 | - return call_user_func_array( array( $this, $name ), $arguments ); |
|
| 64 | + public function __call($name, $arguments) { |
|
| 65 | + return call_user_func_array(array($this, $name), $arguments); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | private function callMe() { |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | class Basic_Subclass extends Basic_Object {} |
| 74 | 74 | |
| 75 | -function _wp_die_handler( $message, $title = '', $args = array() ) { |
|
| 76 | - if ( !$GLOBALS['_wp_die_disabled'] ) { |
|
| 77 | - _wp_die_handler_txt( $message, $title, $args); |
|
| 75 | +function _wp_die_handler($message, $title = '', $args = array()) { |
|
| 76 | + if (!$GLOBALS['_wp_die_disabled']) { |
|
| 77 | + _wp_die_handler_txt($message, $title, $args); |
|
| 78 | 78 | } else { |
| 79 | 79 | //Ignore at our peril |
| 80 | 80 | } |
@@ -92,13 +92,13 @@ discard block |
||
| 92 | 92 | return '_wp_die_handler'; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | -function _wp_die_handler_txt( $message, $title, $args ) { |
|
| 95 | +function _wp_die_handler_txt($message, $title, $args) { |
|
| 96 | 96 | echo "\nwp_die called\n"; |
| 97 | 97 | echo "Message : $message\n"; |
| 98 | 98 | echo "Title : $title\n"; |
| 99 | - if ( ! empty( $args ) ) { |
|
| 99 | + if (!empty($args)) { |
|
| 100 | 100 | echo "Args: \n"; |
| 101 | - foreach( $args as $k => $v ){ |
|
| 101 | + foreach ($args as $k => $v) { |
|
| 102 | 102 | echo "\t $k : $v\n"; |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -113,5 +113,5 @@ discard block |
||
| 113 | 113 | * @since 4.2.0 |
| 114 | 114 | */ |
| 115 | 115 | function _set_default_permalink_structure_for_tests() { |
| 116 | - update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' ); |
|
| 116 | + update_option('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/'); |
|
| 117 | 117 | } |
@@ -49,6 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * "Bulk Loads" a filesystem into the internal virtual filesystem |
| 52 | + * @param string $paths |
|
| 52 | 53 | */ |
| 53 | 54 | function setfs( $paths ) { |
| 54 | 55 | if ( ! is_array($paths) ) |
@@ -144,6 +145,9 @@ discard block |
||
| 144 | 145 | return isset( $this->fs_map[ $file ] ) && $this->fs_map[ $file ]->is_file(); |
| 145 | 146 | } |
| 146 | 147 | |
| 148 | + /** |
|
| 149 | + * @param string $path |
|
| 150 | + */ |
|
| 147 | 151 | function is_dir( $path ) { |
| 148 | 152 | $path = trailingslashit( $path ); |
| 149 | 153 | |
@@ -21,13 +21,15 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | // Copy of core's function, but accepts a path. |
| 23 | 23 | function abspath( $path = false ) { |
| 24 | - if ( ! $path ) |
|
| 25 | - $path = ABSPATH; |
|
| 24 | + if ( ! $path ) { |
|
| 25 | + $path = ABSPATH; |
|
| 26 | + } |
|
| 26 | 27 | $folder = $this->find_folder( $path ); |
| 27 | 28 | |
| 28 | 29 | // Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare. |
| 29 | - if ( ! $folder && $this->is_dir('/wp-includes') ) |
|
| 30 | - $folder = '/'; |
|
| 30 | + if ( ! $folder && $this->is_dir('/wp-includes') ) { |
|
| 31 | + $folder = '/'; |
|
| 32 | + } |
|
| 31 | 33 | return $folder; |
| 32 | 34 | } |
| 33 | 35 | |
@@ -51,21 +53,25 @@ discard block |
||
| 51 | 53 | * "Bulk Loads" a filesystem into the internal virtual filesystem |
| 52 | 54 | */ |
| 53 | 55 | function setfs( $paths ) { |
| 54 | - if ( ! is_array($paths) ) |
|
| 55 | - $paths = explode( "\n", $paths ); |
|
| 56 | + if ( ! is_array($paths) ) { |
|
| 57 | + $paths = explode( "\n", $paths ); |
|
| 58 | + } |
|
| 56 | 59 | |
| 57 | 60 | $paths = array_filter( array_map( 'trim', $paths ) ); |
| 58 | 61 | |
| 59 | 62 | foreach ( $paths as $path ) { |
| 60 | 63 | // Allow for comments |
| 61 | - if ( '#' == $path[0] ) |
|
| 62 | - continue; |
|
| 64 | + if ( '#' == $path[0] ) { |
|
| 65 | + continue; |
|
| 66 | + } |
|
| 63 | 67 | |
| 64 | 68 | // Directories |
| 65 | - if ( '/' == $path[ strlen($path) -1 ] ) |
|
| 66 | - $this->mkdir( $path ); |
|
| 67 | - else // Files (with dummy content for now) |
|
| 69 | + if ( '/' == $path[ strlen($path) -1 ] ) { |
|
| 70 | + $this->mkdir( $path ); |
|
| 71 | + } else { |
|
| 72 | + // Files (with dummy content for now) |
|
| 68 | 73 | $this->put_contents( $path, 'This is a test file' ); |
| 74 | + } |
|
| 69 | 75 | } |
| 70 | 76 | |
| 71 | 77 | } |
@@ -95,8 +101,9 @@ discard block |
||
| 95 | 101 | $dirname = str_replace( '\\', '/', dirname( $path ) ); |
| 96 | 102 | $this->mkdir( $dirname ); |
| 97 | 103 | $parent_node = $this->locate_parent_node( $path ); |
| 98 | - if ( ! $parent_node ) |
|
| 99 | - return false; |
|
| 104 | + if ( ! $parent_node ) { |
|
| 105 | + return false; |
|
| 106 | + } |
|
| 100 | 107 | } |
| 101 | 108 | |
| 102 | 109 | $node = new MockFS_Directory_Node( $path ); |
@@ -108,8 +115,9 @@ discard block |
||
| 108 | 115 | } |
| 109 | 116 | |
| 110 | 117 | function put_contents( $path, $contents = '', $mode = null ) { |
| 111 | - if ( ! $this->is_dir( dirname( $path ) ) ) |
|
| 112 | - $this->mkdir( dirname( $path ) ); |
|
| 118 | + if ( ! $this->is_dir( dirname( $path ) ) ) { |
|
| 119 | + $this->mkdir( dirname( $path ) ); |
|
| 120 | + } |
|
| 113 | 121 | |
| 114 | 122 | $parent = $this->locate_parent_node( $path ); |
| 115 | 123 | $new_file = new MockFS_File_Node( $path, $contents ); |
@@ -119,8 +127,9 @@ discard block |
||
| 119 | 127 | } |
| 120 | 128 | |
| 121 | 129 | function get_contents( $file ) { |
| 122 | - if ( ! $this->is_file( $file ) ) |
|
| 123 | - return false; |
|
| 130 | + if ( ! $this->is_file( $file ) ) { |
|
| 131 | + return false; |
|
| 132 | + } |
|
| 124 | 133 | return $this->fs_map[ $file ]->contents; |
| 125 | 134 | } |
| 126 | 135 | |
@@ -129,8 +138,9 @@ discard block |
||
| 129 | 138 | } |
| 130 | 139 | |
| 131 | 140 | function chdir( $path ) { |
| 132 | - if ( ! isset( $this->fs_map[ $path ] ) ) |
|
| 133 | - return false; |
|
| 141 | + if ( ! isset( $this->fs_map[ $path ] ) ) { |
|
| 142 | + return false; |
|
| 143 | + } |
|
| 134 | 144 | |
| 135 | 145 | $this->cwd = $this->fs_map[ $path ]; |
| 136 | 146 | return true; |
@@ -152,11 +162,13 @@ discard block |
||
| 152 | 162 | |
| 153 | 163 | function dirlist( $path = '.', $include_hidden = true, $recursive = false ) { |
| 154 | 164 | |
| 155 | - if ( empty( $path ) || '.' == $path ) |
|
| 156 | - $path = $this->cwd(); |
|
| 165 | + if ( empty( $path ) || '.' == $path ) { |
|
| 166 | + $path = $this->cwd(); |
|
| 167 | + } |
|
| 157 | 168 | |
| 158 | - if ( ! $this->exists( $path ) ) |
|
| 159 | - return false; |
|
| 169 | + if ( ! $this->exists( $path ) ) { |
|
| 170 | + return false; |
|
| 171 | + } |
|
| 160 | 172 | |
| 161 | 173 | $limit_file = false; |
| 162 | 174 | if ( $this->is_file( $path ) ) { |
@@ -166,24 +178,28 @@ discard block |
||
| 166 | 178 | |
| 167 | 179 | $ret = array(); |
| 168 | 180 | foreach ( $this->fs_map[ $path ]->children as $entry ) { |
| 169 | - if ( '.' == $entry->name || '..' == $entry->name ) |
|
| 170 | - continue; |
|
| 181 | + if ( '.' == $entry->name || '..' == $entry->name ) { |
|
| 182 | + continue; |
|
| 183 | + } |
|
| 171 | 184 | |
| 172 | - if ( ! $include_hidden && '.' == $entry->name ) |
|
| 173 | - continue; |
|
| 185 | + if ( ! $include_hidden && '.' == $entry->name ) { |
|
| 186 | + continue; |
|
| 187 | + } |
|
| 174 | 188 | |
| 175 | - if ( $limit_file && $entry->name != $limit_file ) |
|
| 176 | - continue; |
|
| 189 | + if ( $limit_file && $entry->name != $limit_file ) { |
|
| 190 | + continue; |
|
| 191 | + } |
|
| 177 | 192 | |
| 178 | 193 | $struc = array(); |
| 179 | 194 | $struc['name'] = $entry->name; |
| 180 | 195 | $struc['type'] = $entry->type; |
| 181 | 196 | |
| 182 | 197 | if ( 'd' == $struc['type'] ) { |
| 183 | - if ( $recursive ) |
|
| 184 | - $struc['files'] = $this->dirlist( trailingslashit( $path ) . trailingslashit( $struc['name'] ), $include_hidden, $recursive ); |
|
| 185 | - else |
|
| 186 | - $struc['files'] = array(); |
|
| 198 | + if ( $recursive ) { |
|
| 199 | + $struc['files'] = $this->dirlist( trailingslashit( $path ) . trailingslashit( $struc['name'] ), $include_hidden, $recursive ); |
|
| 200 | + } else { |
|
| 201 | + $struc['files'] = array(); |
|
| 202 | + } |
|
| 187 | 203 | } |
| 188 | 204 | |
| 189 | 205 | $ret[ $entry->name ] = $struc; |
@@ -20,13 +20,13 @@ discard block |
||
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // Copy of core's function, but accepts a path. |
| 23 | - function abspath( $path = false ) { |
|
| 24 | - if ( ! $path ) |
|
| 23 | + function abspath($path = false) { |
|
| 24 | + if (!$path) |
|
| 25 | 25 | $path = ABSPATH; |
| 26 | - $folder = $this->find_folder( $path ); |
|
| 26 | + $folder = $this->find_folder($path); |
|
| 27 | 27 | |
| 28 | 28 | // Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare. |
| 29 | - if ( ! $folder && $this->is_dir('/wp-includes') ) |
|
| 29 | + if (!$folder && $this->is_dir('/wp-includes')) |
|
| 30 | 30 | $folder = '/'; |
| 31 | 31 | return $folder; |
| 32 | 32 | } |
@@ -37,35 +37,35 @@ discard block |
||
| 37 | 37 | * Sets initial filesystem environment and/or clears the current environment. |
| 38 | 38 | * Can also be passed the initial filesystem to be setup which is passed to self::setfs() |
| 39 | 39 | */ |
| 40 | - function init( $paths = '', $home_dir = '/' ) { |
|
| 41 | - $this->fs = new MockFS_Directory_Node( '/' ); |
|
| 40 | + function init($paths = '', $home_dir = '/') { |
|
| 41 | + $this->fs = new MockFS_Directory_Node('/'); |
|
| 42 | 42 | $this->fs_map = array( |
| 43 | 43 | '/' => $this->fs, |
| 44 | 44 | ); |
| 45 | 45 | $this->cache = array(); // Used by find_folder() and friends |
| 46 | - $this->cwd = isset( $this->fs_map[ $home_dir ] ) ? $this->fs_map[ $home_dir ] : '/'; |
|
| 47 | - $this->setfs( $paths ); |
|
| 46 | + $this->cwd = isset($this->fs_map[$home_dir]) ? $this->fs_map[$home_dir] : '/'; |
|
| 47 | + $this->setfs($paths); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * "Bulk Loads" a filesystem into the internal virtual filesystem |
| 52 | 52 | */ |
| 53 | - function setfs( $paths ) { |
|
| 54 | - if ( ! is_array($paths) ) |
|
| 55 | - $paths = explode( "\n", $paths ); |
|
| 53 | + function setfs($paths) { |
|
| 54 | + if (!is_array($paths)) |
|
| 55 | + $paths = explode("\n", $paths); |
|
| 56 | 56 | |
| 57 | - $paths = array_filter( array_map( 'trim', $paths ) ); |
|
| 57 | + $paths = array_filter(array_map('trim', $paths)); |
|
| 58 | 58 | |
| 59 | - foreach ( $paths as $path ) { |
|
| 59 | + foreach ($paths as $path) { |
|
| 60 | 60 | // Allow for comments |
| 61 | - if ( '#' == $path[0] ) |
|
| 61 | + if ('#' == $path[0]) |
|
| 62 | 62 | continue; |
| 63 | 63 | |
| 64 | 64 | // Directories |
| 65 | - if ( '/' == $path[ strlen($path) -1 ] ) |
|
| 66 | - $this->mkdir( $path ); |
|
| 65 | + if ('/' == $path[strlen($path) - 1]) |
|
| 66 | + $this->mkdir($path); |
|
| 67 | 67 | else // Files (with dummy content for now) |
| 68 | - $this->put_contents( $path, 'This is a test file' ); |
|
| 68 | + $this->put_contents($path, 'This is a test file'); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | } |
@@ -73,120 +73,120 @@ discard block |
||
| 73 | 73 | /** |
| 74 | 74 | * Locates a filesystem "node" |
| 75 | 75 | */ |
| 76 | - private function locate_node( $path ) { |
|
| 77 | - return isset( $this->fs_map[ $path ] ) ? $this->fs_map[ $path ] : false; |
|
| 76 | + private function locate_node($path) { |
|
| 77 | + return isset($this->fs_map[$path]) ? $this->fs_map[$path] : false; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Locates a filesystem node for the parent of the given item |
| 82 | 82 | */ |
| 83 | - private function locate_parent_node( $path ) { |
|
| 84 | - $dirname = str_replace( '\\', '/', dirname( $path ) ); |
|
| 85 | - return $this->locate_node( trailingslashit( $dirname ) ); |
|
| 83 | + private function locate_parent_node($path) { |
|
| 84 | + $dirname = str_replace('\\', '/', dirname($path)); |
|
| 85 | + return $this->locate_node(trailingslashit($dirname)); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // Here starteth the WP_Filesystem functions. |
| 89 | 89 | |
| 90 | - function mkdir( $path, /* Optional args are ignored */ $chmod = false, $chown = false, $chgrp = false ) { |
|
| 91 | - $path = trailingslashit( $path ); |
|
| 90 | + function mkdir($path, /* Optional args are ignored */ $chmod = false, $chown = false, $chgrp = false) { |
|
| 91 | + $path = trailingslashit($path); |
|
| 92 | 92 | |
| 93 | - $parent_node = $this->locate_parent_node( $path ); |
|
| 94 | - if ( ! $parent_node ) { |
|
| 95 | - $dirname = str_replace( '\\', '/', dirname( $path ) ); |
|
| 96 | - $this->mkdir( $dirname ); |
|
| 97 | - $parent_node = $this->locate_parent_node( $path ); |
|
| 98 | - if ( ! $parent_node ) |
|
| 93 | + $parent_node = $this->locate_parent_node($path); |
|
| 94 | + if (!$parent_node) { |
|
| 95 | + $dirname = str_replace('\\', '/', dirname($path)); |
|
| 96 | + $this->mkdir($dirname); |
|
| 97 | + $parent_node = $this->locate_parent_node($path); |
|
| 98 | + if (!$parent_node) |
|
| 99 | 99 | return false; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $node = new MockFS_Directory_Node( $path ); |
|
| 102 | + $node = new MockFS_Directory_Node($path); |
|
| 103 | 103 | |
| 104 | - $parent_node->children[ $node->name ] = $node; |
|
| 105 | - $this->fs_map[ $path ] = $node; |
|
| 104 | + $parent_node->children[$node->name] = $node; |
|
| 105 | + $this->fs_map[$path] = $node; |
|
| 106 | 106 | |
| 107 | 107 | return true; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - function put_contents( $path, $contents = '', $mode = null ) { |
|
| 111 | - if ( ! $this->is_dir( dirname( $path ) ) ) |
|
| 112 | - $this->mkdir( dirname( $path ) ); |
|
| 110 | + function put_contents($path, $contents = '', $mode = null) { |
|
| 111 | + if (!$this->is_dir(dirname($path))) |
|
| 112 | + $this->mkdir(dirname($path)); |
|
| 113 | 113 | |
| 114 | - $parent = $this->locate_parent_node( $path ); |
|
| 115 | - $new_file = new MockFS_File_Node( $path, $contents ); |
|
| 114 | + $parent = $this->locate_parent_node($path); |
|
| 115 | + $new_file = new MockFS_File_Node($path, $contents); |
|
| 116 | 116 | |
| 117 | - $parent->children[ $new_file->name ] = $new_file; |
|
| 118 | - $this->fs_map[ $path ] = $new_file; |
|
| 117 | + $parent->children[$new_file->name] = $new_file; |
|
| 118 | + $this->fs_map[$path] = $new_file; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - function get_contents( $file ) { |
|
| 122 | - if ( ! $this->is_file( $file ) ) |
|
| 121 | + function get_contents($file) { |
|
| 122 | + if (!$this->is_file($file)) |
|
| 123 | 123 | return false; |
| 124 | - return $this->fs_map[ $file ]->contents; |
|
| 124 | + return $this->fs_map[$file]->contents; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | function cwd() { |
| 128 | 128 | return $this->cwd->path; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - function chdir( $path ) { |
|
| 132 | - if ( ! isset( $this->fs_map[ $path ] ) ) |
|
| 131 | + function chdir($path) { |
|
| 132 | + if (!isset($this->fs_map[$path])) |
|
| 133 | 133 | return false; |
| 134 | 134 | |
| 135 | - $this->cwd = $this->fs_map[ $path ]; |
|
| 135 | + $this->cwd = $this->fs_map[$path]; |
|
| 136 | 136 | return true; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - function exists( $path ) { |
|
| 140 | - return isset( $this->fs_map[ $path ] ) || isset( $this->fs_map[ trailingslashit( $path ) ] ); |
|
| 139 | + function exists($path) { |
|
| 140 | + return isset($this->fs_map[$path]) || isset($this->fs_map[trailingslashit($path)]); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - function is_file( $file ) { |
|
| 144 | - return isset( $this->fs_map[ $file ] ) && $this->fs_map[ $file ]->is_file(); |
|
| 143 | + function is_file($file) { |
|
| 144 | + return isset($this->fs_map[$file]) && $this->fs_map[$file]->is_file(); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - function is_dir( $path ) { |
|
| 148 | - $path = trailingslashit( $path ); |
|
| 147 | + function is_dir($path) { |
|
| 148 | + $path = trailingslashit($path); |
|
| 149 | 149 | |
| 150 | - return isset( $this->fs_map[ $path ] ) && $this->fs_map[ $path ]->is_dir(); |
|
| 150 | + return isset($this->fs_map[$path]) && $this->fs_map[$path]->is_dir(); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - function dirlist( $path = '.', $include_hidden = true, $recursive = false ) { |
|
| 153 | + function dirlist($path = '.', $include_hidden = true, $recursive = false) { |
|
| 154 | 154 | |
| 155 | - if ( empty( $path ) || '.' == $path ) |
|
| 155 | + if (empty($path) || '.' == $path) |
|
| 156 | 156 | $path = $this->cwd(); |
| 157 | 157 | |
| 158 | - if ( ! $this->exists( $path ) ) |
|
| 158 | + if (!$this->exists($path)) |
|
| 159 | 159 | return false; |
| 160 | 160 | |
| 161 | 161 | $limit_file = false; |
| 162 | - if ( $this->is_file( $path ) ) { |
|
| 163 | - $limit_file = $this->locate_node( $path )->name; |
|
| 164 | - $path = dirname( $path ) . '/'; |
|
| 162 | + if ($this->is_file($path)) { |
|
| 163 | + $limit_file = $this->locate_node($path)->name; |
|
| 164 | + $path = dirname($path).'/'; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | $ret = array(); |
| 168 | - foreach ( $this->fs_map[ $path ]->children as $entry ) { |
|
| 169 | - if ( '.' == $entry->name || '..' == $entry->name ) |
|
| 168 | + foreach ($this->fs_map[$path]->children as $entry) { |
|
| 169 | + if ('.' == $entry->name || '..' == $entry->name) |
|
| 170 | 170 | continue; |
| 171 | 171 | |
| 172 | - if ( ! $include_hidden && '.' == $entry->name ) |
|
| 172 | + if (!$include_hidden && '.' == $entry->name) |
|
| 173 | 173 | continue; |
| 174 | 174 | |
| 175 | - if ( $limit_file && $entry->name != $limit_file ) |
|
| 175 | + if ($limit_file && $entry->name != $limit_file) |
|
| 176 | 176 | continue; |
| 177 | 177 | |
| 178 | 178 | $struc = array(); |
| 179 | 179 | $struc['name'] = $entry->name; |
| 180 | 180 | $struc['type'] = $entry->type; |
| 181 | 181 | |
| 182 | - if ( 'd' == $struc['type'] ) { |
|
| 183 | - if ( $recursive ) |
|
| 184 | - $struc['files'] = $this->dirlist( trailingslashit( $path ) . trailingslashit( $struc['name'] ), $include_hidden, $recursive ); |
|
| 182 | + if ('d' == $struc['type']) { |
|
| 183 | + if ($recursive) |
|
| 184 | + $struc['files'] = $this->dirlist(trailingslashit($path).trailingslashit($struc['name']), $include_hidden, $recursive); |
|
| 185 | 185 | else |
| 186 | 186 | $struc['files'] = array(); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - $ret[ $entry->name ] = $struc; |
|
| 189 | + $ret[$entry->name] = $struc; |
|
| 190 | 190 | } |
| 191 | 191 | return $ret; |
| 192 | 192 | } |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | public $type; // The type of the entry 'f' for file, 'd' for Directory |
| 199 | 199 | public $path; // The full path to the entry. |
| 200 | 200 | |
| 201 | - function __construct( $path ) { |
|
| 201 | + function __construct($path) { |
|
| 202 | 202 | $this->path = $path; |
| 203 | - $this->name = basename( $path ); |
|
| 203 | + $this->name = basename($path); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | function is_file() { |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | public $type = 'f'; |
| 222 | 222 | public $contents = ''; // The contents of the file |
| 223 | 223 | |
| 224 | - function __construct( $path, $contents = '' ) { |
|
| 225 | - parent::__construct( $path ); |
|
| 224 | + function __construct($path, $contents = '') { |
|
| 225 | + parent::__construct($path); |
|
| 226 | 226 | $this->contents = $contents; |
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | \ No newline at end of file |
@@ -336,8 +336,6 @@ discard block |
||
| 336 | 336 | * |
| 337 | 337 | * @since 4.2.0 |
| 338 | 338 | * |
| 339 | - * @param string $deprecated Name of the function, method, or class that appears in the first argument of the |
|
| 340 | - * source `_doing_it_wrong()` call. |
|
| 341 | 339 | */ |
| 342 | 340 | public function setExpectedIncorrectUsage( $doing_it_wrong ) { |
| 343 | 341 | array_push( $this->expected_doing_it_wrong, $doing_it_wrong ); |
@@ -525,7 +523,6 @@ discard block |
||
| 525 | 523 | * expected to be false. For example, assertQueryTrue('is_single', 'is_feed') means is_single() |
| 526 | 524 | * and is_feed() must be true and everything else must be false to pass. |
| 527 | 525 | * |
| 528 | - * @param string $prop,... Any number of WP_Query properties that are expected to be true for the current request. |
|
| 529 | 526 | */ |
| 530 | 527 | function assertQueryTrue(/* ... */) { |
| 531 | 528 | global $wp_query; |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | function __get( $name ) { |
| 22 | 22 | if ( 'factory' === $name ) { |
| 23 | 23 | return self::factory(); |
| 24 | - } |
|
| 24 | + } |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | protected static function factory() { |
@@ -256,14 +256,16 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | function _create_temporary_tables( $query ) { |
| 259 | - if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) ) |
|
| 260 | - return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 ); |
|
| 259 | + if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) ) { |
|
| 260 | + return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 ); |
|
| 261 | + } |
|
| 261 | 262 | return $query; |
| 262 | 263 | } |
| 263 | 264 | |
| 264 | 265 | function _drop_temporary_tables( $query ) { |
| 265 | - if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) ) |
|
| 266 | - return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 ); |
|
| 266 | + if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) ) { |
|
| 267 | + return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 ); |
|
| 268 | + } |
|
| 267 | 269 | return $query; |
| 268 | 270 | } |
| 269 | 271 | |
@@ -278,10 +280,12 @@ discard block |
||
| 278 | 280 | function expectDeprecated() { |
| 279 | 281 | $annotations = $this->getAnnotations(); |
| 280 | 282 | foreach ( array( 'class', 'method' ) as $depth ) { |
| 281 | - if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) ) |
|
| 282 | - $this->expected_deprecated = array_merge( $this->expected_deprecated, $annotations[ $depth ]['expectedDeprecated'] ); |
|
| 283 | - if ( ! empty( $annotations[ $depth ]['expectedIncorrectUsage'] ) ) |
|
| 284 | - $this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $annotations[ $depth ]['expectedIncorrectUsage'] ); |
|
| 283 | + if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) ) { |
|
| 284 | + $this->expected_deprecated = array_merge( $this->expected_deprecated, $annotations[ $depth ]['expectedDeprecated'] ); |
|
| 285 | + } |
|
| 286 | + if ( ! empty( $annotations[ $depth ]['expectedIncorrectUsage'] ) ) { |
|
| 287 | + $this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $annotations[ $depth ]['expectedIncorrectUsage'] ); |
|
| 288 | + } |
|
| 285 | 289 | } |
| 286 | 290 | add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) ); |
| 287 | 291 | add_action( 'deprecated_argument_run', array( $this, 'deprecated_function_run' ) ); |
@@ -344,13 +348,15 @@ discard block |
||
| 344 | 348 | } |
| 345 | 349 | |
| 346 | 350 | function deprecated_function_run( $function ) { |
| 347 | - if ( ! in_array( $function, $this->caught_deprecated ) ) |
|
| 348 | - $this->caught_deprecated[] = $function; |
|
| 351 | + if ( ! in_array( $function, $this->caught_deprecated ) ) { |
|
| 352 | + $this->caught_deprecated[] = $function; |
|
| 353 | + } |
|
| 349 | 354 | } |
| 350 | 355 | |
| 351 | 356 | function doing_it_wrong_run( $function ) { |
| 352 | - if ( ! in_array( $function, $this->caught_doing_it_wrong ) ) |
|
| 353 | - $this->caught_doing_it_wrong[] = $function; |
|
| 357 | + if ( ! in_array( $function, $this->caught_doing_it_wrong ) ) { |
|
| 358 | + $this->caught_doing_it_wrong[] = $function; |
|
| 359 | + } |
|
| 354 | 360 | } |
| 355 | 361 | |
| 356 | 362 | function assertWPError( $actual, $message = '' ) { |
@@ -394,7 +400,9 @@ discard block |
||
| 394 | 400 | // to run them more than once without very carefully clearing everything |
| 395 | 401 | $_GET = $_POST = array(); |
| 396 | 402 | foreach (array('query_string', 'id', 'postdata', 'authordata', 'day', 'currentmonth', 'page', 'pages', 'multipage', 'more', 'numpages', 'pagenow') as $v) { |
| 397 | - if ( isset( $GLOBALS[$v] ) ) unset( $GLOBALS[$v] ); |
|
| 403 | + if ( isset( $GLOBALS[$v] ) ) { |
|
| 404 | + unset( $GLOBALS[$v] ); |
|
| 405 | + } |
|
| 398 | 406 | } |
| 399 | 407 | $parts = parse_url($url); |
| 400 | 408 | if (isset($parts['scheme'])) { |
@@ -439,20 +447,23 @@ discard block |
||
| 439 | 447 | return; |
| 440 | 448 | } |
| 441 | 449 | |
| 442 | - if ( WP_TESTS_FORCE_KNOWN_BUGS ) |
|
| 443 | - return; |
|
| 450 | + if ( WP_TESTS_FORCE_KNOWN_BUGS ) { |
|
| 451 | + return; |
|
| 452 | + } |
|
| 444 | 453 | $tickets = PHPUnit_Util_Test::getTickets( get_class( $this ), $this->getName( false ) ); |
| 445 | 454 | foreach ( $tickets as $ticket ) { |
| 446 | 455 | if ( is_numeric( $ticket ) ) { |
| 447 | 456 | $this->knownWPBug( $ticket ); |
| 448 | 457 | } elseif ( 'UT' == substr( $ticket, 0, 2 ) ) { |
| 449 | 458 | $ticket = substr( $ticket, 2 ); |
| 450 | - if ( $ticket && is_numeric( $ticket ) ) |
|
| 451 | - $this->knownUTBug( $ticket ); |
|
| 459 | + if ( $ticket && is_numeric( $ticket ) ) { |
|
| 460 | + $this->knownUTBug( $ticket ); |
|
| 461 | + } |
|
| 452 | 462 | } elseif ( 'Plugin' == substr( $ticket, 0, 6 ) ) { |
| 453 | 463 | $ticket = substr( $ticket, 6 ); |
| 454 | - if ( $ticket && is_numeric( $ticket ) ) |
|
| 455 | - $this->knownPluginBug( $ticket ); |
|
| 464 | + if ( $ticket && is_numeric( $ticket ) ) { |
|
| 465 | + $this->knownPluginBug( $ticket ); |
|
| 466 | + } |
|
| 456 | 467 | } |
| 457 | 468 | } |
| 458 | 469 | } |
@@ -461,30 +472,36 @@ discard block |
||
| 461 | 472 | * Skips the current test if there is an open WordPress ticket with id $ticket_id |
| 462 | 473 | */ |
| 463 | 474 | function knownWPBug( $ticket_id ) { |
| 464 | - if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets ) ) |
|
| 465 | - return; |
|
| 466 | - if ( ! TracTickets::isTracTicketClosed( 'https://core.trac.wordpress.org', $ticket_id ) ) |
|
| 467 | - $this->markTestSkipped( sprintf( 'WordPress Ticket #%d is not fixed', $ticket_id ) ); |
|
| 475 | + if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets ) ) { |
|
| 476 | + return; |
|
| 477 | + } |
|
| 478 | + if ( ! TracTickets::isTracTicketClosed( 'https://core.trac.wordpress.org', $ticket_id ) ) { |
|
| 479 | + $this->markTestSkipped( sprintf( 'WordPress Ticket #%d is not fixed', $ticket_id ) ); |
|
| 480 | + } |
|
| 468 | 481 | } |
| 469 | 482 | |
| 470 | 483 | /** |
| 471 | 484 | * Skips the current test if there is an open unit tests ticket with id $ticket_id |
| 472 | 485 | */ |
| 473 | 486 | function knownUTBug( $ticket_id ) { |
| 474 | - if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'UT' . $ticket_id, self::$forced_tickets ) ) |
|
| 475 | - return; |
|
| 476 | - if ( ! TracTickets::isTracTicketClosed( 'https://unit-tests.trac.wordpress.org', $ticket_id ) ) |
|
| 477 | - $this->markTestSkipped( sprintf( 'Unit Tests Ticket #%d is not fixed', $ticket_id ) ); |
|
| 487 | + if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'UT' . $ticket_id, self::$forced_tickets ) ) { |
|
| 488 | + return; |
|
| 489 | + } |
|
| 490 | + if ( ! TracTickets::isTracTicketClosed( 'https://unit-tests.trac.wordpress.org', $ticket_id ) ) { |
|
| 491 | + $this->markTestSkipped( sprintf( 'Unit Tests Ticket #%d is not fixed', $ticket_id ) ); |
|
| 492 | + } |
|
| 478 | 493 | } |
| 479 | 494 | |
| 480 | 495 | /** |
| 481 | 496 | * Skips the current test if there is an open plugin ticket with id $ticket_id |
| 482 | 497 | */ |
| 483 | 498 | function knownPluginBug( $ticket_id ) { |
| 484 | - if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'Plugin' . $ticket_id, self::$forced_tickets ) ) |
|
| 485 | - return; |
|
| 486 | - if ( ! TracTickets::isTracTicketClosed( 'https://plugins.trac.wordpress.org', $ticket_id ) ) |
|
| 487 | - $this->markTestSkipped( sprintf( 'WordPress Plugin Ticket #%d is not fixed', $ticket_id ) ); |
|
| 499 | + if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'Plugin' . $ticket_id, self::$forced_tickets ) ) { |
|
| 500 | + return; |
|
| 501 | + } |
|
| 502 | + if ( ! TracTickets::isTracTicketClosed( 'https://plugins.trac.wordpress.org', $ticket_id ) ) { |
|
| 503 | + $this->markTestSkipped( sprintf( 'WordPress Plugin Ticket #%d is not fixed', $ticket_id ) ); |
|
| 504 | + } |
|
| 488 | 505 | } |
| 489 | 506 | |
| 490 | 507 | public static function forceTicket( $ticket ) { |
@@ -506,9 +523,10 @@ discard block |
||
| 506 | 523 | function temp_filename() { |
| 507 | 524 | $tmp_dir = ''; |
| 508 | 525 | $dirs = array( 'TMP', 'TMPDIR', 'TEMP' ); |
| 509 | - foreach( $dirs as $dir ) |
|
| 510 | - if ( isset( $_ENV[$dir] ) && !empty( $_ENV[$dir] ) ) { |
|
| 526 | + foreach( $dirs as $dir ) { |
|
| 527 | + if ( isset( $_ENV[$dir] ) && !empty( $_ENV[$dir] ) ) { |
|
| 511 | 528 | $tmp_dir = $dir; |
| 529 | + } |
|
| 512 | 530 | break; |
| 513 | 531 | } |
| 514 | 532 | if ( empty( $tmp_dir ) ) { |
@@ -579,10 +597,12 @@ discard block |
||
| 579 | 597 | } |
| 580 | 598 | |
| 581 | 599 | $message = ''; |
| 582 | - if ( count($not_true) ) |
|
| 583 | - $message .= implode( $not_true, ', ' ) . ' is expected to be true. '; |
|
| 584 | - if ( count($not_false) ) |
|
| 585 | - $message .= implode( $not_false, ', ' ) . ' is expected to be false.'; |
|
| 600 | + if ( count($not_true) ) { |
|
| 601 | + $message .= implode( $not_true, ', ' ) . ' is expected to be true. '; |
|
| 602 | + } |
|
| 603 | + if ( count($not_false) ) { |
|
| 604 | + $message .= implode( $not_false, ', ' ) . ' is expected to be false.'; |
|
| 605 | + } |
|
| 586 | 606 | $this->assertTrue( $passed, $message ); |
| 587 | 607 | } |
| 588 | 608 | |
@@ -702,8 +722,9 @@ discard block |
||
| 702 | 722 | $type = $upload['type']; |
| 703 | 723 | } else { |
| 704 | 724 | $mime = wp_check_filetype( $upload['file'] ); |
| 705 | - if ($mime) |
|
| 706 | - $type = $mime['type']; |
|
| 725 | + if ($mime) { |
|
| 726 | + $type = $mime['type']; |
|
| 727 | + } |
|
| 707 | 728 | } |
| 708 | 729 | |
| 709 | 730 | $attachment = array( |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once dirname( __FILE__ ) . '/factory.php'; |
|
| 4 | -require_once dirname( __FILE__ ) . '/trac.php'; |
|
| 3 | +require_once dirname(__FILE__).'/factory.php'; |
|
| 4 | +require_once dirname(__FILE__).'/trac.php'; |
|
| 5 | 5 | |
| 6 | 6 | class WP_UnitTestCase extends PHPUnit_Framework_TestCase { |
| 7 | 7 | |
@@ -14,26 +14,26 @@ discard block |
||
| 14 | 14 | protected static $hooks_saved = array(); |
| 15 | 15 | protected static $ignore_files; |
| 16 | 16 | |
| 17 | - function __isset( $name ) { |
|
| 17 | + function __isset($name) { |
|
| 18 | 18 | return 'factory' === $name; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - function __get( $name ) { |
|
| 22 | - if ( 'factory' === $name ) { |
|
| 21 | + function __get($name) { |
|
| 22 | + if ('factory' === $name) { |
|
| 23 | 23 | return self::factory(); |
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | protected static function factory() { |
| 28 | 28 | static $factory = null; |
| 29 | - if ( ! $factory ) { |
|
| 29 | + if (!$factory) { |
|
| 30 | 30 | $factory = new WP_UnitTest_Factory(); |
| 31 | 31 | } |
| 32 | 32 | return $factory; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public static function get_called_class() { |
| 36 | - if ( function_exists( 'get_called_class' ) ) { |
|
| 36 | + if (function_exists('get_called_class')) { |
|
| 37 | 37 | return get_called_class(); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $backtrace = debug_backtrace(); |
| 42 | 42 | // [0] WP_UnitTestCase::get_called_class() |
| 43 | 43 | // [1] WP_UnitTestCase::setUpBeforeClass() |
| 44 | - if ( 'call_user_func' === $backtrace[2]['function'] ) { |
|
| 44 | + if ('call_user_func' === $backtrace[2]['function']) { |
|
| 45 | 45 | return $backtrace[2]['args'][0][0]; |
| 46 | 46 | } |
| 47 | 47 | return $backtrace[2]['class']; |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | parent::setUpBeforeClass(); |
| 52 | 52 | |
| 53 | 53 | $c = self::get_called_class(); |
| 54 | - if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) { |
|
| 54 | + if (!method_exists($c, 'wpSetUpBeforeClass')) { |
|
| 55 | 55 | return; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::factory() ); |
|
| 58 | + call_user_func(array($c, 'wpSetUpBeforeClass'), self::factory()); |
|
| 59 | 59 | |
| 60 | 60 | self::commit_transaction(); |
| 61 | 61 | } |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | parent::tearDownAfterClass(); |
| 65 | 65 | |
| 66 | 66 | $c = self::get_called_class(); |
| 67 | - if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) { |
|
| 67 | + if (!method_exists($c, 'wpTearDownAfterClass')) { |
|
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - call_user_func( array( $c, 'wpTearDownAfterClass' ) ); |
|
| 71 | + call_user_func(array($c, 'wpTearDownAfterClass')); |
|
| 72 | 72 | |
| 73 | 73 | self::commit_transaction(); |
| 74 | 74 | } |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | function setUp() { |
| 77 | 77 | set_time_limit(0); |
| 78 | 78 | |
| 79 | - if ( ! self::$ignore_files ) { |
|
| 79 | + if (!self::$ignore_files) { |
|
| 80 | 80 | self::$ignore_files = $this->scan_user_uploads(); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( ! self::$hooks_saved ) { |
|
| 83 | + if (!self::$hooks_saved) { |
|
| 84 | 84 | $this->_backup_hooks(); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $wpdb->suppress_errors = false; |
| 89 | 89 | $wpdb->show_errors = true; |
| 90 | 90 | $wpdb->db_connect(); |
| 91 | - ini_set('display_errors', 1 ); |
|
| 91 | + ini_set('display_errors', 1); |
|
| 92 | 92 | $this->clean_up_global_scope(); |
| 93 | 93 | |
| 94 | 94 | /* |
@@ -97,19 +97,19 @@ discard block |
||
| 97 | 97 | * given the large number of plugins that register post types and |
| 98 | 98 | * taxonomies at 'init'. |
| 99 | 99 | */ |
| 100 | - if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { |
|
| 100 | + if (defined('WP_RUN_CORE_TESTS') && WP_RUN_CORE_TESTS) { |
|
| 101 | 101 | $this->reset_post_types(); |
| 102 | 102 | $this->reset_taxonomies(); |
| 103 | 103 | $this->reset_post_statuses(); |
| 104 | 104 | |
| 105 | - if ( $wp_rewrite->permalink_structure ) { |
|
| 106 | - $this->set_permalink_structure( '' ); |
|
| 105 | + if ($wp_rewrite->permalink_structure) { |
|
| 106 | + $this->set_permalink_structure(''); |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $this->start_transaction(); |
| 111 | 111 | $this->expectDeprecated(); |
| 112 | - add_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) ); |
|
| 112 | + add_filter('wp_die_handler', array($this, 'get_wp_die_handler')); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -125,21 +125,21 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | function tearDown() { |
| 127 | 127 | global $wpdb, $wp_query, $wp, $post; |
| 128 | - $wpdb->query( 'ROLLBACK' ); |
|
| 129 | - if ( is_multisite() ) { |
|
| 130 | - while ( ms_is_switched() ) { |
|
| 128 | + $wpdb->query('ROLLBACK'); |
|
| 129 | + if (is_multisite()) { |
|
| 130 | + while (ms_is_switched()) { |
|
| 131 | 131 | restore_current_blog(); |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | $wp_query = new WP_Query(); |
| 135 | 135 | $wp = new WP(); |
| 136 | 136 | $post = null; |
| 137 | - remove_theme_support( 'html5' ); |
|
| 138 | - remove_filter( 'query', array( $this, '_create_temporary_tables' ) ); |
|
| 139 | - remove_filter( 'query', array( $this, '_drop_temporary_tables' ) ); |
|
| 140 | - remove_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) ); |
|
| 137 | + remove_theme_support('html5'); |
|
| 138 | + remove_filter('query', array($this, '_create_temporary_tables')); |
|
| 139 | + remove_filter('query', array($this, '_drop_temporary_tables')); |
|
| 140 | + remove_filter('wp_die_handler', array($this, 'get_wp_die_handler')); |
|
| 141 | 141 | $this->_restore_hooks(); |
| 142 | - wp_set_current_user( 0 ); |
|
| 142 | + wp_set_current_user(0); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | function clean_up_global_scope() { |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | * it has a chance to do so. |
| 157 | 157 | */ |
| 158 | 158 | protected function reset_post_types() { |
| 159 | - foreach ( get_post_types() as $pt ) { |
|
| 160 | - _unregister_post_type( $pt ); |
|
| 159 | + foreach (get_post_types() as $pt) { |
|
| 160 | + _unregister_post_type($pt); |
|
| 161 | 161 | } |
| 162 | 162 | create_initial_post_types(); |
| 163 | 163 | } |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | * it has a chance to do so. |
| 171 | 171 | */ |
| 172 | 172 | protected function reset_taxonomies() { |
| 173 | - foreach ( get_taxonomies() as $tax ) { |
|
| 174 | - _unregister_taxonomy( $tax ); |
|
| 173 | + foreach (get_taxonomies() as $tax) { |
|
| 174 | + _unregister_taxonomy($tax); |
|
| 175 | 175 | } |
| 176 | 176 | create_initial_taxonomies(); |
| 177 | 177 | } |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | * Unregister non-built-in post statuses. |
| 181 | 181 | */ |
| 182 | 182 | protected function reset_post_statuses() { |
| 183 | - foreach ( get_post_stati( array( '_builtin' => false ) ) as $post_status ) { |
|
| 184 | - _unregister_post_status( $post_status ); |
|
| 183 | + foreach (get_post_stati(array('_builtin' => false)) as $post_status) { |
|
| 184 | + _unregister_post_status($post_status); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | * @return void |
| 199 | 199 | */ |
| 200 | 200 | protected function _backup_hooks() { |
| 201 | - $globals = array( 'merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter' ); |
|
| 202 | - foreach ( $globals as $key ) { |
|
| 203 | - self::$hooks_saved[ $key ] = $GLOBALS[ $key ]; |
|
| 201 | + $globals = array('merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter'); |
|
| 202 | + foreach ($globals as $key) { |
|
| 203 | + self::$hooks_saved[$key] = $GLOBALS[$key]; |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
@@ -215,10 +215,10 @@ discard block |
||
| 215 | 215 | * @return void |
| 216 | 216 | */ |
| 217 | 217 | protected function _restore_hooks() { |
| 218 | - $globals = array( 'merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter' ); |
|
| 219 | - foreach ( $globals as $key ) { |
|
| 220 | - if ( isset( self::$hooks_saved[ $key ] ) ) { |
|
| 221 | - $GLOBALS[ $key ] = self::$hooks_saved[ $key ]; |
|
| 218 | + $globals = array('merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter'); |
|
| 219 | + foreach ($globals as $key) { |
|
| 220 | + if (isset(self::$hooks_saved[$key])) { |
|
| 221 | + $GLOBALS[$key] = self::$hooks_saved[$key]; |
|
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -229,20 +229,20 @@ discard block |
||
| 229 | 229 | $wp_object_cache->stats = array(); |
| 230 | 230 | $wp_object_cache->memcache_debug = array(); |
| 231 | 231 | $wp_object_cache->cache = array(); |
| 232 | - if ( method_exists( $wp_object_cache, '__remoteset' ) ) { |
|
| 232 | + if (method_exists($wp_object_cache, '__remoteset')) { |
|
| 233 | 233 | $wp_object_cache->__remoteset(); |
| 234 | 234 | } |
| 235 | 235 | wp_cache_flush(); |
| 236 | - wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache' ) ); |
|
| 237 | - wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) ); |
|
| 236 | + wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache')); |
|
| 237 | + wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | function start_transaction() { |
| 241 | 241 | global $wpdb; |
| 242 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
| 243 | - $wpdb->query( 'START TRANSACTION;' ); |
|
| 244 | - add_filter( 'query', array( $this, '_create_temporary_tables' ) ); |
|
| 245 | - add_filter( 'query', array( $this, '_drop_temporary_tables' ) ); |
|
| 242 | + $wpdb->query('SET autocommit = 0;'); |
|
| 243 | + $wpdb->query('START TRANSACTION;'); |
|
| 244 | + add_filter('query', array($this, '_create_temporary_tables')); |
|
| 245 | + add_filter('query', array($this, '_drop_temporary_tables')); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -252,70 +252,70 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public static function commit_transaction() { |
| 254 | 254 | global $wpdb; |
| 255 | - $wpdb->query( 'COMMIT;' ); |
|
| 255 | + $wpdb->query('COMMIT;'); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - function _create_temporary_tables( $query ) { |
|
| 259 | - if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) ) |
|
| 260 | - return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 ); |
|
| 258 | + function _create_temporary_tables($query) { |
|
| 259 | + if ('CREATE TABLE' === substr(trim($query), 0, 12)) |
|
| 260 | + return substr_replace(trim($query), 'CREATE TEMPORARY TABLE', 0, 12); |
|
| 261 | 261 | return $query; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - function _drop_temporary_tables( $query ) { |
|
| 265 | - if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) ) |
|
| 266 | - return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 ); |
|
| 264 | + function _drop_temporary_tables($query) { |
|
| 265 | + if ('DROP TABLE' === substr(trim($query), 0, 10)) |
|
| 266 | + return substr_replace(trim($query), 'DROP TEMPORARY TABLE', 0, 10); |
|
| 267 | 267 | return $query; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - function get_wp_die_handler( $handler ) { |
|
| 271 | - return array( $this, 'wp_die_handler' ); |
|
| 270 | + function get_wp_die_handler($handler) { |
|
| 271 | + return array($this, 'wp_die_handler'); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - function wp_die_handler( $message ) { |
|
| 275 | - throw new WPDieException( $message ); |
|
| 274 | + function wp_die_handler($message) { |
|
| 275 | + throw new WPDieException($message); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | function expectDeprecated() { |
| 279 | 279 | $annotations = $this->getAnnotations(); |
| 280 | - foreach ( array( 'class', 'method' ) as $depth ) { |
|
| 281 | - if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) ) |
|
| 282 | - $this->expected_deprecated = array_merge( $this->expected_deprecated, $annotations[ $depth ]['expectedDeprecated'] ); |
|
| 283 | - if ( ! empty( $annotations[ $depth ]['expectedIncorrectUsage'] ) ) |
|
| 284 | - $this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $annotations[ $depth ]['expectedIncorrectUsage'] ); |
|
| 280 | + foreach (array('class', 'method') as $depth) { |
|
| 281 | + if (!empty($annotations[$depth]['expectedDeprecated'])) |
|
| 282 | + $this->expected_deprecated = array_merge($this->expected_deprecated, $annotations[$depth]['expectedDeprecated']); |
|
| 283 | + if (!empty($annotations[$depth]['expectedIncorrectUsage'])) |
|
| 284 | + $this->expected_doing_it_wrong = array_merge($this->expected_doing_it_wrong, $annotations[$depth]['expectedIncorrectUsage']); |
|
| 285 | 285 | } |
| 286 | - add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) ); |
|
| 287 | - add_action( 'deprecated_argument_run', array( $this, 'deprecated_function_run' ) ); |
|
| 288 | - add_action( 'doing_it_wrong_run', array( $this, 'doing_it_wrong_run' ) ); |
|
| 289 | - add_action( 'deprecated_function_trigger_error', '__return_false' ); |
|
| 290 | - add_action( 'deprecated_argument_trigger_error', '__return_false' ); |
|
| 291 | - add_action( 'doing_it_wrong_trigger_error', '__return_false' ); |
|
| 286 | + add_action('deprecated_function_run', array($this, 'deprecated_function_run')); |
|
| 287 | + add_action('deprecated_argument_run', array($this, 'deprecated_function_run')); |
|
| 288 | + add_action('doing_it_wrong_run', array($this, 'doing_it_wrong_run')); |
|
| 289 | + add_action('deprecated_function_trigger_error', '__return_false'); |
|
| 290 | + add_action('deprecated_argument_trigger_error', '__return_false'); |
|
| 291 | + add_action('doing_it_wrong_trigger_error', '__return_false'); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | function expectedDeprecated() { |
| 295 | 295 | $errors = array(); |
| 296 | 296 | |
| 297 | - $not_caught_deprecated = array_diff( $this->expected_deprecated, $this->caught_deprecated ); |
|
| 298 | - foreach ( $not_caught_deprecated as $not_caught ) { |
|
| 297 | + $not_caught_deprecated = array_diff($this->expected_deprecated, $this->caught_deprecated); |
|
| 298 | + foreach ($not_caught_deprecated as $not_caught) { |
|
| 299 | 299 | $errors[] = "Failed to assert that $not_caught triggered a deprecated notice"; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - $unexpected_deprecated = array_diff( $this->caught_deprecated, $this->expected_deprecated ); |
|
| 303 | - foreach ( $unexpected_deprecated as $unexpected ) { |
|
| 302 | + $unexpected_deprecated = array_diff($this->caught_deprecated, $this->expected_deprecated); |
|
| 303 | + foreach ($unexpected_deprecated as $unexpected) { |
|
| 304 | 304 | $errors[] = "Unexpected deprecated notice for $unexpected"; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - $not_caught_doing_it_wrong = array_diff( $this->expected_doing_it_wrong, $this->caught_doing_it_wrong ); |
|
| 308 | - foreach ( $not_caught_doing_it_wrong as $not_caught ) { |
|
| 307 | + $not_caught_doing_it_wrong = array_diff($this->expected_doing_it_wrong, $this->caught_doing_it_wrong); |
|
| 308 | + foreach ($not_caught_doing_it_wrong as $not_caught) { |
|
| 309 | 309 | $errors[] = "Failed to assert that $not_caught triggered an incorrect usage notice"; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - $unexpected_doing_it_wrong = array_diff( $this->caught_doing_it_wrong, $this->expected_doing_it_wrong ); |
|
| 313 | - foreach ( $unexpected_doing_it_wrong as $unexpected ) { |
|
| 312 | + $unexpected_doing_it_wrong = array_diff($this->caught_doing_it_wrong, $this->expected_doing_it_wrong); |
|
| 313 | + foreach ($unexpected_doing_it_wrong as $unexpected) { |
|
| 314 | 314 | $errors[] = "Unexpected incorrect usage notice for $unexpected"; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - if ( ! empty( $errors ) ) { |
|
| 318 | - $this->fail( implode( "\n", $errors ) ); |
|
| 317 | + if (!empty($errors)) { |
|
| 318 | + $this->fail(implode("\n", $errors)); |
|
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | * @param string $deprecated Name of the function, method, class, or argument that is deprecated. Must match |
| 328 | 328 | * first parameter of the `_deprecated_function()` or `_deprecated_argument()` call. |
| 329 | 329 | */ |
| 330 | - public function setExpectedDeprecated( $deprecated ) { |
|
| 331 | - array_push( $this->expected_deprecated, $deprecated ); |
|
| 330 | + public function setExpectedDeprecated($deprecated) { |
|
| 331 | + array_push($this->expected_deprecated, $deprecated); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
@@ -339,75 +339,75 @@ discard block |
||
| 339 | 339 | * @param string $deprecated Name of the function, method, or class that appears in the first argument of the |
| 340 | 340 | * source `_doing_it_wrong()` call. |
| 341 | 341 | */ |
| 342 | - public function setExpectedIncorrectUsage( $doing_it_wrong ) { |
|
| 343 | - array_push( $this->expected_doing_it_wrong, $doing_it_wrong ); |
|
| 342 | + public function setExpectedIncorrectUsage($doing_it_wrong) { |
|
| 343 | + array_push($this->expected_doing_it_wrong, $doing_it_wrong); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - function deprecated_function_run( $function ) { |
|
| 347 | - if ( ! in_array( $function, $this->caught_deprecated ) ) |
|
| 346 | + function deprecated_function_run($function) { |
|
| 347 | + if (!in_array($function, $this->caught_deprecated)) |
|
| 348 | 348 | $this->caught_deprecated[] = $function; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - function doing_it_wrong_run( $function ) { |
|
| 352 | - if ( ! in_array( $function, $this->caught_doing_it_wrong ) ) |
|
| 351 | + function doing_it_wrong_run($function) { |
|
| 352 | + if (!in_array($function, $this->caught_doing_it_wrong)) |
|
| 353 | 353 | $this->caught_doing_it_wrong[] = $function; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - function assertWPError( $actual, $message = '' ) { |
|
| 357 | - $this->assertInstanceOf( 'WP_Error', $actual, $message ); |
|
| 356 | + function assertWPError($actual, $message = '') { |
|
| 357 | + $this->assertInstanceOf('WP_Error', $actual, $message); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - function assertNotWPError( $actual, $message = '' ) { |
|
| 361 | - if ( is_wp_error( $actual ) && '' === $message ) { |
|
| 360 | + function assertNotWPError($actual, $message = '') { |
|
| 361 | + if (is_wp_error($actual) && '' === $message) { |
|
| 362 | 362 | $message = $actual->get_error_message(); |
| 363 | 363 | } |
| 364 | - $this->assertNotInstanceOf( 'WP_Error', $actual, $message ); |
|
| 364 | + $this->assertNotInstanceOf('WP_Error', $actual, $message); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - function assertEqualFields( $object, $fields ) { |
|
| 368 | - foreach( $fields as $field_name => $field_value ) { |
|
| 369 | - if ( $object->{$field_name} != $field_value ) { |
|
| 367 | + function assertEqualFields($object, $fields) { |
|
| 368 | + foreach ($fields as $field_name => $field_value) { |
|
| 369 | + if ($object->{$field_name} != $field_value) { |
|
| 370 | 370 | $this->fail(); |
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - function assertDiscardWhitespace( $expected, $actual ) { |
|
| 376 | - $this->assertEquals( preg_replace( '/\s*/', '', $expected ), preg_replace( '/\s*/', '', $actual ) ); |
|
| 375 | + function assertDiscardWhitespace($expected, $actual) { |
|
| 376 | + $this->assertEquals(preg_replace('/\s*/', '', $expected), preg_replace('/\s*/', '', $actual)); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - function assertEqualSets( $expected, $actual ) { |
|
| 380 | - sort( $expected ); |
|
| 381 | - sort( $actual ); |
|
| 382 | - $this->assertEquals( $expected, $actual ); |
|
| 379 | + function assertEqualSets($expected, $actual) { |
|
| 380 | + sort($expected); |
|
| 381 | + sort($actual); |
|
| 382 | + $this->assertEquals($expected, $actual); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - function assertEqualSetsWithIndex( $expected, $actual ) { |
|
| 386 | - ksort( $expected ); |
|
| 387 | - ksort( $actual ); |
|
| 388 | - $this->assertEquals( $expected, $actual ); |
|
| 385 | + function assertEqualSetsWithIndex($expected, $actual) { |
|
| 386 | + ksort($expected); |
|
| 387 | + ksort($actual); |
|
| 388 | + $this->assertEquals($expected, $actual); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - function go_to( $url ) { |
|
| 391 | + function go_to($url) { |
|
| 392 | 392 | // note: the WP and WP_Query classes like to silently fetch parameters |
| 393 | 393 | // from all over the place (globals, GET, etc), which makes it tricky |
| 394 | 394 | // to run them more than once without very carefully clearing everything |
| 395 | 395 | $_GET = $_POST = array(); |
| 396 | 396 | foreach (array('query_string', 'id', 'postdata', 'authordata', 'day', 'currentmonth', 'page', 'pages', 'multipage', 'more', 'numpages', 'pagenow') as $v) { |
| 397 | - if ( isset( $GLOBALS[$v] ) ) unset( $GLOBALS[$v] ); |
|
| 397 | + if (isset($GLOBALS[$v])) unset($GLOBALS[$v]); |
|
| 398 | 398 | } |
| 399 | 399 | $parts = parse_url($url); |
| 400 | 400 | if (isset($parts['scheme'])) { |
| 401 | - $req = isset( $parts['path'] ) ? $parts['path'] : ''; |
|
| 401 | + $req = isset($parts['path']) ? $parts['path'] : ''; |
|
| 402 | 402 | if (isset($parts['query'])) { |
| 403 | - $req .= '?' . $parts['query']; |
|
| 403 | + $req .= '?'.$parts['query']; |
|
| 404 | 404 | // parse the url query vars into $_GET |
| 405 | 405 | parse_str($parts['query'], $_GET); |
| 406 | 406 | } |
| 407 | 407 | } else { |
| 408 | 408 | $req = $url; |
| 409 | 409 | } |
| 410 | - if ( ! isset( $parts['query'] ) ) { |
|
| 410 | + if (!isset($parts['query'])) { |
|
| 411 | 411 | $parts['query'] = ''; |
| 412 | 412 | } |
| 413 | 413 | |
@@ -435,24 +435,24 @@ discard block |
||
| 435 | 435 | parent::checkRequirements(); |
| 436 | 436 | |
| 437 | 437 | // Core tests no longer check against open Trac tickets, but others using WP_UnitTestCase may do so. |
| 438 | - if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { |
|
| 438 | + if (defined('WP_RUN_CORE_TESTS') && WP_RUN_CORE_TESTS) { |
|
| 439 | 439 | return; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - if ( WP_TESTS_FORCE_KNOWN_BUGS ) |
|
| 442 | + if (WP_TESTS_FORCE_KNOWN_BUGS) |
|
| 443 | 443 | return; |
| 444 | - $tickets = PHPUnit_Util_Test::getTickets( get_class( $this ), $this->getName( false ) ); |
|
| 445 | - foreach ( $tickets as $ticket ) { |
|
| 446 | - if ( is_numeric( $ticket ) ) { |
|
| 447 | - $this->knownWPBug( $ticket ); |
|
| 448 | - } elseif ( 'UT' == substr( $ticket, 0, 2 ) ) { |
|
| 449 | - $ticket = substr( $ticket, 2 ); |
|
| 450 | - if ( $ticket && is_numeric( $ticket ) ) |
|
| 451 | - $this->knownUTBug( $ticket ); |
|
| 452 | - } elseif ( 'Plugin' == substr( $ticket, 0, 6 ) ) { |
|
| 453 | - $ticket = substr( $ticket, 6 ); |
|
| 454 | - if ( $ticket && is_numeric( $ticket ) ) |
|
| 455 | - $this->knownPluginBug( $ticket ); |
|
| 444 | + $tickets = PHPUnit_Util_Test::getTickets(get_class($this), $this->getName(false)); |
|
| 445 | + foreach ($tickets as $ticket) { |
|
| 446 | + if (is_numeric($ticket)) { |
|
| 447 | + $this->knownWPBug($ticket); |
|
| 448 | + } elseif ('UT' == substr($ticket, 0, 2)) { |
|
| 449 | + $ticket = substr($ticket, 2); |
|
| 450 | + if ($ticket && is_numeric($ticket)) |
|
| 451 | + $this->knownUTBug($ticket); |
|
| 452 | + } elseif ('Plugin' == substr($ticket, 0, 6)) { |
|
| 453 | + $ticket = substr($ticket, 6); |
|
| 454 | + if ($ticket && is_numeric($ticket)) |
|
| 455 | + $this->knownPluginBug($ticket); |
|
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | } |
@@ -460,44 +460,44 @@ discard block |
||
| 460 | 460 | /** |
| 461 | 461 | * Skips the current test if there is an open WordPress ticket with id $ticket_id |
| 462 | 462 | */ |
| 463 | - function knownWPBug( $ticket_id ) { |
|
| 464 | - if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets ) ) |
|
| 463 | + function knownWPBug($ticket_id) { |
|
| 464 | + if (WP_TESTS_FORCE_KNOWN_BUGS || in_array($ticket_id, self::$forced_tickets)) |
|
| 465 | 465 | return; |
| 466 | - if ( ! TracTickets::isTracTicketClosed( 'https://core.trac.wordpress.org', $ticket_id ) ) |
|
| 467 | - $this->markTestSkipped( sprintf( 'WordPress Ticket #%d is not fixed', $ticket_id ) ); |
|
| 466 | + if (!TracTickets::isTracTicketClosed('https://core.trac.wordpress.org', $ticket_id)) |
|
| 467 | + $this->markTestSkipped(sprintf('WordPress Ticket #%d is not fixed', $ticket_id)); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
| 471 | 471 | * Skips the current test if there is an open unit tests ticket with id $ticket_id |
| 472 | 472 | */ |
| 473 | - function knownUTBug( $ticket_id ) { |
|
| 474 | - if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'UT' . $ticket_id, self::$forced_tickets ) ) |
|
| 473 | + function knownUTBug($ticket_id) { |
|
| 474 | + if (WP_TESTS_FORCE_KNOWN_BUGS || in_array('UT'.$ticket_id, self::$forced_tickets)) |
|
| 475 | 475 | return; |
| 476 | - if ( ! TracTickets::isTracTicketClosed( 'https://unit-tests.trac.wordpress.org', $ticket_id ) ) |
|
| 477 | - $this->markTestSkipped( sprintf( 'Unit Tests Ticket #%d is not fixed', $ticket_id ) ); |
|
| 476 | + if (!TracTickets::isTracTicketClosed('https://unit-tests.trac.wordpress.org', $ticket_id)) |
|
| 477 | + $this->markTestSkipped(sprintf('Unit Tests Ticket #%d is not fixed', $ticket_id)); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | /** |
| 481 | 481 | * Skips the current test if there is an open plugin ticket with id $ticket_id |
| 482 | 482 | */ |
| 483 | - function knownPluginBug( $ticket_id ) { |
|
| 484 | - if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'Plugin' . $ticket_id, self::$forced_tickets ) ) |
|
| 483 | + function knownPluginBug($ticket_id) { |
|
| 484 | + if (WP_TESTS_FORCE_KNOWN_BUGS || in_array('Plugin'.$ticket_id, self::$forced_tickets)) |
|
| 485 | 485 | return; |
| 486 | - if ( ! TracTickets::isTracTicketClosed( 'https://plugins.trac.wordpress.org', $ticket_id ) ) |
|
| 487 | - $this->markTestSkipped( sprintf( 'WordPress Plugin Ticket #%d is not fixed', $ticket_id ) ); |
|
| 486 | + if (!TracTickets::isTracTicketClosed('https://plugins.trac.wordpress.org', $ticket_id)) |
|
| 487 | + $this->markTestSkipped(sprintf('WordPress Plugin Ticket #%d is not fixed', $ticket_id)); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - public static function forceTicket( $ticket ) { |
|
| 490 | + public static function forceTicket($ticket) { |
|
| 491 | 491 | self::$forced_tickets[] = $ticket; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | /** |
| 495 | 495 | * Define constants after including files. |
| 496 | 496 | */ |
| 497 | - function prepareTemplate( Text_Template $template ) { |
|
| 498 | - $template->setVar( array( 'constants' => '' ) ); |
|
| 499 | - $template->setVar( array( 'wp_constants' => PHPUnit_Util_GlobalState::getConstantsAsString() ) ); |
|
| 500 | - parent::prepareTemplate( $template ); |
|
| 497 | + function prepareTemplate(Text_Template $template) { |
|
| 498 | + $template->setVar(array('constants' => '')); |
|
| 499 | + $template->setVar(array('wp_constants' => PHPUnit_Util_GlobalState::getConstantsAsString())); |
|
| 500 | + parent::prepareTemplate($template); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | /** |
@@ -505,17 +505,17 @@ discard block |
||
| 505 | 505 | */ |
| 506 | 506 | function temp_filename() { |
| 507 | 507 | $tmp_dir = ''; |
| 508 | - $dirs = array( 'TMP', 'TMPDIR', 'TEMP' ); |
|
| 509 | - foreach( $dirs as $dir ) |
|
| 510 | - if ( isset( $_ENV[$dir] ) && !empty( $_ENV[$dir] ) ) { |
|
| 508 | + $dirs = array('TMP', 'TMPDIR', 'TEMP'); |
|
| 509 | + foreach ($dirs as $dir) |
|
| 510 | + if (isset($_ENV[$dir]) && !empty($_ENV[$dir])) { |
|
| 511 | 511 | $tmp_dir = $dir; |
| 512 | 512 | break; |
| 513 | 513 | } |
| 514 | - if ( empty( $tmp_dir ) ) { |
|
| 514 | + if (empty($tmp_dir)) { |
|
| 515 | 515 | $tmp_dir = '/tmp'; |
| 516 | 516 | } |
| 517 | - $tmp_dir = realpath( $tmp_dir ); |
|
| 518 | - return tempnam( $tmp_dir, 'wpunit' ); |
|
| 517 | + $tmp_dir = realpath($tmp_dir); |
|
| 518 | + return tempnam($tmp_dir, 'wpunit'); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | /** |
@@ -564,43 +564,43 @@ discard block |
||
| 564 | 564 | $passed = true; |
| 565 | 565 | $not_false = $not_true = array(); // properties that were not set to expected values |
| 566 | 566 | |
| 567 | - foreach ( $all as $query_thing ) { |
|
| 568 | - $result = is_callable( $query_thing ) ? call_user_func( $query_thing ) : $wp_query->{$query_thing}; |
|
| 567 | + foreach ($all as $query_thing) { |
|
| 568 | + $result = is_callable($query_thing) ? call_user_func($query_thing) : $wp_query->{$query_thing}; |
|
| 569 | 569 | |
| 570 | - if ( in_array( $query_thing, $true ) ) { |
|
| 571 | - if ( ! $result ) { |
|
| 572 | - array_push( $not_true, $query_thing ); |
|
| 570 | + if (in_array($query_thing, $true)) { |
|
| 571 | + if (!$result) { |
|
| 572 | + array_push($not_true, $query_thing); |
|
| 573 | 573 | $passed = false; |
| 574 | 574 | } |
| 575 | - } else if ( $result ) { |
|
| 576 | - array_push( $not_false, $query_thing ); |
|
| 575 | + } else if ($result) { |
|
| 576 | + array_push($not_false, $query_thing); |
|
| 577 | 577 | $passed = false; |
| 578 | 578 | } |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | $message = ''; |
| 582 | - if ( count($not_true) ) |
|
| 583 | - $message .= implode( $not_true, ', ' ) . ' is expected to be true. '; |
|
| 584 | - if ( count($not_false) ) |
|
| 585 | - $message .= implode( $not_false, ', ' ) . ' is expected to be false.'; |
|
| 586 | - $this->assertTrue( $passed, $message ); |
|
| 582 | + if (count($not_true)) |
|
| 583 | + $message .= implode($not_true, ', ').' is expected to be true. '; |
|
| 584 | + if (count($not_false)) |
|
| 585 | + $message .= implode($not_false, ', ').' is expected to be false.'; |
|
| 586 | + $this->assertTrue($passed, $message); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - function unlink( $file ) { |
|
| 590 | - $exists = is_file( $file ); |
|
| 591 | - if ( $exists && ! in_array( $file, self::$ignore_files ) ) { |
|
| 589 | + function unlink($file) { |
|
| 590 | + $exists = is_file($file); |
|
| 591 | + if ($exists && !in_array($file, self::$ignore_files)) { |
|
| 592 | 592 | //error_log( $file ); |
| 593 | - unlink( $file ); |
|
| 594 | - } elseif ( ! $exists ) { |
|
| 595 | - $this->fail( "Trying to delete a file that doesn't exist: $file" ); |
|
| 593 | + unlink($file); |
|
| 594 | + } elseif (!$exists) { |
|
| 595 | + $this->fail("Trying to delete a file that doesn't exist: $file"); |
|
| 596 | 596 | } |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - function rmdir( $path ) { |
|
| 600 | - $files = $this->files_in_dir( $path ); |
|
| 601 | - foreach ( $files as $file ) { |
|
| 602 | - if ( ! in_array( $file, self::$ignore_files ) ) { |
|
| 603 | - $this->unlink( $file ); |
|
| 599 | + function rmdir($path) { |
|
| 600 | + $files = $this->files_in_dir($path); |
|
| 601 | + foreach ($files as $file) { |
|
| 602 | + if (!in_array($file, self::$ignore_files)) { |
|
| 603 | + $this->unlink($file); |
|
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | 606 | } |
@@ -608,16 +608,16 @@ discard block |
||
| 608 | 608 | function remove_added_uploads() { |
| 609 | 609 | // Remove all uploads. |
| 610 | 610 | $uploads = wp_upload_dir(); |
| 611 | - $this->rmdir( $uploads['basedir'] ); |
|
| 611 | + $this->rmdir($uploads['basedir']); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | - function files_in_dir( $dir ) { |
|
| 614 | + function files_in_dir($dir) { |
|
| 615 | 615 | $files = array(); |
| 616 | 616 | |
| 617 | - $iterator = new RecursiveDirectoryIterator( $dir ); |
|
| 618 | - $objects = new RecursiveIteratorIterator( $iterator ); |
|
| 619 | - foreach ( $objects as $name => $object ) { |
|
| 620 | - if ( is_file( $name ) ) { |
|
| 617 | + $iterator = new RecursiveDirectoryIterator($dir); |
|
| 618 | + $objects = new RecursiveIteratorIterator($iterator); |
|
| 619 | + foreach ($objects as $name => $object) { |
|
| 620 | + if (is_file($name)) { |
|
| 621 | 621 | $files[] = $name; |
| 622 | 622 | } |
| 623 | 623 | } |
@@ -627,33 +627,33 @@ discard block |
||
| 627 | 627 | |
| 628 | 628 | function scan_user_uploads() { |
| 629 | 629 | static $files = array(); |
| 630 | - if ( ! empty( $files ) ) { |
|
| 630 | + if (!empty($files)) { |
|
| 631 | 631 | return $files; |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | $uploads = wp_upload_dir(); |
| 635 | - $files = $this->files_in_dir( $uploads['basedir'] ); |
|
| 635 | + $files = $this->files_in_dir($uploads['basedir']); |
|
| 636 | 636 | return $files; |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - function delete_folders( $path ) { |
|
| 639 | + function delete_folders($path) { |
|
| 640 | 640 | $this->matched_dirs = array(); |
| 641 | - if ( ! is_dir( $path ) ) { |
|
| 641 | + if (!is_dir($path)) { |
|
| 642 | 642 | return; |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - $this->scandir( $path ); |
|
| 646 | - foreach ( array_reverse( $this->matched_dirs ) as $dir ) { |
|
| 647 | - rmdir( $dir ); |
|
| 645 | + $this->scandir($path); |
|
| 646 | + foreach (array_reverse($this->matched_dirs) as $dir) { |
|
| 647 | + rmdir($dir); |
|
| 648 | 648 | } |
| 649 | - rmdir( $path ); |
|
| 649 | + rmdir($path); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - function scandir( $dir ) { |
|
| 653 | - foreach ( scandir( $dir ) as $path ) { |
|
| 654 | - if ( 0 !== strpos( $path, '.' ) && is_dir( $dir . '/' . $path ) ) { |
|
| 655 | - $this->matched_dirs[] = $dir . '/' . $path; |
|
| 656 | - $this->scandir( $dir . '/' . $path ); |
|
| 652 | + function scandir($dir) { |
|
| 653 | + foreach (scandir($dir) as $path) { |
|
| 654 | + if (0 !== strpos($path, '.') && is_dir($dir.'/'.$path)) { |
|
| 655 | + $this->matched_dirs[] = $dir.'/'.$path; |
|
| 656 | + $this->scandir($dir.'/'.$path); |
|
| 657 | 657 | } |
| 658 | 658 | } |
| 659 | 659 | } |
@@ -661,9 +661,9 @@ discard block |
||
| 661 | 661 | /** |
| 662 | 662 | * Helper to Convert a microtime string into a float |
| 663 | 663 | */ |
| 664 | - protected function _microtime_to_float($microtime ){ |
|
| 665 | - $time_array = explode( ' ', $microtime ); |
|
| 666 | - return array_sum( $time_array ); |
|
| 664 | + protected function _microtime_to_float($microtime) { |
|
| 665 | + $time_array = explode(' ', $microtime); |
|
| 666 | + return array_sum($time_array); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | /** |
@@ -671,11 +671,11 @@ discard block |
||
| 671 | 671 | * |
| 672 | 672 | * @since 4.3.0 |
| 673 | 673 | */ |
| 674 | - public static function delete_user( $user_id ) { |
|
| 675 | - if ( is_multisite() ) { |
|
| 676 | - return wpmu_delete_user( $user_id ); |
|
| 674 | + public static function delete_user($user_id) { |
|
| 675 | + if (is_multisite()) { |
|
| 676 | + return wpmu_delete_user($user_id); |
|
| 677 | 677 | } else { |
| 678 | - return wp_delete_user( $user_id ); |
|
| 678 | + return wp_delete_user($user_id); |
|
| 679 | 679 | } |
| 680 | 680 | } |
| 681 | 681 | |
@@ -688,36 +688,36 @@ discard block |
||
| 688 | 688 | * |
| 689 | 689 | * @param string $structure Optional. Permalink structure to set. Default empty. |
| 690 | 690 | */ |
| 691 | - public function set_permalink_structure( $structure = '' ) { |
|
| 691 | + public function set_permalink_structure($structure = '') { |
|
| 692 | 692 | global $wp_rewrite; |
| 693 | 693 | |
| 694 | 694 | $wp_rewrite->init(); |
| 695 | - $wp_rewrite->set_permalink_structure( $structure ); |
|
| 695 | + $wp_rewrite->set_permalink_structure($structure); |
|
| 696 | 696 | $wp_rewrite->flush_rules(); |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | function _make_attachment($upload, $parent_post_id = 0) { |
| 700 | 700 | $type = ''; |
| 701 | - if ( !empty($upload['type']) ) { |
|
| 701 | + if (!empty($upload['type'])) { |
|
| 702 | 702 | $type = $upload['type']; |
| 703 | 703 | } else { |
| 704 | - $mime = wp_check_filetype( $upload['file'] ); |
|
| 704 | + $mime = wp_check_filetype($upload['file']); |
|
| 705 | 705 | if ($mime) |
| 706 | 706 | $type = $mime['type']; |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | $attachment = array( |
| 710 | - 'post_title' => basename( $upload['file'] ), |
|
| 710 | + 'post_title' => basename($upload['file']), |
|
| 711 | 711 | 'post_content' => '', |
| 712 | 712 | 'post_type' => 'attachment', |
| 713 | 713 | 'post_parent' => $parent_post_id, |
| 714 | 714 | 'post_mime_type' => $type, |
| 715 | - 'guid' => $upload[ 'url' ], |
|
| 715 | + 'guid' => $upload['url'], |
|
| 716 | 716 | ); |
| 717 | 717 | |
| 718 | 718 | // Save the data |
| 719 | - $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent_post_id ); |
|
| 720 | - wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); |
|
| 719 | + $id = wp_insert_attachment($attachment, $upload['file'], $parent_post_id); |
|
| 720 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $upload['file'])); |
|
| 721 | 721 | return $id; |
| 722 | 722 | } |
| 723 | 723 | } |