Changeset 1371991
- Timestamp:
- 03/16/2016 02:47:01 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
location-specific-menu-items-by-country/tags/1.0.3/CSMI.php
r1371605 r1371991 13 13 add_action( 'network_admin_notices', 'csmi_admin_notice' ); // also show message on multisite 14 14 function csmi_admin_notice() { 15 if ( class_exists ( 'City_Specific_Menu_Items' ) ) {15 if ( class_exists ( 'City_Specific_Menu_Items' ) ) { 16 16 global $pagenow; 17 if ( $pagenow == 'plugins.php' ) {17 if ( $pagenow == 'plugins.php' ) { 18 18 deactivate_plugins ( 'location-specific-menu-items-by-country/CSMI.php' ); 19 19 if ( current_user_can( 'install_plugins' ) ) { … … 185 185 foreach($countries as $key => $value) { 186 186 ?> 187 <option value="<?php echo $key;?>"<?php echo (is_array( $vals ) && in_array( $key, $vals )) ? "selected='selected'" : ''; ?>> <?php echo $value;?> </option>187 <option value="<?php echo $key;?>"<?php echo is_array( $vals ) && in_array( $key, $vals ) ? "selected='selected'" : ''; ?>> <?php echo $value;?> </option> 188 188 <?php 189 189 } … … 214 214 function csmi_update_locations( $menu_id, $menu_item_db_id, $args ) { 215 215 $meta_value = get_post_meta( $menu_item_db_id, 'locations', true ); 216 if ( isset( $_POST['menu-item-visibility'][$menu_item_db_id] ) ) { 217 $new_meta_value = $_POST['menu-item-visibility'][$menu_item_db_id]; } 218 if ( !isset($new_meta_value ) ) { 219 delete_post_meta( $menu_item_db_id, 'locations', $meta_value ); 220 } 221 elseif ( $meta_value !== $new_meta_value ) { 222 update_post_meta( $menu_item_db_id, 'locations', $new_meta_value ); 223 } 216 if ( isset( $_POST[ 'menu-item-visibility' ][ $menu_item_db_id ] ) ) { 217 $new_meta_value = $_POST[ 'menu-item-visibility' ][ $menu_item_db_id ]; 218 } 219 if ( !isset($new_meta_value ) ) { 220 delete_post_meta( $menu_item_db_id, 'locations', $meta_value ); 221 } 222 elseif ( $meta_value !== $new_meta_value ) { 223 update_post_meta( $menu_item_db_id, 'locations', $new_meta_value ); 224 } 224 225 } 225 226 … … 229 230 if ( isset( $_POST[ 'menu-item-show-hide' ][ $menu_item_db_id ] ) ) { 230 231 $new_meta_value = $_POST[ 'menu-item-show-hide' ][ $menu_item_db_id ]; 231 if ( '' == $new_meta_value ) { 232 delete_post_meta( $menu_item_db_id, 'hide_show', $meta_value ); 233 } 234 elseif ( $meta_value !== $new_meta_value ) { 235 update_post_meta( $menu_item_db_id, 'hide_show', $new_meta_value ); 236 } 232 } 233 if ( $meta_value !== $new_meta_value ) { 234 update_post_meta( $menu_item_db_id, 'hide_show', $new_meta_value ); 237 235 } 238 236 } … … 256 254 } 257 255 if ( !filter_var( $ip_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) === FALSE ) { 258 if ( is_readable ( $GeoIPv4_file ) ) {256 if ( is_readable( $GeoIPv4_file ) ) { 259 257 $gi = \CSMIGeoIP\geoip_open( $GeoIPv4_file, GEOIP_STANDARD ); 260 258 $user_country = \CSMIGeoIP\geoip_country_code_by_addr( $gi, $ip_address ); … … 269 267 } 270 268 } elseif ( !filter_var( $ip_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) === FALSE ) { 271 if ( is_readable ( $GeoIPv6_file ) ) {269 if ( is_readable( $GeoIPv6_file ) ) { 272 270 $gi = \CSMIGeoIP\geoip_open( $GeoIPv6_file, GEOIP_STANDARD ); 273 271 $user_country = \CSMIGeoIP\geoip_country_code_by_addr_v6( $gi, $ip_address ); … … 310 308 $visible = true; 311 309 } 312 if ( !$visible || isset( $hidden_items[ $item_parent] ) ) { // also hide the children of hidden items310 if ( !$visible || isset( $hidden_items[ $item_parent ] ) ) { // also hide the children of hidden items 313 311 unset( $items[ $key ] ); 314 312 $hidden_items[ $item->ID ] = '1';
Note: See TracChangeset
for help on using the changeset viewer.