Plugin Directory

Changeset 1371991


Ignore:
Timestamp:
03/16/2016 02:47:01 AM (10 years ago)
Author:
Ryan Stutzman
Message:

Cleaned up functions which store settings in the DB.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • location-specific-menu-items-by-country/tags/1.0.3/CSMI.php

    r1371605 r1371991  
    1313add_action( 'network_admin_notices', 'csmi_admin_notice' ); // also show message on multisite
    1414function csmi_admin_notice() {
    15     if ( class_exists ( 'City_Specific_Menu_Items' ) ){
     15    if ( class_exists ( 'City_Specific_Menu_Items' ) ) {
    1616        global $pagenow;
    17         if ( $pagenow == 'plugins.php' ){
     17        if ( $pagenow == 'plugins.php' ) {
    1818            deactivate_plugins ( 'location-specific-menu-items-by-country/CSMI.php' );
    1919            if ( current_user_can( 'install_plugins' ) ) {
     
    185185                    foreach($countries as $key => $value) {
    186186                    ?>
    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>
    188188                    <?php
    189189                    }
     
    214214    function csmi_update_locations( $menu_id, $menu_item_db_id, $args ) {
    215215        $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        }
    224225    }
    225226
     
    229230        if ( isset( $_POST[ 'menu-item-show-hide' ][ $menu_item_db_id ] ) ) {
    230231            $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 );
    237235        }
    238236    }
     
    256254            }
    257255            if ( !filter_var( $ip_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) === FALSE ) {     
    258                 if ( is_readable ( $GeoIPv4_file ) ) {
     256                if ( is_readable( $GeoIPv4_file ) ) {
    259257                    $gi = \CSMIGeoIP\geoip_open( $GeoIPv4_file, GEOIP_STANDARD );
    260258                    $user_country = \CSMIGeoIP\geoip_country_code_by_addr( $gi, $ip_address );
     
    269267                }
    270268            } elseif ( !filter_var( $ip_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) === FALSE ) {
    271                 if ( is_readable ( $GeoIPv6_file ) ) {
     269                if ( is_readable( $GeoIPv6_file ) ) {
    272270                    $gi = \CSMIGeoIP\geoip_open( $GeoIPv6_file, GEOIP_STANDARD );
    273271                    $user_country = \CSMIGeoIP\geoip_country_code_by_addr_v6( $gi, $ip_address );
     
    310308                    $visible = true;
    311309                }
    312                 if ( !$visible || isset( $hidden_items[$item_parent] ) ) { // also hide the children of hidden items
     310                if ( !$visible || isset( $hidden_items[ $item_parent ] ) ) { // also hide the children of hidden items
    313311                    unset( $items[ $key ] );
    314312                    $hidden_items[ $item->ID ] = '1';   
Note: See TracChangeset for help on using the changeset viewer.