Changeset 1435680
- Timestamp:
- 06/13/2016 09:32:40 AM (10 years ago)
- File:
-
- 1 edited
-
xml-news-sitemap/trunk/gns_xml.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
xml-news-sitemap/trunk/gns_xml.php
r1344021 r1435680 92 92 if ( empty($settings)) { 93 93 $settings = array(); 94 $settings['gns_xml_custom_post_types'] = (array)array("post");94 $settings['gns_xml_custom_post_types'] = array("post"); 95 95 $settings['gns_xml_url'] = (string) get_site_url() . "/sitemap-news.xml"; 96 96 $settings['gns_xml_pubname'] = (string) get_bloginfo( 'name' ); 97 $settings['gns_xml_genres'] = (array)array("Blog");97 $settings['gns_xml_genres'] = array("Blog"); 98 98 $settings['gns_xml_publanguage'] = (string) get_locale(); 99 99 $settings['gns_xml_pubaccess'] = (string) 'na'; 100 $settings['gns_xml_cats'] = array(); 100 101 update_option('gns_xml_options', $settings); 101 102 } … … 113 114 if (isset($_POST['gns_xml_settings']) && current_user_can('manage_options') && check_admin_referer('gns_xml_settings')) { 114 115 $settings = $this->getSettings(); 115 if( !array($_POST['gns_xml_custom_post_types'])){116 if(isset($_POST['gns_xml_custom_post_types']) && !array($_POST['gns_xml_custom_post_types'])){ 116 117 return new WP_Error( 'broke', __( "Oops you can't post that!" ) ); 117 118 } else { 118 $settings['gns_xml_custom_post_types'] = sanitize_text_field($_POST['gns_xml_custom_post_types']); 119 $settings['gns_xml_cats'] = sanitize_text_field($_POST["post_category"]); 120 $settings['gns_xml_pubaccess'] = sanitize_text_field($_POST['gns_xml_pubaccess']); 121 $settings['gns_xml_genres'] = sanitize_text_field($_POST['gns_xml_genres']); 119 if(isset($_POST['gns_xml_custom_post_types'])){ 120 foreach($_POST["gns_xml_custom_post_types"] as $option){ 121 $settings['gns_xml_custom_post_types'][] = sanitize_text_field($option); 122 } 123 } 124 if(isset($_POST["post_category"]) && is_array($_POST["post_category"])){ 125 foreach($_POST["post_category"] as $option){ 126 $settings['gns_xml_cats'][] = sanitize_text_field($option); 127 } 128 } 129 if(isset($_POST["gns_xml_pubaccess"]) && is_array($_POST["gns_xml_pubaccess"])){ 130 $settings['gns_xml_pubaccess'] = sanitize_text_field($_POST["gns_xml_pubaccess"]); 131 } 132 if(isset($_POST["gns_xml_genres"]) && is_array($_POST["gns_xml_genres"])){ 133 foreach($_POST["gns_xml_genres"] as $option){ 134 $settings['gns_xml_genres'][] = sanitize_text_field($option); 135 } 136 } 122 137 } 123 138 if(!is_string($_POST['gns_xml_url']) || !is_string($_POST['gns_xml_pubname']) || !is_string($_POST['gns_xml_publanguage'])){ … … 224 239 $output .= '<select class="index-list widefat" name="gns_xml_pubaccess">'; 225 240 foreach($this->_access as $key => $value){ 226 227 241 if($gns_xml_pubaccess != "" && $key == $gns_xml_pubaccess){ 228 242 $selected = 'selected'; … … 238 252 $output .= '<p class="label"><strong>'.__('Genres').'</strong></p>'; 239 253 $output .= '<select class="index-list widefat" name="gns_xml_genres[]" multiple="multiple">'; 240 foreach($this->_genres as $key => $value){ 241 if(!empty($gns_xml_genres) && in_array($key, $gns_xml_genres)){ 254 255 if(isset($gns_xml_genres) && is_array($gns_xml_genres)){ 256 foreach($this->_genres as $key => $value){ 257 if(!empty($gns_xml_genres) && in_array($key, $gns_xml_genres)){ 242 258 $selected = 'selected'; 243 } elseif (!empty($settings['gns_xml_genres']) && in_array($key, $settings['gns_xml_genres'])) { 259 } else { 260 $selected = ''; 261 } 262 $output .= '<option value="'.$key.'" '.$selected.'>'. __($value).'</option>'; 263 } 264 } else { 265 foreach($this->_genres as $key => $value){ 266 if (!empty($settings['gns_xml_genres']) && in_array($key, $settings['gns_xml_genres'])) { 244 267 $selected = 'selected'; 245 268 } else { … … 248 271 $output .= '<option value="'.$key.'" '.$selected.'>'. __($value).'</option>'; 249 272 } 273 } 274 250 275 $output .= '</select>'; 251 276 $output .= '<p class="label"><label for="gns_xml_publanguage"><strong>'.__('Language').'</strong></label></p>'; … … 272 297 273 298 if ( isset($_POST['gns_xml_include']) && $_POST['gns_xml_include'] != "" ) { 274 //print_r($_POST['gns_xml_include']); 275 update_post_meta( $post_id, 'gns_xml_include', sanitize_meta($_POST['gns_xml_include']) ); 276 update_post_meta( $post_id, 'gns_xml_pubaccess', sanitize_meta($_POST['gns_xml_pubaccess']) ); 277 update_post_meta( $post_id, 'gns_xml_genres', sanitize_meta(serialize($_POST['gns_xml_genres'])) ); 299 update_post_meta( $post_id, 'gns_xml_include', sanitize_text_field($_POST['gns_xml_include']) ); 300 update_post_meta( $post_id, 'gns_xml_pubaccess', sanitize_text_field($_POST['gns_xml_pubaccess']) ); 301 if(isset($_POST['gns_xml_genres']) && is_array($_POST['gns_xml_genres'])){ 302 $genres = array(); 303 foreach($_POST["gns_xml_genres"] as $option){ 304 $genres[] = sanitize_text_field($option); 305 } 306 307 update_post_meta( $post_id, 'gns_xml_genres', serialize($genres) ); 308 } 278 309 update_post_meta( $post_id, 'gns_xml_publanguage', sanitize_meta($_POST['gns_xml_publanguage']) ); 279 310
Note: See TracChangeset
for help on using the changeset viewer.