| @@ -1,7 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -define( 'FWP_BOLD_PREFIX_REGEX', '/^[*][*] ([^*]+) [*][*] \s+ (\S.*)$/x' ); | |
| 3 | - | |
| 4 | 2 | /** |
| 5 | 3 | * class FeedWordPressAdminPage |
| 6 | 4 | * |
| 7 | 5 | * Handles a lot of the interface-code related jots and tittles for putting together |
| @@ -14,19 +12,17 @@ | ||
| 14 | 12 | protected $context; |
| 15 | 13 | protected $updated = false; |
| 16 | 14 | protected $mesg = NULL; |
| 17 | 15 | |
| 18 | - /** @var SyndicatedLink|null An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings. */ | |
| 19 | 16 | var $link = NULL; |
| 20 | 17 | var $dispatch = NULL; |
| 21 | 18 | var $filename = NULL; |
| 22 | 19 | var $pagenames = array(); |
| 23 | - var $boxes_by_methods = array(); // did I delete this by mistake? (gwyneth 20230920) | |
| 24 | 20 | |
| 25 | 21 | /** |
| 26 | 22 | * Construct the admin page object. |
| 27 | 23 | * |
| 28 | - * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings. | |
| 24 | + * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings | |
| 29 | 25 | */ |
| 30 | 26 | public function __construct( $page = 'feedwordpressadmin', $link = NULL ) { |
| 31 | 27 | $this->link = $link; |
| 32 | 28 | |
| @@ -31,9 +27,9 @@ | ||
| 31 | 27 | $this->link = $link; |
| 32 | 28 | |
| 33 | 29 | // Set meta-box context name |
| 34 | 30 | $this->context = $page; |
| 35 | - if ( $this->for_feed_settings() ) : | |
| 31 | + if ($this->for_feed_settings()) : | |
| 36 | 32 | $this->context .= 'forfeed'; |
| 37 | 33 | endif; |
| 38 | 34 | } /* FeedWordPressAdminPage constructor */ |
| 39 | 35 | |
| @@ -48,9 +44,9 @@ | ||
| 48 | 44 | endif; |
| 49 | 45 | |
| 50 | 46 | if (isset($this->pagenames[$context])) : |
| 51 | 47 | $name = $this->pagenames[$context]; |
| 52 | - elseif (isset($this->pagenames['default'])) : | |
| 48 | + elseif (isset($tis->pagenames['default'])) : | |
| 53 | 49 | $name = $this->pagenames['default']; |
| 54 | 50 | else : |
| 55 | 51 | $name = $this->pageslug(); |
| 56 | 52 | endif; |
| @@ -56,19 +52,18 @@ | ||
| 56 | 52 | endif; |
| 57 | 53 | return __($name); |
| 58 | 54 | } /* FeedWordPressAdminPage::pagename () */ |
| 59 | 55 | |
| 60 | - public function accept_POST () { | |
| 61 | - if ( $this->for_feed_settings() and $this->update_requested() ) : | |
| 56 | + public function accept_POST ($post) { | |
| 57 | + if ($this->for_feed_settings() and $this->update_requested_in($post)) : | |
| 62 | 58 | $this->update_feed(); |
| 63 | - elseif ($this->save_requested()) : // User mashed Save Changes | |
| 64 | - $this->save_settings(); | |
| 59 | + elseif ($this->save_requested_in($post)) : // User mashed Save Changes | |
| 60 | + $this->save_settings($post); | |
| 65 | 61 | endif; |
| 66 | - do_action($this->dispatch.'_post', null, $this); | |
| 62 | + do_action($this->dispatch.'_post', $post, $this); | |
| 67 | 63 | } |
| 68 | 64 | |
| 69 | - | |
| 70 | - public function update_feed() { | |
| 65 | + public function update_feed () { | |
| 71 | 66 | global $feedwordpress; |
| 72 | 67 | |
| 73 | 68 | add_action('feedwordpress_check_feed', 'update_feeds_mention'); |
| 74 | 69 | add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3); |
| @@ -73,9 +68,9 @@ | ||
| 73 | 68 | add_action('feedwordpress_check_feed', 'update_feeds_mention'); |
| 74 | 69 | add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3); |
| 75 | 70 | |
| 76 | 71 | $link = $this->link; |
| 77 | - | |
| 72 | + | |
| 78 | 73 | print '<div class="updated">'; |
| 79 | 74 | print "<ul>"; |
| 80 | 75 | $uri = $this->link->uri(); |
| 81 | 76 | $displayUrl = $uri; |
| @@ -86,14 +81,14 @@ | ||
| 86 | 81 | |
| 87 | 82 | $delta = $feedwordpress->update($uri); |
| 88 | 83 | print "</ul>"; |
| 89 | 84 | |
| 90 | - if ( !is_null($delta)) : | |
| 91 | - echo "<p><strong>Update complete.</strong>".esc_html( fwp_update_set_results_message($delta) )."</p>"; | |
| 85 | + if (!is_null($delta)) : | |
| 86 | + echo "<p><strong>Update complete.</strong>".fwp_update_set_results_message($delta)."</p>"; | |
| 92 | 87 | echo "\n"; flush(); |
| 93 | 88 | else : |
| 94 | 89 | $effectiveUrl = esc_html($effectiveUrl); |
| 95 | - echo '<p><strong>Error:</strong> There was a problem updating <a href="' . esc_url( $effectiveUrl ) . '">' . esc_html( $displayUrl ) . '</a></p>' . "\n"; | |
| 90 | + echo "<p><strong>Error:</strong> There was a problem updating <a href=\"$effectiveUrl\">$displayUrl</a></p>\n"; | |
| 96 | 91 | endif; |
| 97 | 92 | print "</div>\n"; |
| 98 | 93 | remove_action('feedwordpress_check_feed', 'update_feeds_mention'); |
| 99 | 94 | remove_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3); |
| @@ -98,10 +93,10 @@ | ||
| 98 | 93 | remove_action('feedwordpress_check_feed', 'update_feeds_mention'); |
| 99 | 94 | remove_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3); |
| 100 | 95 | } |
| 101 | 96 | |
| 102 | - public function save_settings () { | |
| 103 | - do_action($this->dispatch.'_save', null, $this); | |
| 97 | + public function save_settings ($post) { | |
| 98 | + do_action($this->dispatch.'_save', $post, $this); | |
| 104 | 99 | |
| 105 | 100 | if ($this->for_feed_settings()) : |
| 106 | 101 | // Save settings |
| 107 | 102 | $this->link->save_settings(/*reload=*/ true); |
| @@ -115,93 +110,63 @@ | ||
| 115 | 110 | $this->updated = true; |
| 116 | 111 | endif; |
| 117 | 112 | } /* FeedWordPressAdminPage::save_settings () */ |
| 118 | 113 | |
| 114 | + public function for_feed_settings () { return (is_object($this->link) and method_exists($this->link, 'found') and $this->link->found()); } | |
| 115 | + public function for_default_settings () { return !$this->for_feed_settings(); } | |
| 119 | 116 | |
| 120 | - public function for_feed_settings() { | |
| 121 | - return ( is_object( $this->link ) and method_exists( $this->link, 'found' ) and $this->link->found() ); | |
| 122 | - } /* FeedWordPressAdminPage */ | |
| 123 | - | |
| 124 | - public function for_default_settings () { | |
| 125 | - return ! $this->for_feed_settings(); | |
| 126 | - } /* FeedWordPressAdminPage */ | |
| 127 | - | |
| 128 | - /** | |
| 129 | - * Attempts to retrieve a setting for a feed. | |
| 130 | - * | |
| 131 | - * @param string|array $names Either a string with the name of the feed, | |
| 132 | - * or an associative array where the 'feed' parameter | |
| 133 | - * indicates the feed. | |
| 134 | - * @param string|null $fallback_value Fallback option value, if everything fails. | |
| 135 | - * @param Array $params List of attributes. | |
| 136 | - * | |
| 137 | - * @return mixed Retrieved option from settings. | |
| 138 | - */ | |
| 139 | - public function setting( $names, $fallback_value = NULL, $params = array() ) { | |
| 140 | - if ( ! is_array( $params ) ) : | |
| 141 | - $params = array( 'default' => $params ); | |
| 117 | + public function setting ($names, $fallback_value = NULL, $params = array()) { | |
| 118 | + if (!is_array($params)) : | |
| 119 | + $params = array('default' => $params); | |
| 142 | 120 | endif; |
| 143 | - $params = shortcode_atts( array( | |
| 144 | - 'default' => 'default', | |
| 145 | - 'fallback' => true, | |
| 146 | - ), | |
| 147 | - $params ); | |
| 121 | + $params = shortcode_atts(array( | |
| 122 | + 'default' => 'default', | |
| 123 | + 'fallback' => true, | |
| 124 | + ), $params); | |
| 148 | 125 | |
| 149 | - if ( is_string( $names ) ) : | |
| 150 | - $feed_name = $names; | |
| 151 | - $global_name = 'feedwordpress_' . preg_replace( '![\s/]+!', '_', $names ); | |
| 126 | + if (is_string($names)) : | |
| 127 | + $feed_name = $names; | |
| 128 | + $global_name = 'feedwordpress_'.preg_replace('![\s/]+!', '_', $names); | |
| 152 | 129 | else : |
| 153 | - $feed_name = $names['feed']; | |
| 154 | - $global_name = 'feedwordpress_' . $names['global']; | |
| 130 | + $feed_name = $names['feed']; | |
| 131 | + $global_name = 'feedwordpress_'.$names['global']; | |
| 155 | 132 | endif; |
| 156 | 133 | |
| 157 | - if ( $this->for_feed_settings() ) : // Check feed-specific setting first; fall back to global | |
| 158 | - if ( ! $params['fallback'] ) : | |
| 159 | - $global_name = NULL; | |
| 160 | - endif; | |
| 161 | - $ret = $this->link->setting( $feed_name, $global_name, $fallback_value, $params['default'] ); | |
| 134 | + if ($this->for_feed_settings()) : // Check feed-specific setting first; fall back to global | |
| 135 | + if (!$params['fallback']) : $global_name = NULL; endif; | |
| 136 | + $ret = $this->link->setting($feed_name, $global_name, $fallback_value, $params['default']); | |
| 162 | 137 | else : // Check global setting |
| 163 | - $ret = get_option( $global_name, $fallback_value ); | |
| 138 | + $ret = get_option($global_name, $fallback_value); | |
| 164 | 139 | endif; |
| 165 | 140 | return $ret; |
| 166 | - } /* FeedWordPressAdminPage::setting() */ | |
| 141 | + } | |
| 167 | 142 | |
| 168 | - /** | |
| 169 | - * Updates feed settings. | |
| 170 | - * | |
| 171 | - * @see setting() | |
| 172 | - * | |
| 173 | - * @param string|array $names Either a string with the name of the feed, | |
| 174 | - * or an associative array where the 'global' parameter | |
| 175 | - * indicates the feed. | |
| 176 | - * @param string|null $value Setting value to update. | |
| 177 | - * @param string $default Setting default option (defaults to 'default'). | |
| 178 | - */ | |
| 179 | - public function update_setting( $names, $value, $default = 'default' ) { | |
| 180 | - if ( is_string( $names ) ) : | |
| 181 | - $feed_name = $names; | |
| 182 | - $global_name = 'feedwordpress_' . preg_replace( '![\s/]+!', '_', $names ); | |
| 143 | + public function update_setting ($names, $value, $default = 'default') { | |
| 144 | + if (is_string($names)) : | |
| 145 | + $feed_name = $names; | |
| 146 | + $global_name = 'feedwordpress_'.preg_replace('![\s/]+!', '_', $names); | |
| 183 | 147 | else : |
| 184 | - $feed_name = $names['feed']; | |
| 185 | - $global_name = 'feedwordpress_' . $names['global']; | |
| 148 | + $feed_name = $names['feed']; | |
| 149 | + $global_name = 'feedwordpress_'.$names['global']; | |
| 186 | 150 | endif; |
| 187 | 151 | |
| 188 | - if ( $this->for_feed_settings() ) : // Update feed-specific setting | |
| 189 | - $this->link->update_setting( $feed_name, $value, $default ); | |
| 152 | + if ($this->for_feed_settings()) : // Update feed-specific setting | |
| 153 | + $this->link->update_setting($feed_name, $value, $default); | |
| 190 | 154 | else : // Update global setting |
| 191 | - update_option( $global_name, $value ); | |
| 155 | + update_option($global_name, $value); | |
| 192 | 156 | endif; |
| 193 | - } /* FeedWordPressAdminPage::update_setting() */ | |
| 157 | + } /* FeedWordPressAdminPage::update_setting () */ | |
| 194 | 158 | |
| 195 | - public function save_requested() { | |
| 196 | - return ! ( is_null( MyPHP::post('save') ) && is_null( MyPHP::post('submit') ) ); | |
| 159 | + public function save_requested_in ($post) { | |
| 160 | + return (isset($post['save']) or isset($post['submit'])); | |
| 197 | 161 | } |
| 162 | + public function update_requested_in ($post) { | |
| 163 | + return (isset($post['update']) and (strlen($post['update']) > 0)); | |
| 164 | + } | |
| 198 | 165 | |
| 199 | - public function update_requested() { | |
| 200 | - return ( strlen( MyPHP::post('update', '') ) > 0 ); | |
| 201 | - } | |
| 166 | + public function submitted_link_id () { | |
| 167 | + global $fwp_post; | |
| 202 | 168 | |
| 203 | - public function submitted_link_id() { | |
| 204 | 169 | // Presume global unless we get a specific link ID |
| 205 | 170 | $link_id = NULL; |
| 206 | 171 | |
| 207 | 172 | $submit_buttons = array( |
| @@ -210,15 +175,15 @@ | ||
| 210 | 175 | 'fix_mismatch', |
| 211 | 176 | 'feedfinder', |
| 212 | 177 | ); |
| 213 | 178 | foreach ($submit_buttons as $field) : |
| 214 | - if ( ! is_null( MyPHP::request($field) ) ) : | |
| 215 | - $link_id = sanitize_text_field( MyPHP::request('save_link_id') ); | |
| 179 | + if (isset($fwp_post[$field])) : | |
| 180 | + $link_id = MyPHP::request('save_link_id'); | |
| 216 | 181 | endif; |
| 217 | 182 | endforeach; |
| 218 | 183 | |
| 219 | - if ( is_null($link_id) ) : | |
| 220 | - $link_id = sanitize_text_field( MyPHP::request( 'link_id' ) ); | |
| 184 | + if (is_null($link_id) and isset($_REQUEST['link_id'])) : | |
| 185 | + $link_id = MyPHP::request('link_id'); | |
| 221 | 186 | endif; |
| 222 | 187 | |
| 223 | 188 | return $link_id; |
| 224 | 189 | } /* FeedWordPressAdminPage::submitted_link_id() */ |
| @@ -235,24 +200,17 @@ | ||
| 235 | 200 | |
| 236 | 201 | public function stamp_link_id ($field = null) { |
| 237 | 202 | if (is_null($field)) : $field = 'save_link_id'; endif; |
| 238 | 203 | ?> |
| 239 | - <input type="hidden" name="<?php print esc_attr($field); ?>" value="<?php print esc_attr( ($this->for_feed_settings() ? $this->link->id : '*') ); ?>" /> | |
| 204 | + <input type="hidden" name="<?php print esc_attr($field); ?>" value="<?php print ($this->for_feed_settings() ? $this->link->id : '*'); ?>" /> | |
| 240 | 205 | <?php |
| 241 | 206 | } /* FeedWordPressAdminPage::stamp_link_id () */ |
| 242 | 207 | |
| 243 | - /** | |
| 244 | - * Returns a short explanation of what posts we have here, | |
| 245 | - * either posts from this feed or syndicated posts. | |
| 246 | - * | |
| 247 | - * @return string True corresponds to posts from this feed, | |
| 248 | - * false to syndicated posts. | |
| 249 | - */ | |
| 250 | - public function these_posts_phrase() { | |
| 251 | - if ( $this->for_feed_settings() ) : | |
| 252 | - $phrase = __( 'posts from this feed' ); | |
| 208 | + public function these_posts_phrase () { | |
| 209 | + if ($this->for_feed_settings()) : | |
| 210 | + $phrase = __('posts from this feed'); | |
| 253 | 211 | else : |
| 254 | - $phrase = __( 'syndicated posts' ); | |
| 212 | + $phrase = __('syndicated posts'); | |
| 255 | 213 | endif; |
| 256 | 214 | return $phrase; |
| 257 | 215 | } /* FeedWordPressAdminPage::these_posts_phrase() */ |
| 258 | 216 | |
| @@ -264,9 +222,9 @@ | ||
| 264 | 222 | * |
| 265 | 223 | * @see add_meta_box() |
| 266 | 224 | * @see do_meta_boxes() |
| 267 | 225 | */ |
| 268 | - public function meta_box_context() { | |
| 226 | + public function meta_box_context () { | |
| 269 | 227 | return $this->context; |
| 270 | 228 | } /* FeedWordPressAdminPage::meta_box_context () */ |
| 271 | 229 | |
| 272 | 230 | /** |
| @@ -284,9 +242,9 @@ | ||
| 284 | 242 | if (typeof(visibleStyle)=='undefined') visibleStyle = 'block'; |
| 285 | 243 | |
| 286 | 244 | var rollup=document.getElementById(item); |
| 287 | 245 | if (rollup) { |
| 288 | - if ((checkbox && rollup.checked) || ( !checkbox && value==rollup.value)) { | |
| 246 | + if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) { | |
| 289 | 247 | jQuery('#'+disappear).hide(); |
| 290 | 248 | jQuery('#'+appear).show(600); |
| 291 | 249 | } else { |
| 292 | 250 | jQuery('#'+appear).hide(); |
| @@ -303,9 +261,9 @@ | ||
| 303 | 261 | // Merge in the page's filename |
| 304 | 262 | $params = array_merge($params, array('page' => $fwp_path.'/'.$page)); |
| 305 | 263 | |
| 306 | 264 | // If there is a link ID provided, then merge that in too. |
| 307 | - if ( !is_null($link)) : | |
| 265 | + if (!is_null($link)) : | |
| 308 | 266 | $link_id = NULL; |
| 309 | 267 | if (is_object($link)) : |
| 310 | 268 | if (method_exists($link, 'found')) : |
| 311 | 269 | // Is this a SyndicatedLink object? |
| @@ -320,9 +278,9 @@ | ||
| 320 | 278 | // Is this just a numeric ID? |
| 321 | 279 | $link_id = $link; |
| 322 | 280 | endif; |
| 323 | 281 | |
| 324 | - if ( !is_null($link_id)) : | |
| 282 | + if (!is_null($link_id)) : | |
| 325 | 283 | $params = array_merge($params, array('link_id' => $link_id)); |
| 326 | 284 | endif; |
| 327 | 285 | endif; |
| 328 | 286 | |
| @@ -329,8 +287,10 @@ | ||
| 329 | 287 | return MyPHP::url(admin_url('admin.php'), $params); |
| 330 | 288 | } /* FeedWordPressAdminPage::admin_page_href () */ |
| 331 | 289 | |
| 332 | 290 | public function display_feed_settings_page_links ($params = array()) { |
| 291 | + global $fwp_path; | |
| 292 | + | |
| 333 | 293 | $params = wp_parse_args($params, array( |
| 334 | 294 | 'before' => '', |
| 335 | 295 | 'between' => ' | ', |
| 336 | 296 | 'after' => '', |
| @@ -356,11 +316,11 @@ | ||
| 356 | 316 | $link_id = $sub->link_id; |
| 357 | 317 | endif; |
| 358 | 318 | endif; |
| 359 | 319 | |
| 360 | - $out_html = $params['before']; $first = true; | |
| 320 | + print $params['before']; $first = true; | |
| 361 | 321 | foreach ($links as $label => $link) : |
| 362 | - if ( ! $first) : $out_html .= $params['between']; endif; | |
| 322 | + if (!$first) : print $params['between']; endif; | |
| 363 | 323 | |
| 364 | 324 | if (isset($link['url'])) : MyPHP::url($link['url'], array("link_id" => $link_id)); |
| 365 | 325 | else : $url = $this->admin_page_href($link['page'], array(), $sub); |
| 366 | 326 | endif; |
| @@ -366,28 +326,26 @@ | ||
| 366 | 326 | endif; |
| 367 | 327 | $url = esc_html($url); |
| 368 | 328 | |
| 369 | 329 | if ($link['page']==basename($this->filename)) : |
| 370 | - $out_html .= "<strong>"; | |
| 330 | + print "<strong>"; | |
| 371 | 331 | else : |
| 372 | - $out_html .= sprintf( '<a href="%s">', esc_url( $url ) ); | |
| 332 | + print "<a href=\"${url}\">"; | |
| 373 | 333 | endif; |
| 374 | 334 | |
| 375 | - if ($params['long']) : $out_html .= esc_html(__($link['long'])); | |
| 376 | - else : $out_html .= esc_html(__($label)); | |
| 335 | + if ($params['long']) : print esc_html(__($link['long'])); | |
| 336 | + else : print esc_html(__($label)); | |
| 377 | 337 | endif; |
| 378 | 338 | |
| 379 | 339 | if ($link['page']==basename($this->filename)) : |
| 380 | - $out_html .= "</strong>"; | |
| 340 | + print "</strong>"; | |
| 381 | 341 | else : |
| 382 | - $out_html .= "</a>"; | |
| 342 | + print "</a>"; | |
| 383 | 343 | endif; |
| 384 | 344 | |
| 385 | 345 | $first = false; |
| 386 | 346 | endforeach; |
| 387 | - $out_html .= $params['after']; | |
| 388 | - | |
| 389 | - print wp_kses( $out_html, 'post' ); | |
| 347 | + print $params['after']; | |
| 390 | 348 | } /* FeedWordPressAdminPage::display_feed_settings_page_links */ |
| 391 | 349 | |
| 392 | 350 | public function display_feed_select_dropdown() { |
| 393 | 351 | $links = FeedWordPress::syndicated_links(); |
| @@ -396,12 +354,12 @@ | ||
| 396 | 354 | <div id="fwpfs-container"><ul class="subsubsub"> |
| 397 | 355 | <li><select name="link_id" class="fwpfs" style="max-width: 20.0em;"> |
| 398 | 356 | <option value="*"<?php if ($this->for_default_settings()) : ?> selected="selected"<?php endif; ?>>- defaults for all feeds -</option> |
| 399 | 357 | <?php if ($links) : foreach ($links as $ddlink) : ?> |
| 400 | - <option value="<?php print (int) $ddlink->link_id; ?>"<?php if ( !is_null($this->link) and ($this->link->id==$ddlink->link_id)) : ?> selected="selected"<?php endif; ?>><?php print esc_html($ddlink->link_name); ?></option> | |
| 358 | + <option value="<?php print (int) $ddlink->link_id; ?>"<?php if (!is_null($this->link) and ($this->link->id==$ddlink->link_id)) : ?> selected="selected"<?php endif; ?>><?php print esc_html($ddlink->link_name); ?></option> | |
| 401 | 359 | <?php endforeach; endif; ?> |
| 402 | 360 | </select> |
| 403 | - <input id="fwpfs-button" class="button" type="submit" name="go" value="<?php esc_attr_e('Go') ?> »" /></li> | |
| 361 | + <input id="fwpfs-button" class="button" type="submit" name="go" value="<?php _e('Go') ?> »" /></li> | |
| 404 | 362 | |
| 405 | 363 | <?php |
| 406 | 364 | $this->display_feed_settings_page_links(array( |
| 407 | 365 | 'before' => '<li>', |
| @@ -420,26 +378,17 @@ | ||
| 420 | 378 | </div> |
| 421 | 379 | <?php |
| 422 | 380 | } /* FeedWordPressAdminPage::display_feed_select_dropdown() */ |
| 423 | 381 | |
| 424 | - /** | |
| 425 | - * Displays a header section throughout the FWP dashboard. | |
| 426 | - * | |
| 427 | - * @param string $pagename Page name for which this header is. | |
| 428 | - * @param bool $all False if it displays just the settings; true if it displays all. | |
| 429 | - */ | |
| 430 | - public function display_sheet_header( $pagename = 'Syndication', $all = false ) { | |
| 431 | - /* changed to use a SVG instead, while keeping the correct size. | |
| 432 | - Note that these icons have been deprecated in 2013 or so: | |
| 433 | - @see https://core.trac.wordpress.org/ticket/26119 */ | |
| 382 | + public function display_sheet_header ($pagename = 'Syndication', $all = false) { | |
| 434 | 383 | ?> |
| 435 | - <div class="icon32"><img src="<?php print esc_attr( plugins_url( 'assets/images/icon.svg', __FILE__ ) ); ?>" alt="FeedWordPress Logo" /></div> | |
| 436 | - <h2><?php print esc_html( __( $pagename . ( $all ? '' : ' Settings' ) ) ); ?><?php if ( $this->for_feed_settings() ) : ?>: <?php echo esc_html( $this->link->name( /*from feed=*/ false ) ); ?><?php endif; ?></h2> | |
| 384 | + <div class="icon32"><img src="<?php print esc_attr( plugins_url( 'feedwordpress.png', __FILE__ ) ); ?>" alt="" /></div> | |
| 385 | + <h2><?php print esc_html(__($pagename.($all ? '' : ' Settings'))); ?><?php if ($this->for_feed_settings()) : ?>: <?php echo esc_html($this->link->name(/*from feed=*/ false)); ?><?php endif; ?></h2> | |
| 437 | 386 | <?php |
| 438 | - } /* FeedWordPressAdminPage::display_sheet_header() */ | |
| 387 | + } | |
| 439 | 388 | |
| 440 | - public function display_update_notice_if_updated( $pagename = 'Syndication', $mesg = NULL ) { | |
| 441 | - if ( ! is_null( $mesg ) ) : | |
| 389 | + public function display_update_notice_if_updated ($pagename = 'Syndication', $mesg = NULL) { | |
| 390 | + if (!is_null($mesg)) : | |
| 442 | 391 | $this->mesg = $mesg; |
| 443 | 392 | endif; |
| 444 | 393 | |
| 445 | 394 | if ($this->updated) : |
| @@ -449,9 +398,9 @@ | ||
| 449 | 398 | $this->mesg = $this->updated; |
| 450 | 399 | endif; |
| 451 | 400 | endif; |
| 452 | 401 | |
| 453 | - if ( !is_null($this->mesg)) : | |
| 402 | + if (!is_null($this->mesg)) : | |
| 454 | 403 | ?> |
| 455 | 404 | <div class="updated"> |
| 456 | 405 | <p><?php print esc_html($this->mesg); ?></p> |
| 457 | 406 | </div> |
| @@ -486,8 +435,9 @@ | ||
| 486 | 435 | return $this->mesg; |
| 487 | 436 | } |
| 488 | 437 | |
| 489 | 438 | public function display () { |
| 439 | + global $fwp_post; | |
| 490 | 440 | |
| 491 | 441 | if (FeedWordPress::needs_upgrade()) : |
| 492 | 442 | fwp_upgrade_page(); |
| 493 | 443 | return; |
| @@ -498,9 +448,9 @@ | ||
| 498 | 448 | //////////////////////////////////////////////// |
| 499 | 449 | // Process POST request, if any //////////////// |
| 500 | 450 | //////////////////////////////////////////////// |
| 501 | 451 | if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') : |
| 502 | - $this->accept_POST(); | |
| 452 | + $this->accept_POST($fwp_post); | |
| 503 | 453 | else : |
| 504 | 454 | $this->updated = false; |
| 505 | 455 | endif; |
| 506 | 456 | |
| @@ -529,10 +479,10 @@ | ||
| 529 | 479 | add_meta_box( |
| 530 | 480 | /*id=*/ $id, |
| 531 | 481 | /*title=*/ $title, |
| 532 | 482 | /*callback=*/ array($this, $method), |
| 533 | - /*screen=*/ $this->meta_box_context(), | |
| 534 | - /*context=*/ $this->meta_box_context(), | |
| 483 | + /*page=*/ $this->meta_box_context(), | |
| 484 | + /*context=*/ $this->meta_box_context() | |
| 535 | 485 | ); |
| 536 | 486 | endforeach; |
| 537 | 487 | do_action($this->dispatch.'_meta_boxes', $this); |
| 538 | 488 | ?> |
| @@ -537,9 +487,9 @@ | ||
| 537 | 487 | do_action($this->dispatch.'_meta_boxes', $this); |
| 538 | 488 | ?> |
| 539 | 489 | <div class="metabox-holder"> |
| 540 | 490 | <?php |
| 541 | - do_meta_boxes( $this->meta_box_context(), $this->meta_box_context(), $this ); | |
| 491 | + do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this); | |
| 542 | 492 | ?> |
| 543 | 493 | </div> <!-- class="metabox-holder" --> |
| 544 | 494 | </div> <!-- id="post-body" --> |
| 545 | 495 | <?php $this->close_sheet(); ?> |
| @@ -563,17 +513,17 @@ | ||
| 563 | 513 | ); |
| 564 | 514 | FeedWordPressSettingsUI::ajax_nonce_fields(); |
| 565 | 515 | |
| 566 | 516 | ?> |
| 567 | - <div class="wrap feedwordpress-admin" id="feedwordpress-admin-<?php print esc_attr( $this->pageslug() ); ?>"> | |
| 517 | + <div class="wrap feedwordpress-admin" id="feedwordpress-admin-<?php print $this->pageslug(); ?>"> | |
| 568 | 518 | <?php |
| 569 | - if ( !is_null($header)) : | |
| 519 | + if (!is_null($header)) : | |
| 570 | 520 | $this->display_sheet_header($header); |
| 571 | 521 | endif; |
| 572 | 522 | |
| 573 | - if ( !is_null( $this->dispatch ) ) : | |
| 523 | + if (!is_null($this->dispatch)) : | |
| 574 | 524 | ?> |
| 575 | - <form action="<?php print esc_url( $this->form_action() ); ?>" method="post"> | |
| 525 | + <form action="<?php print $this->form_action(); ?>" method="post"> | |
| 576 | 526 | <div><?php |
| 577 | 527 | FeedWordPressCompatibility::stamp_nonce($this->dispatch); |
| 578 | 528 | $this->stamp_link_id(); |
| 579 | 529 | ?></div> |
| @@ -584,9 +534,9 @@ | ||
| 584 | 534 | $this->display_settings_scope_message(); |
| 585 | 535 | endif; |
| 586 | 536 | |
| 587 | 537 | ?><div class="tablenav"><?php |
| 588 | - if ( !is_null($this->dispatch)) : | |
| 538 | + if (!is_null($this->dispatch)) : | |
| 589 | 539 | ?><div class="alignright"><?php |
| 590 | 540 | $this->save_button(); |
| 591 | 541 | ?></div><?php |
| 592 | 542 | endif; |
| @@ -605,9 +555,9 @@ | ||
| 605 | 555 | ?> |
| 606 | 556 | |
| 607 | 557 | </div> <!-- id="poststuff" --> |
| 608 | 558 | <?php |
| 609 | - if ( !is_null($this->dispatch)) : | |
| 559 | + if (!is_null($this->dispatch)) : | |
| 610 | 560 | $this->save_button(); |
| 611 | 561 | print "</form>\n"; |
| 612 | 562 | endif; |
| 613 | 563 | ?> |
| @@ -616,41 +566,35 @@ | ||
| 616 | 566 | <?php |
| 617 | 567 | } /* FeedWordPressAdminPage::close_sheet () */ |
| 618 | 568 | |
| 619 | 569 | public function setting_radio_control ($localName, $globalName, $options, $params = array()) { |
| 620 | - $params = wp_parse_args( | |
| 621 | - $params, | |
| 622 | - array( | |
| 623 | - 'filename' => basename($this->filename), | |
| 624 | - 'site-wide-url' => null, | |
| 625 | - 'setting-default' => null, | |
| 626 | - 'global-setting-default' => null, | |
| 627 | - 'offer-site-wide' => null, | |
| 628 | - ) | |
| 629 | - ); | |
| 570 | + global $fwp_path; | |
| 630 | 571 | |
| 631 | - $filename = $params['filename']; | |
| 632 | - $href = $params['site-wide-url']; | |
| 633 | - if ( is_null( $href ) ) : | |
| 634 | - $href = $this->admin_page_href( $filename ); | |
| 572 | + if (isset($params['filename'])) : $filename = $params['filename']; | |
| 573 | + else : $filename = basename($this->filename); | |
| 635 | 574 | endif; |
| 636 | 575 | |
| 637 | - $settingDefault = $params['setting-default']; | |
| 638 | - $globalSettingDefault = $params['global-setting-default']; | |
| 639 | - if ( is_null( $globalSettingDefault ) ) : | |
| 640 | - $globalSettingDefault = $settingDefault; | |
| 576 | + if (isset($params['site-wide-url'])) : $href = $params['site-wide-url']; | |
| 577 | + else : $href = $this->admin_page_href($filename); | |
| 641 | 578 | endif; |
| 642 | 579 | |
| 580 | + if (isset($params['setting-default'])) : $settingDefault = $params['setting-default']; | |
| 581 | + else : $settingDefault = NULL; | |
| 582 | + endif; | |
| 583 | + | |
| 584 | + if (isset($params['global-setting-default'])) : $globalSettingDefault = $params['global-setting-default']; | |
| 585 | + else : $globalSettingDefault = $settingDefault; | |
| 586 | + endif; | |
| 587 | + | |
| 643 | 588 | $globalSetting = get_option('feedwordpress_'.$globalName, $globalSettingDefault); |
| 644 | - if ( $this->for_feed_settings() ) : | |
| 589 | + if ($this->for_feed_settings()) : | |
| 645 | 590 | $setting = $this->link->setting($localName, NULL, $settingDefault); |
| 646 | 591 | else : |
| 647 | 592 | $setting = $globalSetting; |
| 648 | 593 | endif; |
| 649 | 594 | |
| 650 | - $offerSiteWide = $params['offer-site-wide']; | |
| 651 | - if ( is_null( $offerSiteWide ) ) : | |
| 652 | - $offerSiteWide = $this->for_feed_settings(); | |
| 595 | + if (isset($params['offer-site-wide'])) : $offerSiteWide = $params['offer-site-wide']; | |
| 596 | + else : $offerSiteWide = $this->for_feed_settings(); | |
| 653 | 597 | endif; |
| 654 | 598 | |
| 655 | 599 | // This allows us to provide an alternative set of human-readable |
| 656 | 600 | // labels for each potential value. For use in Currently: line. |
| @@ -667,9 +611,9 @@ | ||
| 667 | 611 | else : $defaultInputId = NULL; |
| 668 | 612 | endif; |
| 669 | 613 | |
| 670 | 614 | if (isset($params['default-input-id-no'])) : $defaultInputIdNo = $params['default-input-id-no']; |
| 671 | - elseif ( !is_null($defaultInputId)) : $defaultInputIdNo = $defaultInputId.'-no'; | |
| 615 | + elseif (!is_null($defaultInputId)) : $defaultInputIdNo = $defaultInputId.'-no'; | |
| 672 | 616 | else : $defaultInputIdNo = NULL; |
| 673 | 617 | endif; |
| 674 | 618 | |
| 675 | 619 | // This allows us to either include the site-default setting as |
| @@ -691,9 +635,9 @@ | ||
| 691 | 635 | endif; |
| 692 | 636 | |
| 693 | 637 | $settingDefaulted = (is_null($setting) or ($settingDefault === $setting)); |
| 694 | 638 | |
| 695 | - if ( !is_callable($options)) : | |
| 639 | + if (!is_callable($options)) : | |
| 696 | 640 | $checked = array(); |
| 697 | 641 | if ($settingDefaulted) : |
| 698 | 642 | $checked[$defaultInputValue] = ' checked="checked"'; |
| 699 | 643 | endif; |
| @@ -726,26 +670,21 @@ | ||
| 726 | 670 | <tbody> |
| 727 | 671 | <tr><td class="equals first inactive"> |
| 728 | 672 | <ul class="options"> |
| 729 | 673 | <li><label><input type="radio" |
| 730 | - name="<?php print esc_attr( $defaultInputName ); ?>" | |
| 731 | - value="<?php print esc_attr( $defaultInputValue ); ?>" | |
| 732 | - <?php if ( !is_null($defaultInputId)) : ?>id="<?php print esc_attr( $defaultInputId ); ?>" <?php endif; ?> | |
| 733 | - <?php fwp_checked_flag($defaulted, 'yes'); ?> /> | |
| 674 | + name="<?php print $defaultInputName; ?>" | |
| 675 | + value="<?php print $defaultInputValue; ?>" | |
| 676 | + <?php if (!is_null($defaultInputId)) : ?>id="<?php print $defaultInputId; ?>" <?php endif; ?> | |
| 677 | + <?php print $defaulted['yes']; ?> /> | |
| 734 | 678 | Use the site-wide setting</label> |
| 735 | 679 | <span class="current-setting">Currently: |
| 736 | 680 | <strong><?php if (is_callable($labels)) : |
| 737 | - print wp_kses( call_user_func( $labels, $globalSetting, $defaulted, $params ), 'post' ); | |
| 681 | + print call_user_func($labels, $globalSetting, $defaulted, $params); | |
| 738 | 682 | elseif (is_null($labels)) : |
| 739 | - print esc_html( $globalSetting ); | |
| 683 | + print $globalSetting; | |
| 740 | 684 | else : |
| 741 | - $label = $labels[ $globalSetting ]; | |
| 742 | - if ( preg_match( FWP_BOLD_PREFIX_REGEX, $label, $ref ) ) : | |
| 743 | - $label = $ref[1] . ' ' . $ref[2]; | |
| 744 | - endif; | |
| 745 | - | |
| 746 | - print esc_html( $label ); | |
| 747 | - endif; ?></strong> (<a href="<?php print esc_url( $href ); ?>">change</a>)</span></li> | |
| 685 | + print $labels[$globalSetting]; | |
| 686 | + endif; ?></strong> (<a href="<?php print $href; ?>">change</a>)</span></li> | |
| 748 | 687 | </ul></td> |
| 749 | 688 | |
| 750 | 689 | <td class="equals second inactive"> |
| 751 | 690 | <?php if ($defaultInputName != $inputName) : ?> |
| @@ -750,13 +689,13 @@ | ||
| 750 | 689 | <td class="equals second inactive"> |
| 751 | 690 | <?php if ($defaultInputName != $inputName) : ?> |
| 752 | 691 | <ul class="options"> |
| 753 | 692 | <li><label><input type="radio" |
| 754 | - name="<?php print esc_attr( $defaultInputName ); ?>" | |
| 693 | + name="<?php print $defaultInputName; ?>" | |
| 755 | 694 | value="no" |
| 756 | - <?php if ( !is_null($defaultInputIdNo)) : ?>id="<?php print esc_attr( $defaultInputIdNo ); ?>" <?php endif; ?> | |
| 757 | - <?php fwp_checked_flag($defaulted, 'no'); ?> /> | |
| 758 | - <?php esc_html_e('Do something different with this feed.'); ?></label> | |
| 695 | + <?php if (!is_null($defaultInputIdNo)) : ?>id="<?php print $defaultInputIdNo; ?>" <?php endif; ?> | |
| 696 | + <?php print $defaulted['no']; ?> /> | |
| 697 | + <?php _e('Do something different with this feed.'); ?></label> | |
| 759 | 698 | <?php endif; |
| 760 | 699 | endif; |
| 761 | 700 | |
| 762 | 701 | // Let's spit out the controls here. |
| @@ -765,27 +704,13 @@ | ||
| 765 | 704 | call_user_func($options, $setting, $defaulted, $params); |
| 766 | 705 | else : |
| 767 | 706 | ?> |
| 768 | 707 | <ul class="options"> |
| 769 | - <?php | |
| 770 | - foreach ($options as $value => $label) : | |
| 771 | - if ( preg_match( FWP_BOLD_PREFIX_REGEX, $label, $ref ) ) : | |
| 772 | - $prefix = $ref[1]; | |
| 773 | - $label = $ref[2]; | |
| 774 | - else : | |
| 775 | - $prefix = null; | |
| 776 | - endif; | |
| 777 | - ?> | |
| 778 | - <li><label><input type="radio" name="<?php print esc_attr( $inputName ); ?>" | |
| 779 | - value="<?php print esc_attr( $value ); ?>" | |
| 780 | - <?php fwp_checked_flag($checked, $value); ?> /> | |
| 781 | - <?php | |
| 782 | - if ( !is_null($prefix) ) : | |
| 783 | - printf( '<strong>%s</strong> ', esc_html( $prefix ) ); | |
| 784 | - endif; | |
| 785 | - printf( '%s', esc_html( $label ) ); | |
| 786 | - ?> | |
| 787 | - </label></li> | |
| 708 | + <?php foreach ($options as $value => $label) : ?> | |
| 709 | + <li><label><input type="radio" name="<?php print $inputName; ?>" | |
| 710 | + value="<?php print $value; ?>" | |
| 711 | + <?php print $checked[$value]; ?> /> | |
| 712 | + <?php print $label; ?></label></li> | |
| 788 | 713 | <?php endforeach; ?> |
| 789 | 714 | </ul> <!-- class="options" --> |
| 790 | 715 | <?php |
| 791 | 716 | endif; |
| @@ -811,9 +736,9 @@ | ||
| 811 | 736 | public function save_button ($caption = NULL) { |
| 812 | 737 | if (is_null($caption)) : $caption = __('Save Changes'); endif; |
| 813 | 738 | ?> |
| 814 | 739 | <p class="submit"> |
| 815 | -<input class="button-primary" type="submit" name="save" value="<?php print esc_attr( $caption ); ?>" /> | |
| 740 | +<input class="button-primary" type="submit" name="save" value="<?php print $caption; ?>" /> | |
| 816 | 741 | </p> |
| 817 | 742 | <?php |
| 818 | 743 | } |
| 819 | 744 | } /* class FeedWordPressAdminPage */ |