Plugin Directory

Changeset 2008056


Ignore:
Timestamp:
01/07/2019 09:52:47 PM (7 years ago)
Author:
LiknoSoftware
Message:

Supports WordPress v5 (i.e. from v3 up to v5)

Location:
allwebmenus-wordpress-menu-plugin/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • allwebmenus-wordpress-menu-plugin/trunk/actions.php

    r1165181 r2008056  
    11<?php
    2 if (!function_exists("AWM_get_wp_header_path")) {
    3     function AWM_get_wp_header_path()
    4     {
    5         $base = dirname(__FILE__);
    6         $path = false;
     2if ( ! function_exists("AWM_get_wp_header_path")) {
     3    function AWM_get_wp_header_path()
     4    {
     5        $base = dirname(__FILE__);
     6        $path = false;
    77
    8         if (@file_exists(dirname(dirname($base)) . "/wp-blog-header.php")) {
    9             $path = dirname(dirname($base)) . "/wp-blog-header.php";
    10         } elseif (@file_exists(dirname(dirname(dirname($base))) . "/wp-blog-header.php")) {
    11             $path = dirname(dirname(dirname($base))) . "/wp-blog-header.php";
    12         } else $path = false;
     8        if (@file_exists(dirname(dirname($base)) . "/wp-blog-header.php")) {
     9            $path = dirname(dirname($base)) . "/wp-blog-header.php";
     10        } elseif (@file_exists(dirname(dirname(dirname($base))) . "/wp-blog-header.php")) {
     11            $path = dirname(dirname(dirname($base))) . "/wp-blog-header.php";
     12        } else {
     13            $path = false;
     14        }
    1315
    14         if ($path != false) {
    15             $path = str_replace("\\", "/", $path);
    16         }
    17         return $path;
    18     }
     16        if ($path != false) {
     17            $path = str_replace("\\", "/", $path);
     18        }
     19        return $path;
     20    }
    1921}
    2022
     
    2325
    2426$nonce = $_REQUEST['_wpnonce'];
    25 if (!wp_verify_nonce($nonce, 'my-nonce')) die('Security check');
     27if ( ! wp_verify_nonce($nonce, 'my-nonce')) {
     28    die('Security check');
     29}
    2630
    2731
     
    2933define('WP_USE_THEMES', false);
    3034
    31 if (!isset($wp_session)) $wp_session = WP_Session::get_instance();
     35if ( ! isset($wp_session)) {
     36    $wp_session = WP_Session::get_instance();
     37}
    3238
    3339require_once(ABSPATH . 'wp-admin/includes/file.php');
     
    4652
    4753for ($awm_t = 0; $awm_t < $awm_total_tabs; $awm_t++) {
    48     // AWM_categories_subitems_no
    49     if (isset($_POST['AWM_categories_subitems_no_' . $awm_t])) {
    50         if ($_POST['AWM_categories_subitems_no_' . $awm_t] < 1) $_POST['AWM_categories_subitems_no_' . $awm_t] = 1;
    51         if ($_POST['AWM_categories_subitems_no_' . $awm_t] > 50) $_POST['AWM_categories_subitems_no_' . $awm_t] = 50;
    52     }
    53     // AWM_menu_name
    54     if (isset($_POST["AWM_menu_name_" . $awm_t])) $_POST["AWM_menu_name_" . $awm_t] = awm_fix_menu_name($_POST["AWM_menu_name_" . $awm_t]);
     54    // AWM_categories_subitems_no
     55    if (isset($_POST['AWM_categories_subitems_no_' . $awm_t])) {
     56        if ($_POST['AWM_categories_subitems_no_' . $awm_t] < 1) {
     57            $_POST['AWM_categories_subitems_no_' . $awm_t] = 1;
     58        }
     59        if ($_POST['AWM_categories_subitems_no_' . $awm_t] > 50) {
     60            $_POST['AWM_categories_subitems_no_' . $awm_t] = 50;
     61        }
     62    }
     63    // AWM_menu_name
     64    if (isset($_POST["AWM_menu_name_" . $awm_t])) {
     65        $_POST["AWM_menu_name_" . $awm_t] = awm_fix_menu_name($_POST["AWM_menu_name_" . $awm_t]);
     66    }
    5567}
    5668// AWM_menu_path
    5769if (isset($_POST["AWM_menu_path"])) {
    58     $awm_path = (string)$_POST["AWM_menu_path"];
    59     if ((strpos($awm_path, "/") != 0) || (strpos($awm_path, "/") === FALSE)) $awm_path = "/" . $awm_path;
    60     if (substr($awm_path, strlen($awm_path) - 1, 1) != "/") $awm_path = $awm_path . "/";
    61     $_POST["AWM_menu_path"] = $awm_path;
     70    $awm_path = (string)$_POST["AWM_menu_path"];
     71    if ((strpos($awm_path, "/") != 0) || (strpos($awm_path, "/") === false)) {
     72        $awm_path = "/" . $awm_path;
     73    }
     74    if (substr($awm_path, strlen($awm_path) - 1, 1) != "/") {
     75        $awm_path = $awm_path . "/";
     76    }
     77    $_POST["AWM_menu_path"] = $awm_path;
    6278}
    6379
    64 if (!isset($_POST['theaction'])) {
    65     ob_end_clean();
    66     wp_redirect($_POST['ref']);
    67     exit;
     80if ( ! isset($_POST['theaction'])) {
     81    ob_end_clean();
     82    wp_redirect($_POST['ref']);
     83    exit;
    6884
    6985}
    7086if ($_POST['theaction'] == "createnew") {
    71     $message = awm_create_new_menu();
    72     $wp_session['message'] = $message;
    73     ob_end_clean();
    74     wp_redirect($_POST['ref']);
    75     exit;
    76 } else if ($_POST['theaction'] == "delete") {
    77     // update all values
    78     $message = awm_delete_menu();
    79     $wp_session['message'] = '<div class="updated fade"><p><strong>' . $message . '</strong></p></div>';
    80     ob_end_clean();
    81     wp_redirect($_POST['ref']);
    82     exit;
    83 } elseif ($_POST['theaction'] == "generate_structure") {
    84     // first update all values, then generate the current tab's structure
    85     global $awm_total_tabs;
    86     if ($awm_total_tabs) {
    87         awm_update_option_values();
    88         ob_end_clean();
    89         wp_redirect($_POST['ref'] . "&generated=true");
    90     } else {
    91         $wp_session['message'] = '<div class="updated fade"><p><strong>There are no menus. You can create one using the appropriate button.</strong></p></div>';
    92         ob_end_clean();
    93         wp_redirect($_POST['ref']);
    94     }
    95     exit;
    96 } else if ($_POST['theaction'] == "set_defaults") {
    97     // first update all values, then reset this tab to defaults
    98     awm_update_option_values();
    99     awm_set_default_option_values(get_option('AWM_selected_tab'));
    100     $wp_session['message'] = '<div class="updated fade"><p><strong>Default Settings Loaded!</strong></p></div>';
    101     ob_end_clean();
    102     wp_redirect($_POST['ref']);
    103     exit;
    104 } else if ($_POST['theaction'] == "info_update") {
    105     // update all values
    106     $message = awm_update_option_values();
    107     $wp_session['message'] = '<div class="updated fade"><p><strong>' . $message . '</strong></p></div>';
    108     ob_end_clean();
    109     wp_redirect($_POST['ref']);
    110     exit;
    111 } else if ($_POST['theaction'] == 'hide_msg') {
    112     update_option('AWM_Check_show', 0);
    113     ob_end_clean();
    114     wp_redirect($_POST['ref']);
    115     exit;
    116 } else if ($_POST['theaction'] == 'hide_addcode') {
    117     update_option("AWM_code_check", 0);
    118     ob_end_clean();
    119     wp_redirect($_POST['ref']);
    120     exit;
    121 } else if ($_POST['theaction'] == "zip_update") {
    122     if (strpos(urldecode($_SERVER['HTTP_REFERER']), "wp-admin/options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php") === false) {
    123         echo "Access error! Please contact: [email protected]";
    124         exit;
    125     }
    126     $message = awm_update_zip();
    127     $wp_session['message'] = '<div class="updated fade"><p><strong>' . $message . '</strong></p></div>';
    128     ob_end_clean();
    129     wp_redirect($_POST['ref']);
    130     exit;
     87    $message = awm_create_new_menu();
     88    $wp_session['message'] = $message;
     89    ob_end_clean();
     90    wp_redirect($_POST['ref']);
     91    exit;
    13192} else {
    132     ob_end_clean();
    133     wp_redirect($_POST['ref']);
    134     exit;
     93    if ($_POST['theaction'] == "delete") {
     94        // update all values
     95        $message = awm_delete_menu();
     96        $wp_session['message'] = '<div class="updated fade"><p><strong>' . $message . '</strong></p></div>';
     97        ob_end_clean();
     98        wp_redirect($_POST['ref']);
     99        exit;
     100    } elseif ($_POST['theaction'] == "generate_structure") {
     101        // first update all values, then generate the current tab's structure
     102        global $awm_total_tabs;
     103        if ($awm_total_tabs) {
     104            awm_update_option_values();
     105            ob_end_clean();
     106            wp_redirect($_POST['ref'] . "&generated=true");
     107        } else {
     108            $wp_session['message'] = '<div class="updated fade"><p><strong>There are no menus. You can create one using the appropriate button.</strong></p></div>';
     109            ob_end_clean();
     110            wp_redirect($_POST['ref']);
     111        }
     112        exit;
     113    } else {
     114        if ($_POST['theaction'] == "set_defaults") {
     115            // first update all values, then reset this tab to defaults
     116            awm_update_option_values();
     117            awm_set_default_option_values(get_option('AWM_selected_tab'));
     118            $wp_session['message'] = '<div class="updated fade"><p><strong>Default Settings Loaded!</strong></p></div>';
     119            ob_end_clean();
     120            wp_redirect($_POST['ref']);
     121            exit;
     122        } else {
     123            if ($_POST['theaction'] == "info_update") {
     124                // update all values
     125                $message = awm_update_option_values();
     126                $wp_session['message'] = '<div class="updated fade"><p><strong>' . $message . '</strong></p></div>';
     127                ob_end_clean();
     128                wp_redirect($_POST['ref']);
     129                exit;
     130            } else {
     131                if ($_POST['theaction'] == 'hide_msg') {
     132                    update_option('AWM_Check_show', 0);
     133                    ob_end_clean();
     134                    wp_redirect($_POST['ref']);
     135                    exit;
     136                } else {
     137                    if ($_POST['theaction'] == 'hide_addcode') {
     138                        update_option("AWM_code_check", 0);
     139                        ob_end_clean();
     140                        wp_redirect($_POST['ref']);
     141                        exit;
     142                    } else {
     143                        if ($_POST['theaction'] == "zip_update") {
     144                            if (strpos(urldecode($_SERVER['HTTP_REFERER']),
     145                                    "wp-admin/options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php") === false) {
     146                                echo "Access error! Please contact: [email protected]";
     147                                exit;
     148                            }
     149                            $message = awm_update_zip();
     150                            $wp_session['message'] = '<div class="updated fade"><p><strong>' . $message . '</strong></p></div>';
     151                            ob_end_clean();
     152                            wp_redirect($_POST['ref']);
     153                            exit;
     154                        } else {
     155                            ob_end_clean();
     156                            wp_redirect($_POST['ref']);
     157                            exit;
     158                        }
     159                    }
     160                }
     161            }
     162        }
     163    }
    135164}
    136165?>
  • allwebmenus-wordpress-menu-plugin/trunk/allwebmenus-wordpress-menu.php

    r1165200 r2008056  
    22/*
    33Plugin Name: AllWebMenus WordPress Menu Plugin
    4 Plugin URI: http://www.likno.com/addins/wordpress-menu.html
     4Plugin URI: https://www.likno.com/addins/wordpress-menu.html
    55Description: WordPress plugin for the AllWebMenus PRO Javascript Menu Maker - Create stylish drop-down menus or sliding menus for your blogs!
    66Version: 1.1.23
    77Author: Likno Software
    8 Author URI: http://www.likno.com/
     8Author URI: https://www.likno.com/
    99*/
    1010
     
    2727global $awmPluginInstance;
    2828$awmPluginInstance = new AWM_Plugin();
    29 require_once ('wp-session-manager-master/wp-session-manager.php');
     29require_once('wp-session-manager-master/wp-session-manager.php');
     30
    3031/*
    3132 *class: AWM_Plugin
     
    3839{
    3940
    40     var $optionsMessage, $databaseMessage, $AWM_ver , $awm_total_tabs, $awm_is_yarpp_enabled, $wpdb, $dataArray,$awm_table_name,$awm_wp_nav_array;
    41    
    42     function AWM_Plugin(){
    43     global $wpdb;
    44     $this->optionsMessage = "";
    45     $this->wpdb = $wpdb;
    46     add_action( 'init', array($this,'AWM_init_hook' ));
    47     add_action( 'admin_init',  array($this,'AWM_addmin_hook' ));
    48     add_action('admin_menu', array($this,'AWM_add_option_pages'));
    49     global $wp_version;
    50     if((float)$wp_version>=2.8){
    51         include_once WP_PLUGIN_DIR.'/allwebmenus-wordpress-menu-plugin/widgetClass.php';
    52         add_action('widgets_init', create_function('', 'return register_widget("Widget_AllWebMenus");'));
    53     }
     41var $optionsMessage, $databaseMessage, $AWM_ver, $awm_total_tabs, $awm_is_yarpp_enabled, $wpdb, $dataArray, $awm_table_name, $awm_wp_nav_array;
     42
     43function __construct()
     44{
     45    global $wpdb;
     46    $this->optionsMessage = "";
     47    $this->wpdb = $wpdb;
     48    add_action('init', array($this, 'AWM_init_hook'));
     49    add_action('admin_init', array($this, 'AWM_addmin_hook'));
     50    add_action('admin_menu', array($this, 'AWM_add_option_pages'));
     51    global $wp_version;
     52    if ((float)$wp_version >= 2.8) {
     53        include_once WP_PLUGIN_DIR . '/allwebmenus-wordpress-menu-plugin/widgetClass.php';
     54        add_action('widgets_init', 'registerWidgetAllWebMenus');
     55    }
     56    function registerWidgetAllWebMenus()
     57    {
     58        register_widget("Widget_AllWebMenus");
     59    }
    5460}
    5561
    5662/*
    57  * Initialization of plugin.
    58  */
    59 function AWM_init_hook(){
    60     global $dataArray,$awm_table_name, $awm_total_tabs, $AWM_ver, $dataArray, $awm_is_yarpp_enabled;
     63     * Initialization of plugin.
     64     */
     65function AWM_init_hook()
     66{
     67    global $dataArray, $awm_table_name, $awm_total_tabs, $AWM_ver, $dataArray, $awm_is_yarpp_enabled;
    6168    /*
    62     * Load the include files
    63     */
    64     include_once WP_PLUGIN_DIR.'/allwebmenus-wordpress-menu-plugin/menu_helper.php';
    65     include_once WP_PLUGIN_DIR.'/allwebmenus-wordpress-menu-plugin/include.php';
    66    
     69        * Load the include files
     70        */
     71    include_once WP_PLUGIN_DIR . '/allwebmenus-wordpress-menu-plugin/menu_helper.php';
     72    include_once WP_PLUGIN_DIR . '/allwebmenus-wordpress-menu-plugin/include.php';
     73
    6774    $this->awm_table_name = $awm_table_name = $this->wpdb->prefix . "awm";
    6875    $this->dataArray = $dataArray = array();
    6976    $this->AWM_ver = $AWM_ver = '1.1.23';
    70    
    71     $this->awm_total_tabs = $awm_total_tabs = get_option("AWM_total_menus",(int) 0);
     77
     78    $this->awm_total_tabs = $awm_total_tabs = get_option("AWM_total_menus", (int)0);
    7279    //if ($_POST["AWM_selected_tab"]=="") $_POST["AWM_selected_tab"]="1";
    7380    // set the first time options (if they do not already exist)
    7481    awm_set_first_time_options();
    75    
     82
    7683    // add linking code to header.php file
    77     if (isset($_GET['theaction']) && $_GET['theaction']=='show_addcode') {
     84    if (isset($_GET['theaction']) && $_GET['theaction'] == 'show_addcode') {
    7885        update_option("AWM_code_check", 1);
    7986    }
    80     $check = get_option("AWM_code_check",1);
    81     if ($check && !awm_add_code()) {
    82         $nonce= wp_create_nonce('my-nonce');
     87    $check = get_option("AWM_code_check", 1);
     88    if ($check && ! awm_add_code()) {
     89        $nonce = wp_create_nonce('my-nonce');
    8390        $this->optionsMessage =
    84             "<div class=\"updated fade\" style=\"margin-top: 20px;\"><p><strong>Linking code could not be added automatically. You have to add it by yourself. Open the \"header.php\" file (found at \"".content_url()."/themes/YourSiteTheme\") and add this code <br /><textarea readonly cols=50 rows=4><?php if (function_exists('AWM_generate_linking_code'))\nAWM_generate_linking_code(); ?></textarea><br /> right after the &lt;body&gt; tag.</strong></p>
    85                 <form method=\"post\" id=\"the_add_code_form\" name=\"the_add_code_form\" action=\"".plugins_url('actions.php',__FILE__)."\">
     91            "<div class=\"updated fade\" style=\"margin-top: 20px;\"><p><strong>Linking code could not be added automatically. You have to add it by yourself. Open the \"header.php\" file (found at \"" . content_url() . "/themes/YourSiteTheme\") and add this code <br /><textarea readonly cols=50 rows=4><?php if (function_exists('AWM_generate_linking_code'))\nAWM_generate_linking_code(); ?></textarea><br /> right after the &lt;body&gt; tag.</strong></p>
     92                <form method=\"post\" id=\"the_add_code_form\" name=\"the_add_code_form\" action=\"" . plugins_url('actions.php',
     93                __FILE__) . "\">
    8694                    <input type=\"hidden\" name=\"theaction\" value=\"hide_addcode\"/>
    8795                    <input type=\"hidden\" name=\"_wpnonce\" value=\"$nonce\"/>
    88                     <input type=\"hidden\" name=\"ref\" value=\" ". admin_url("options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php") ."\"/>
     96                    <input type=\"hidden\" name=\"ref\" value=\" " . admin_url("options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php") . "\"/>
    8997                    <input type=\"submit\"  value=\"Hide notification\"/>
    9098                </form>
     
    94102    // Check if already had the plugin when it was single-tab and convert values
    95103    awm_convert_from_single_to_multi_tab();
    96     $this->databaseMessage  = awm_convert_to_database();
    97     if (!empty($this->databaseMessage))
    98         $this->databaseMessage = "<div class=\"updated fade\" style=\"margin-top: 20px;\"><strong>".$this->databaseMessage."</strong></div>";
     104    $this->databaseMessage = awm_convert_to_database();
     105    if ( ! empty($this->databaseMessage)) {
     106        $this->databaseMessage = "<div class=\"updated fade\" style=\"margin-top: 20px;\"><strong>" . $this->databaseMessage . "</strong></div>";
     107    }
    99108    awm_add_genre_column();
    100109    awm_add_revision_column();
    101    
     110
    102111    $this->awm_total_tabs = $awm_total_tabs;
    103     $this->awm_is_yarpp_enabled = $awm_is_yarpp_enabled = in_array('yet-another-related-posts-plugin/yarpp.php', get_option('active_plugins'));
     112    $this->awm_is_yarpp_enabled = $awm_is_yarpp_enabled = in_array('yet-another-related-posts-plugin/yarpp.php',
     113        get_option('active_plugins'));
    104114    $awm_plugin = plugin_basename(__FILE__);
    105     add_filter("plugin_action_links_$awm_plugin", array($this, 'awm_wp_settings_link' ));
    106    
     115    add_filter("plugin_action_links_$awm_plugin", array($this, 'awm_wp_settings_link'));
     116
    107117    // Check if you need to check for updates
    108118    if ((get_option('AWM_Checked_Date') <= (date('d') - 15)) || (get_option('AWM_Checked_Date') === '00')) {
    109         update_option('AWM_Check_Show', TRUE);
     119        update_option('AWM_Check_Show', true);
    110120    }
    111121}
    112  /*
    113  * Adds link to settings page
    114  */
    115 function awm_wp_settings_link($awm_links) {
     122
     123/*
     124    * Adds link to settings page
     125    */
     126function awm_wp_settings_link($awm_links)
     127{
    116128    $awm_settings_link = '<a href="options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php">Settings</a>';
    117129    array_unshift($awm_links, $awm_settings_link);
    118         $check = get_option("AWM_code_check",1);
    119     if (!$check){
    120             $awm_linking_link2 ='<a href="'.admin_url("options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php&theaction=show_addcode").'">Activate linking code check</a>';
    121              $awm_links[] = $awm_linking_link2;
    122         }
    123             return $awm_links;
     130    $check = get_option("AWM_code_check", 1);
     131    if ( ! $check) {
     132        $awm_linking_link2 = '<a href="' . admin_url("options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php&theaction=show_addcode") . '">Activate linking code check</a>';
     133        $awm_links[] = $awm_linking_link2;
     134    }
     135    return $awm_links;
    124136}
     137
    125138/*
    126  * Initialization of the admin panel.
    127  */
    128 function AWM_addmin_hook() {
     139     * Initialization of the admin panel.
     140     */
     141function AWM_addmin_hook()
     142{
    129143
    130144    /* Register our stylesheet. */
    131     wp_register_script( 'AWMScript', plugins_url('/script.js', __FILE__) );
    132     wp_register_style( 'AWMStylesheet', plugins_url('/stylesheet.css',__FILE__ ));
     145    wp_register_script('AWMScript', plugins_url('/script.js', __FILE__));
     146    wp_register_style('AWMStylesheet', plugins_url('/stylesheet.css', __FILE__));
    133147}
    134148
    135149/*
    136  * Add admin panel styles AND scripts
    137  */
    138 function AWM_admin_styles() {
     150     * Add admin panel styles AND scripts
     151     */
     152function AWM_admin_styles()
     153{
    139154    /*
    140      * It will be called only on your plugin admin page, enqueue our stylesheet here
     155         * It will be called only on your plugin admin page, enqueue our stylesheet here
     156         */
     157    wp_enqueue_style('AWMStylesheet');
     158    wp_enqueue_script('AWMScript');
     159}
     160
     161/*
     162     * Add options page
    141163     */
    142     wp_enqueue_style( 'AWMStylesheet' );
    143     wp_enqueue_script( 'AWMScript' );
     164function AWM_add_option_pages()
     165{
     166    if (function_exists('add_options_page')) {
     167        $page = add_options_page('AllWebMenus WordPress Menu Plugin', 'AllWebMenus-WP-Menu', "edit_pages", __FILE__,
     168            array($this, 'AWM_options_page'));
     169    }
     170    add_action('admin_print_styles-' . $page, array($this, 'AWM_admin_styles'));
    144171}
     172
    145173/*
    146  * Add options page
    147  */
    148 function AWM_add_option_pages() {
    149     if (function_exists('add_options_page')) {
    150         $page = add_options_page('AllWebMenus WordPress Menu Plugin', 'AllWebMenus-WP-Menu', "edit_pages", __FILE__, array($this,'AWM_options_page'));
    151     }
    152    add_action( 'admin_print_styles-' . $page,  array($this,'AWM_admin_styles' ));
     174     * Generate options page
     175     */
     176function AWM_options_page()
     177{
     178echo $this->databaseMessage;
     179echo $this->optionsMessage;
     180$locations = array();
     181if (function_exists('get_registered_nav_menus')) {
     182    $locations = (array)get_registered_nav_menus();
    153183}
    154 
    155 /*
    156  * Generate options page
    157  */
    158 function AWM_options_page() {
    159     echo $this->databaseMessage;
    160     echo $this->optionsMessage;
    161     $locations = array();
    162     if (function_exists('get_registered_nav_menus'))
    163         $locations = (array) get_registered_nav_menus();
    164     $myrows = $this->wpdb->get_results( "SELECT * FROM $this->awm_table_name ORDER BY id ASC" );
     184$myrows = $this->wpdb->get_results("SELECT * FROM $this->awm_table_name ORDER BY id ASC");
    165185?>
    166     <script>
    167         function awm_set_path(x) {
    168             for (var i=0; i<<?php echo $this->awm_total_tabs; ?>; i++) if (i!=x) document.getElementById('AWM_menu_path_'+i).value = document.getElementById('AWM_menu_path_'+x).value;
     186<script>
     187    function awm_set_path(x)
     188    {
     189        for (var i = 0; i <<?php echo $this->awm_total_tabs; ?>; i++) {
     190            if (i != x) {
     191                document.getElementById('AWM_menu_path_' + i).value = document.getElementById('AWM_menu_path_' + x).value;
     192            }
    169193        }
    170     </script>
    171     <div style="max-width: 980px; margin-left: 15px;">
     194    }
     195</script>
     196<div style="max-width: 980px; margin-left: 15px;">
    172197
    173198    <span class="wrap">
     
    175200    <h2>AllWebMenus WordPress Menu Plugin v<?php echo $this->AWM_ver; ?></h2>
    176201    <div id="AWM_welcome_title" onclick="awm_show_welcome();" style="cursor: pointer;">
    177         Note: The plugin requires the use of the "AllWebMenus" commercial application (version 5.3.926+). <span id="AWM_welcome_title_info"><a href="javascript:void(0);">Click for more info.</a></span>
     202        Note: The plugin requires the use of the "AllWebMenus" commercial application (version 5.3.926+). <span id="AWM_welcome_title_info"><a
     203        href="javascript:void(0);">Click for more info.</a></span>
    178204    </div>
    179205        <p id="awm_upload_anchor">For information and updates, please visit:
    180         <a href="http://www.likno.com/addins/wordpress-menu.html">http://www.likno.com/addins/wordpress-menu.html</a></p>   
    181 
    182 <?php
    183     /* Display a message in the Options page if the menu version is outdated
    184     NOTE: we do not check date as we have to recheck to display the message to the admin */
    185     if (get_option('AWM_Check_show')) {
    186         $AWM_buildText = AWM_check();
    187         if ($AWM_buildText != '') echo $AWM_buildText;
    188         else update_option('AWM_Check_show', FALSE);
    189     }
    190 ?>
     206        <a href="https://www.likno.com/addins/wordpress-menu.html">https://www.likno.com/addins/wordpress-menu.html</a></p>
     207
     208        <?php
     209        /* Display a message in the Options page if the menu version is outdated
     210        NOTE: we do not check date as we have to recheck to display the message to the admin */
     211        if (get_option('AWM_Check_show')) {
     212            $AWM_buildText = AWM_check();
     213            if ($AWM_buildText != '') {
     214                echo $AWM_buildText;
     215            } else {
     216                update_option('AWM_Check_show', false);
     217            }
     218        }
     219        ?>
    191220    </span>
    192     <div id="AWM_welcome_screen">   <!-- START OF WELCOME SCREEN -->
    193         <h1>Welcome to our WordPress Menu plugin&nbsp;&nbsp;&nbsp;<button class="button" type="button" style="position: relative; top: -3px;" onclick="awm_show_welcome(false);">Move to Settings &raquo;</button></h1>
    194 <p><br>This plugin acts as a <strong>"bridge"</strong> between...</p>
    195 <table>
    196     <tr>
    197         <td valign="top" style="text-align: center;">
    198 <p>
    199 <span style="font-size: 14px;">...the <strong>AllWebMenus Pro application</strong>...</span><br />
    200  a powerful windows application for <br>creating any kind of navigation menu</p>
    201 <img alt="javascript menu / css menu builder" height="203" src="<?php echo plugins_url();?>/allwebmenus-wordpress-menu-plugin/awm5snap-wordpress-menu-plugin-info.jpg" style="padding-left: 28px;"width="270" />
    202 <p><a href="http://www.likno.com/allwebmenusinfo.html">Features</a> &nbsp; <a href="http://www.likno.com/download.html">Download</a> &nbsp; <a href="http://www.likno.com/examples.html">Menu Examples</a> &nbsp; <a href="http://www.likno.com/awmstyles.php">Menu Themes</a> &nbsp; <a href="http://www.likno.com/awmregister.php">Purchase</a></p>
    203         </td>
    204         <td valign="top"><span style="font-size: 36px; padding: 35px;"><br>&amp;</span></td>
    205         <td valign="top" style="text-align: center;">
     221    <div id="AWM_welcome_screen">    <!-- START OF WELCOME SCREEN -->
     222        <h1>Welcome to our WordPress Menu plugin&nbsp;&nbsp;&nbsp;<button class="button" type="button"
     223                                                                          style="position: relative; top: -3px;"
     224                                                                          onclick="awm_show_welcome(false);">Move to Settings
     225            &raquo;
     226        </button>
     227        </h1>
     228        <p><br>This plugin acts as a <strong>"bridge"</strong> between...</p>
     229        <table>
     230            <tr>
     231                <td valign="top" style="text-align: center;">
     232                    <p>
     233                        <span style="font-size: 14px;">...the <strong>AllWebMenus Pro application</strong>...</span><br/>
     234                        a powerful windows application for <br>creating any kind of navigation menu</p>
     235                    <img alt="javascript menu / css menu builder" height="203"
     236                         src="<?php echo plugins_url(); ?>/allwebmenus-wordpress-menu-plugin/awm5snap-wordpress-menu-plugin-info.jpg"
     237                         style="padding-left: 28px;" width="270"/>
     238                    <p><a href="https://www.likno.com/allwebmenusinfo.html">Features</a> &nbsp; <a
     239                        href="https://www.likno.com/download.html">Download</a> &nbsp; <a
     240                        href="https://www.likno.com/examples.html">Menu Examples</a> &nbsp; <a
     241                        href="https://www.likno.com/awmstyles.php">Menu Themes</a> &nbsp; <a
     242                        href="https://www.likno.com/awmregister.php">Purchase</a></p>
     243                </td>
     244                <td valign="top"><span style="font-size: 36px; padding: 35px;"><br>&amp;</span></td>
     245                <td valign="top" style="text-align: center;">
     246                    <p>
     247                        <span style="font-size: 14px;">...your <strong>WordPress blog</strong></span></p>
     248                    <br><br>
     249                    <img alt="blog" height="203"
     250                         src="<?php echo plugins_url(); ?>/allwebmenus-wordpress-menu-plugin/v5_addins-wordpress-menu-plugin-info-blog.jpg"
     251                         width="270"/>
     252                </td>
     253            </tr>
     254        </table>
     255
    206256        <p>
    207         <span style="font-size: 14px;">...your <strong>WordPress blog</strong></span></p>
    208         <br><br>
    209 <img alt="blog" height="203" src="<?php echo plugins_url();?>/allwebmenus-wordpress-menu-plugin/v5_addins-wordpress-menu-plugin-info-blog.jpg" width="270"/>
    210         </td>
    211     </tr>
    212 </table>
    213 
    214 <p>
    215 &nbsp;</p>
    216 <p style="font-size: 14px; font-weight: bold;">How?</p>
    217 <table style="width: 100%">
    218     <tr>
    219         <td valign="top" style="width: 530px">
    220 <p><strong><br />
    221 1.</strong> Use this plugin to <strong>retrieve items from your blog*.</strong><br>
    222 &nbsp;&nbsp;&nbsp;&nbsp;(such as posts, pages, etc.)<br><br>
    223         <strong>2.</strong> <strong>Paste</strong> these blog items into AllWebMenus and create stylish, feature-rich navigation
    224 menus based on them. Fully customize these menus with styles, behaviors, effects,
    225 designs of your choice and <a href="http://www.likno.com/allwebmenusinfo.html">
    226 many more!</a><br><br>
    227         <strong>3.</strong> Use this plugin to <strong>upload</strong> your menus
    228 (multiple menus also supported) to your blog. <strong>Done!</strong></p>
    229 <br><br><p style="font-size: 11px;"><em>*Also add </em> <strong><em>non-wordpress menu items</em></strong><em> (i.e. your own "external"
    230 items, not posts or pages), that use external or internal links, html-rich
    231 content, etc. </em> </p>
    232         </td>
    233         <td><img alt="wordpress javascript menu css menu plugin" height="306" src="<?php echo plugins_url();?>/allwebmenus-wordpress-menu-plugin/v5_addins-wordpress-menu-plugin-info.jpg" width="217" /></td>
    234     </tr>
    235 </table>
    236         <div style="padding-left:200px;"><button class="button" type="button" onclick="awm_show_welcome(false);">Move to Settings &raquo;</button></div>
    237     </div>      <!-- END OF WELCOME SCREEN -->
     257            &nbsp;</p>
     258        <p style="font-size: 14px; font-weight: bold;">How?</p>
     259        <table style="width: 100%">
     260            <tr>
     261                <td valign="top" style="width: 530px">
     262                    <p><strong><br/>
     263                        1.</strong> Use this plugin to <strong>retrieve items from your blog*.</strong><br>
     264                        &nbsp;&nbsp;&nbsp;&nbsp;(such as posts, pages, etc.)<br><br>
     265                        <strong>2.</strong> <strong>Paste</strong> these blog items into AllWebMenus and create stylish,
     266                        feature-rich navigation
     267                        menus based on them. Fully customize these menus with styles, behaviors, effects,
     268                        designs of your choice and <a href="https://www.likno.com/allwebmenusinfo.html">
     269                            many more!</a><br><br>
     270                        <strong>3.</strong> Use this plugin to <strong>upload</strong> your menus
     271                        (multiple menus also supported) to your blog. <strong>Done!</strong></p>
     272                    <br><br>
     273                    <p style="font-size: 11px;"><em>*Also add </em> <strong><em>non-wordpress menu items</em></strong><em> (i.e.
     274                        your own "external"
     275                        items, not posts or pages), that use external or internal links, html-rich
     276                        content, etc. </em></p>
     277                </td>
     278                <td><img alt="wordpress javascript menu css menu plugin" height="306"
     279                         src="<?php echo plugins_url(); ?>/allwebmenus-wordpress-menu-plugin/v5_addins-wordpress-menu-plugin-info.jpg"
     280                         width="217"/></td>
     281            </tr>
     282        </table>
     283        <div style="padding-left:200px;">
     284            <button class="button" type="button" onclick="awm_show_welcome(false);">Move to Settings &raquo;</button>
     285        </div>
     286    </div>        <!-- END OF WELCOME SCREEN -->
    238287    <br>
    239288
    240 <?php
    241         $wp_session = WP_Session::get_instance();
    242         echo $wp_session['message']."<br>";
    243         unset ( $wp_session['message'] );
    244 ?>
    245     <div id="AWM_settings_publish_screen" style="display: none;">   <!-- START OF SETTINGS / PUBLISH SCREEN -->
    246    
    247    
    248 <?php
    249     if (isset($_GET['generated'])){
    250             $awm_str_code = AWM_create_menu_structure($myrows[get_option('AWM_selected_tab')],"");
     289    <?php
     290    $wp_session = WP_Session::get_instance();
     291    echo $wp_session['message'] . "<br>";
     292    unset ($wp_session['message']);
     293    ?>
     294    <div id="AWM_settings_publish_screen" style="display: none;">    <!-- START OF SETTINGS / PUBLISH SCREEN -->
     295
     296
     297        <?php
     298        if (isset($_GET['generated'])) {
     299        $awm_str_code = AWM_create_menu_structure($myrows[get_option('AWM_selected_tab')], "");
    251300        $awm_up_path = site_url() . get_option('AWM_menu_path');
    252 ?>
     301        ?>
    253302        <!-- START OF PUBLISH SCREEN -->
    254303        <div id="AWM_publish_screen">
    255         <div class="updated fade"><p><strong>Menu Structure Code generated!</strong></p></div>
    256         <div style="background-color: #FEFCF5; border: #E6DB55 solid 1px; padding-left:15px; margin-top: 20px;">
    257             <table>
    258                 <tr><td style="width: 800px; text-align: center; padding-top: 10px; padding-bottom: 10px;"><h3>Generated &quot;Menu Structure Code&quot;:</h3></td></tr>
    259                 <tr><td style="width: 800px; text-align: center; padding-top: 0px; padding-bottom: 10px;">
    260                     <textarea cols="100" rows="10" id="loginfo" name="loginfo"><?php echo $awm_str_code; ?></textarea>
    261                 </td></tr>
    262             </table>
    263             <h3>STEP 1: &nbsp;Copy & Paste the above &quot;Menu Structure Code&quot; into AllWebMenus</h3>
    264             <table>
    265             <tr><td style="padding-left: 100px; width: 800px; text-align: left; padding-top: 10px;">
    266                     - Select it and <b>copy</b> it (press <strong>Ctrl+C</strong>) from above
    267                     <br><br>- Switch to the <b>AllWebMenus</b> desktop application:
     304            <div class="updated fade"><p><strong>Menu Structure Code generated!</strong></p></div>
     305            <div style="background-color: #FEFCF5; border: #E6DB55 solid 1px; padding-left:15px; margin-top: 20px;">
     306                <table>
     307                    <tr>
     308                        <td style="width: 800px; text-align: center; padding-top: 10px; padding-bottom: 10px;"><h3>Generated
     309                            &quot;Menu Structure Code&quot;:</h3></td>
     310                    </tr>
     311                    <tr>
     312                        <td style="width: 800px; text-align: center; padding-top: 0px; padding-bottom: 10px;">
     313                            <textarea cols="100" rows="10" id="loginfo" name="loginfo"><?php echo $awm_str_code; ?></textarea>
     314                        </td>
     315                    </tr>
     316                </table>
     317                <h3>STEP 1: &nbsp;Copy & Paste the above &quot;Menu Structure Code&quot; into AllWebMenus</h3>
     318                <table>
     319                    <tr>
     320                        <td style="padding-left: 100px; width: 800px; text-align: left; padding-top: 10px;">
     321                            - Select it and <b>copy</b> it (press <strong>Ctrl+C</strong>) from above
     322                            <br><br>- Switch to the <b>AllWebMenus</b> desktop application:
     323                        </td>
     324                    </tr>
     325                    <tr>
     326                        <td style="padding-left: 140px; width: 760px; text-align: left; padding-bottom: 10px;">
     327                            <br>- Open the<span style="background-color:#FFFFE0; font-weight:bold; padding:0px 5px;"><i>"Add-ins &nbsp;&gt;&nbsp; WordPress Menu &nbsp;&gt;&nbsp; Import/Update Menu Structure from WordPress"</i></span>
     328                            form
     329                            <br><br>- <b>Paste</b> the above copied "Menu Structure Code" into the import form
     330                            <br><br>- Go to Style Editor to <b>configure</b> your menu appearance, behavior, etc. using the
     331                            related AllWebMenus properties<br>
     332                            <i>&nbsp;&nbsp;(if you use the &lt;"Static" Menu Type&gt; option, you may also change the menu
     333                                structure & content using the Menu Editor)</i>
     334                            <br><br>- <b>Compile</b> your menu using the<span
     335                            style="background-color:#FFFFE0; font-weight:bold; padding:0px 5px;"><i>"Add-ins &nbsp;&gt;&nbsp; WordPress Menu &nbsp;&gt;&nbsp; Compile WordPress Menu"</i></span>
     336                            form
     337                            <br><br>- Your <b>compiled menu ZIP file</b> will be created. Now proceed to "Step 2" below to
     338                            upload this ZIP file to your blog.<br>
     339                            <i>&nbsp;&nbsp;Note: AllWebMenus version 5.3.926 (December 2013) or above is required</i>
     340                        </td>
     341                    </tr>
    268342                    </td></tr>
    269             <tr><td style="padding-left: 140px; width: 760px; text-align: left; padding-bottom: 10px;">                                 
    270                     <br>- Open the<span style="background-color:#FFFFE0; font-weight:bold; padding:0px 5px;"><i>"Add-ins &nbsp;&gt;&nbsp; WordPress Menu &nbsp;&gt;&nbsp; Import/Update Menu Structure from WordPress"</i></span> form
    271                     <br><br>- <b>Paste</b> the above copied "Menu Structure Code" into the import form
    272                     <br><br>- Go to Style Editor to <b>configure</b> your menu appearance, behavior, etc. using the related AllWebMenus properties<br>
    273                     <i>&nbsp;&nbsp;(if you use the &lt;"Static" Menu Type&gt; option, you may also change the menu structure & content using the Menu Editor)</i>
    274                     <br><br>- <b>Compile</b> your menu using the<span style="background-color:#FFFFE0; font-weight:bold; padding:0px 5px;"><i>"Add-ins &nbsp;&gt;&nbsp; WordPress Menu &nbsp;&gt;&nbsp; Compile WordPress Menu"</i></span> form
    275                     <br><br>- Your <b>compiled menu ZIP file</b> will be created. Now proceed to "Step 2" below to upload this ZIP file to your blog.<br>
    276                     <i>&nbsp;&nbsp;Note: AllWebMenus version 5.3.926 (December 2013) or above is required</i>
    277                 </td></tr>
    278                 </td></tr>
    279             </table>
    280     <br>
    281     <h3>STEP 2: &nbsp;Upload the compiled menu ZIP file (produced by AllWebMenus)</h3>
    282    
    283     <table id="uploader">
    284 
    285         <tr><td width="250"><strong>Browse for the "<span id='correct_filename'>awm<?php echo $myrows[get_option('AWM_selected_tab')]->name;?>.zip</span>" file:</strong></td>
    286         <td>
    287         <form method="post" enctype="multipart/form-data" id="theform1a" name="theform1a" action="<?php echo plugins_url('actions.php',__FILE__); ?>" >
    288             <?php $nonce= wp_create_nonce('my-nonce'); ?>
    289             <input type="hidden" name="ref" value="<?php echo admin_url("options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php"); ?>"/>
    290             <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/>
    291             <input type="hidden" name="theaction" value="zip_update"/>
    292             <input type="hidden" name="AWM_menu_id" value=""/>
    293             <input id="AWM_selected_tab_ca" name="AWM_selected_tab_c" type="hidden" value="<?php echo get_option('AWM_selected_tab');?>"/>
    294                     <input id="AWM_menu_js" name="AWM_menu_js" type="file" />
    295                     <button class="button" type="button" onclick="upload_zip();">Upload ZIP file</button>
    296         </form>
    297                 </td></tr>
    298                 <tr><td width="250">&nbsp;</td>
    299         <td class="awm_itemInfo">
    300                     Browse for the ZIP file, then click the "Upload ZIP file" button to upload it.<br />
    301         </td></tr>
    302     </table>
    303 <br></div>
    304 <br><div style="text-align: center;"><button class="button" type="button" onclick="document.getElementById('AWM_settings_screen').style.display='block';document.getElementById('AWM_publish_screen').style.display='none';">Go Back to Settings &raquo;</button></div>
    305 </div>
    306 <script type='text/javascript'>var t=document.getElementById('loginfo');t.select();t.focus();</script>
    307 <?php
    308     }
    309 ?>
    310 <!-- END OF PUBLISH SCREEN -->
    311 
    312 
    313 <!-- START OF SETTINGS SCREEN -->
    314     <div id="AWM_settings_screen" style="<?php if (isset($_GET['generated'])) echo "display: none;";?>">
    315         <form method="post" enctype="multipart/form-data" id="theform1" name="theform1" action="<?php echo plugins_url('actions.php',__FILE__); ?>" >
    316             <?php $nonce= wp_create_nonce('my-nonce'); ?>
    317             <input type="hidden" name="ref" value="<?php echo admin_url("options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php"); ?>"/>
    318             <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/>
    319             <input type="hidden" name="theaction" value=""/>
    320             <input type="hidden" name="AWM_menu_id" value=""/>
    321             <input id="AWM_selected_tab_c" name="AWM_selected_tab_c" type="hidden" value="<?php echo get_option('AWM_selected_tab');?>"/>
    322             <div style="text-align:right; margin-bottom: 15px;">
    323                 <input class="button" type="button" name="info_update" value="Save settings" onclick="theform.theaction.value='info_update'; awm_form_validate();"/>
    324                 <input class="button" type="button" name="generate_structure" value="Publish menu (also saves changes in settings) &raquo;" onclick="theform.theaction.value='generate_structure'; awm_form_validate();"/>
    325                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    326                 <button class="button" type="button" onclick="theform1.theaction.value='createnew'; theform1.AWM_selected_tab_c.value=theform.AWM_selected_tab.value;theform1.submit();">Create Additional Menu</button>
    327                 &nbsp;<button <?php if ($this->awm_total_tabs == 1) echo "disabled='disabled'"; ?>class="button" type="button" onclick="theform1.theaction.value='delete';theform1.AWM_menu_id.value = eval('theform.AWM_menu_id_'+theform.AWM_selected_tab.value + '.value'); theform1.AWM_selected_tab_c.value=theform.AWM_selected_tab.value;theform1.submit();">Delete Selected Menu</button>
     343                </table>
     344                <br>
     345                <h3>STEP 2: &nbsp;Upload the compiled menu ZIP file (produced by AllWebMenus)</h3>
     346
     347                <table id="uploader">
     348
     349                    <tr>
     350                        <td width="250"><strong>Browse for the "<span
     351                            id='correct_filename'>awm<?php echo $myrows[get_option('AWM_selected_tab')]->name; ?>
     352                                                .zip</span>" file:</strong></td>
     353                        <td>
     354                            <form method="post" enctype="multipart/form-data" id="theform1a" name="theform1a"
     355                                  action="<?php echo plugins_url('actions.php', __FILE__); ?>">
     356                                <?php $nonce = wp_create_nonce('my-nonce'); ?>
     357                                <input type="hidden" name="ref"
     358                                       value="<?php echo admin_url("options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php"); ?>"/>
     359                                <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/>
     360                                <input type="hidden" name="theaction" value="zip_update"/>
     361                                <input type="hidden" name="AWM_menu_id" value=""/>
     362                                <input id="AWM_selected_tab_ca" name="AWM_selected_tab_c" type="hidden"
     363                                       value="<?php echo get_option('AWM_selected_tab'); ?>"/>
     364                                <input id="AWM_menu_js" name="AWM_menu_js" type="file"/>
     365                                <button class="button" type="button" onclick="upload_zip();">Upload ZIP file</button>
     366                            </form>
     367                        </td>
     368                    </tr>
     369                    <tr>
     370                        <td width="250">&nbsp;</td>
     371                        <td class="awm_itemInfo">
     372                            Browse for the ZIP file, then click the "Upload ZIP file" button to upload it.<br/>
     373                        </td>
     374                    </tr>
     375                </table>
     376                <br></div>
     377            <br>
     378            <div style="text-align: center;">
     379                <button class="button" type="button"
     380                        onclick="document.getElementById('AWM_settings_screen').style.display='block';document.getElementById('AWM_publish_screen').style.display='none';">
     381                    Go Back to Settings &raquo;
     382                </button>
    328383            </div>
    329         </form >
    330 <form method="post" enctype="multipart/form-data" id="theform" name="theform" action="<?php echo plugins_url('actions.php',__FILE__); ?>" >
    331 <input type="hidden" name="ref" value="<?php echo admin_url("options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php"); ?>"/>
    332     <?php $nonce= wp_create_nonce('my-nonce'); ?>
    333     <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/>
    334     <input id="AWM_selected_tab" name="AWM_selected_tab" type="hidden" value="<?php echo get_option('AWM_selected_tab');?>"/>
    335    
    336     <div id="AWM_tab_wrapper">
    337         <div id="AWM_tabHeaders">
    338 <?php
    339     for ($awm_t=0; $awm_t<$this->awm_total_tabs; $awm_t++) {
    340         echo "<div class='awm_tab_header' style='color: #".($myrows[$awm_t]->active?"0099":"9900")."00;' id='AWM_tab_header_$awm_t' onclick='awm_show_tab($awm_t)'>".$myrows[$awm_t]->name."</div>";
    341     }
    342 ?>
    343384        </div>
    344         <div id="AWM_tabBodies">
    345 <?php
    346     for ($awm_t=0; $awm_t<$this->awm_total_tabs; $awm_t++) {
    347 ?>
    348             <div class='awm_tab_body' id='AWM_tab_body_<?php echo $awm_t;?>'>
    349                 <div><input type="hidden" name="AWM_menu_id_<?php echo $awm_t?>" value="<?php echo $myrows[$awm_t]->id;?>"/><input id="AWM_menu_active_<?php echo $awm_t;?>" name="AWM_menu_active_<?php echo $awm_t;?>" onclick="awm_uncheck(<?php echo $awm_t;?>);" type="checkbox" value="true" <?php if ($myrows[$awm_t]->active) echo "checked='checked'"; ?> /> <strong>Show "<?php echo $myrows[$awm_t]->name;?>" in blog</strong>
    350                 &nbsp;&nbsp;&nbsp;<?php if (!$myrows[$awm_t]->active) { ?><span id='AWM_unchecked_<?php echo $awm_t;?>' style='color:#990000;'>Unchecked! (this menu will not appear in your blog)</span><?php } else { ?><span id='AWM_unchecked_<?php echo $awm_t;?>' style='color:#009900;'>(this menu will appear in your blog)</span><?php } ?></div>
    351                 <div style="padding-left: 19px; margin-top: 22px;"><strong>Menu name: </strong> <input name="AWM_menu_name_<?php echo $awm_t;?>" id="AWM_menu_name_<?php echo $awm_t;?>" type="text" size="30" value="<?php echo $myrows[$awm_t]->name ?>"/></div>
    352                 <div style="padding-left: 19px;" class="awm_itemInfo">Please make sure that the "Menu name" value matches the value in the "Compiled Menu Name" property of the AllWebMenus project file (<i>Tools > Project Properties > Folders</i>). <a id='show_me_<?php echo $awm_t;?>' href="javascript:void(0)" onclick="show_awm_folder_info(<?php echo $awm_t;?>);">show me</a></div>
    353                 <div id="AWM_folder_info_<?php echo $awm_t;?>" style="margin-top: 20px; display: none; background-color: #FEFCF5; border: #E6DB55 solid 1px;">
    354                     <table>
    355                         <tr><td style="width: 800px; text-align: center; padding-top: 10px; padding-bottom: 10px;"><strong>More info</strong></td></tr>
    356                         <tr><td style="width: 800px; text-align: center; padding-top: 0px; padding-bottom: 10px;">
    357                             <img src="<?php echo plugins_url();?>/allwebmenus-wordpress-menu-plugin/more_info.jpg" width="527" height="513" alt="More info" title="More info"/>
    358                         </td></tr>
    359                         <tr><td style="width: 800px; text-align: center; padding-top: 0px; padding-bottom: 10px;">
    360                             <a href="javascript:void(0)" onclick="show_awm_folder_info(<?php echo $awm_t;?>);">close</a>
    361                     </table>
     385        <script type='text/javascript'>var t = document.getElementById('loginfo');
     386        t.select();
     387        t.focus();</script>
     388        <?php
     389        }
     390        ?>
     391        <!-- END OF PUBLISH SCREEN -->
     392
     393
     394        <!-- START OF SETTINGS SCREEN -->
     395        <div id="AWM_settings_screen" style="<?php if (isset($_GET['generated'])) {
     396            echo "display: none;";
     397        } ?>">
     398            <form method="post" enctype="multipart/form-data" id="theform1" name="theform1"
     399                  action="<?php echo plugins_url('actions.php', __FILE__); ?>">
     400                <?php $nonce = wp_create_nonce('my-nonce'); ?>
     401                <input type="hidden" name="ref"
     402                       value="<?php echo admin_url("options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php"); ?>"/>
     403                <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/>
     404                <input type="hidden" name="theaction" value=""/>
     405                <input type="hidden" name="AWM_menu_id" value=""/>
     406                <input id="AWM_selected_tab_c" name="AWM_selected_tab_c" type="hidden"
     407                       value="<?php echo get_option('AWM_selected_tab'); ?>"/>
     408                <div style="text-align:right; margin-bottom: 15px;">
     409                    <input class="button" type="button" name="info_update" value="Save settings"
     410                           onclick="theform.theaction.value='info_update'; awm_form_validate();"/>
     411                    <input class="button" type="button" name="generate_structure"
     412                           value="Publish menu (also saves changes in settings) &raquo;"
     413                           onclick="theform.theaction.value='generate_structure'; awm_form_validate();"/>
     414                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     415                    <button class="button" type="button"
     416                            onclick="theform1.theaction.value='createnew'; theform1.AWM_selected_tab_c.value=theform.AWM_selected_tab.value;theform1.submit();">
     417                        Create Additional Menu
     418                    </button>
     419                    &nbsp;<button <?php if ($this->awm_total_tabs == 1) {
     420                    echo "disabled='disabled'";
     421                } ?>class="button" type="button"
     422                                  onclick="theform1.theaction.value='delete';theform1.AWM_menu_id.value = eval('theform.AWM_menu_id_'+theform.AWM_selected_tab.value + '.value'); theform1.AWM_selected_tab_c.value=theform.AWM_selected_tab.value;theform1.submit();">
     423                    Delete Selected Menu
     424                </button>
    362425                </div>
    363                 <div style="padding-left: 19px; margin-top: 22px;"><strong>Online folder for menu files<?php if ($this->awm_total_tabs>1) echo " (common for all menus)"; ?>: </strong> <input id="AWM_menu_path_<?php echo $awm_t;?>" name="AWM_menu_path_<?php echo $awm_t;?>" onkeyup="awm_set_path(<?php echo $awm_t;?>);" onchange="awm_set_path(<?php echo $awm_t;?>);" type="text" size="30" value="<?php echo get_option('AWM_menu_path'); ?>"/>&nbsp;&nbsp;(relative to blog's root folder)</div>
    364                 <div style="padding-left: 19px;" class="awm_itemInfo">
    365                     Based on your settings, this is the folder that should be created online: &nbsp;
    366                     <span style="background-color:#FFFFE0; padding:0px 5px;">
    367                     <?php echo site_url().get_option("AWM_menu_path")?>
     426            </form>
     427            <form method="post" enctype="multipart/form-data" id="theform" name="theform"
     428                  action="<?php echo plugins_url('actions.php', __FILE__); ?>">
     429                <input type="hidden" name="ref"
     430                       value="<?php echo admin_url("options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php"); ?>"/>
     431                <?php $nonce = wp_create_nonce('my-nonce'); ?>
     432                <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/>
     433                <input id="AWM_selected_tab" name="AWM_selected_tab" type="hidden"
     434                       value="<?php echo get_option('AWM_selected_tab'); ?>"/>
     435
     436                <div id="AWM_tab_wrapper">
     437                    <div id="AWM_tabHeaders">
     438                        <?php
     439                        for ($awm_t = 0; $awm_t < $this->awm_total_tabs; $awm_t++) {
     440                            echo "<div class='awm_tab_header' style='color: #" . ($myrows[$awm_t]->active ? "0099" : "9900") . "00;' id='AWM_tab_header_$awm_t' onclick='awm_show_tab($awm_t)'>" . $myrows[$awm_t]->name . "</div>";
     441                        }
     442                        ?>
     443                    </div>
     444                    <div id="AWM_tabBodies">
     445                        <?php
     446                        for ($awm_t = 0; $awm_t < $this->awm_total_tabs; $awm_t++) {
     447                        ?>
     448                        <div class='awm_tab_body' id='AWM_tab_body_<?php echo $awm_t; ?>'>
     449                            <div><input type="hidden" name="AWM_menu_id_<?php echo $awm_t ?>"
     450                                        value="<?php echo $myrows[$awm_t]->id; ?>"/><input
     451                                id="AWM_menu_active_<?php echo $awm_t; ?>" name="AWM_menu_active_<?php echo $awm_t; ?>"
     452                                onclick="awm_uncheck(<?php echo $awm_t; ?>);" type="checkbox"
     453                                value="true" <?php if ($myrows[$awm_t]->active) {
     454                                echo "checked='checked'";
     455                            } ?> /> <strong>Show "<?php echo $myrows[$awm_t]->name; ?>" in blog</strong>
     456                                &nbsp;&nbsp;&nbsp;<?php if ( ! $myrows[$awm_t]->active) { ?><span
     457                                    id='AWM_unchecked_<?php echo $awm_t; ?>' style='color:#990000;'>Unchecked! (this menu will not appear in your blog)</span><?php } else { ?>
     458                                <span id='AWM_unchecked_<?php echo $awm_t; ?>'
     459                                      style='color:#009900;'>(this menu will appear in your blog)</span><?php } ?>
     460                            </div>
     461                            <div style="padding-left: 19px; margin-top: 22px;"><strong>Menu name: </strong> <input
     462                                name="AWM_menu_name_<?php echo $awm_t; ?>" id="AWM_menu_name_<?php echo $awm_t; ?>"
     463                                type="text" size="30" value="<?php echo $myrows[$awm_t]->name ?>"/></div>
     464                            <div style="padding-left: 19px;" class="awm_itemInfo">Please make sure that the "Menu name" value
     465                                matches the value in the "Compiled Menu Name" property of the AllWebMenus project file (<i>Tools
     466                                    > Project Properties > Folders</i>). <a id='show_me_<?php echo $awm_t; ?>'
     467                                                                            href="javascript:void(0)"
     468                                                                            onclick="show_awm_folder_info(<?php echo $awm_t; ?>);">show
     469                                    me</a></div>
     470                            <div id="AWM_folder_info_<?php echo $awm_t; ?>"
     471                                 style="margin-top: 20px; display: none; background-color: #FEFCF5; border: #E6DB55 solid 1px;">
     472                                <table>
     473                                    <tr>
     474                                        <td style="width: 800px; text-align: center; padding-top: 10px; padding-bottom: 10px;">
     475                                            <strong>More info</strong></td>
     476                                    </tr>
     477                                    <tr>
     478                                        <td style="width: 800px; text-align: center; padding-top: 0px; padding-bottom: 10px;">
     479                                            <img
     480                                                src="<?php echo plugins_url(); ?>/allwebmenus-wordpress-menu-plugin/more_info.jpg"
     481                                                width="527" height="513" alt="More info" title="More info"/>
     482                                        </td>
     483                                    </tr>
     484                                    <tr>
     485                                        <td style="width: 800px; text-align: center; padding-top: 0px; padding-bottom: 10px;">
     486                                            <a href="javascript:void(0)" onclick="show_awm_folder_info(<?php echo $awm_t; ?>);">close</a>
     487                                </table>
     488                            </div>
     489                            <div style="padding-left: 19px; margin-top: 22px;"><strong>Online folder for menu
     490                                files<?php if ($this->awm_total_tabs > 1) {
     491                                    echo " (common for all menus)";
     492                                } ?>: </strong> <input id="AWM_menu_path_<?php echo $awm_t; ?>"
     493                                                       name="AWM_menu_path_<?php echo $awm_t; ?>"
     494                                                       onkeyup="awm_set_path(<?php echo $awm_t; ?>);"
     495                                                       onchange="awm_set_path(<?php echo $awm_t; ?>);" type="text" size="30"
     496                                                       value="<?php echo get_option('AWM_menu_path'); ?>"/>&nbsp;&nbsp;(relative
     497                                to blog's root folder)
     498                            </div>
     499                            <div style="padding-left: 19px;" class="awm_itemInfo">
     500                                Based on your settings, this is the folder that should be created online: &nbsp;
     501                                <span style="background-color:#FFFFE0; padding:0px 5px;">
     502                    <?php echo site_url() . get_option("AWM_menu_path") ?>
    368503                    </span>
    369                     <br>
    370                     It is created automatically during this action. If your server's settings do not permit this you will have to create this folder yourself (eg: FTP).
    371                     <br/>
    372                     Info: This is the online folder where the AllWebMenus "compiled menu ZIP file" extracts its contents (menu engine, styles, etc.) every time you upload it through the "Publish Menu" action.
    373                     </div>
    374                 <br>
    375                 <fieldset class="options">
    376                                         <fieldset id="AWM_menu_structure_fieldset_<?php echo $awm_t;?>">
    377                     <div class="AWM_section">Menu Structure</div>
    378                     <table width="100%" height="auto" style="padding-left: 20px;">
    379                         <tr><td>&nbsp;</td></tr>
    380                         <tr><td width="100%"><input onclick="awm_select_structure(true,<?php echo $awm_t;?>);" name="AWM_use_custom_menu_<?php echo $awm_t;?>" value="1" type="radio" <?php if ($myrows[$awm_t]->custom_menu) echo "checked='checked'"; ?> />&nbsp;Menu is populated from an existing "Wordpress menu" (check to choose menu, Wordpress 3+ only)</td></tr>
    381                         <tr><td id="AWM_menu_structure_use_existing_<?php echo $awm_t;?>">
    382                             <table width="100%" height="auto" style="padding-left: 20px;">
    383                                 <tr><td>
    384                                     Which WordPress menu do you want to use? <select id="AWM_use_custom_menu_id_<?php echo $awm_t;?>" name="AWM_use_custom_menu_id_<?php echo $awm_t;?>">
    385 <?php
    386         $awm_available_custom_menus = (array)$this->wpdb->get_results("
     504                                <br>
     505                                It is created automatically during this action. If your server's settings do not permit this you
     506                                will have to create this folder yourself (eg: FTP).
     507                                <br/>
     508                                Info: This is the online folder where the AllWebMenus "compiled menu ZIP file" extracts its
     509                                contents (menu engine, styles, etc.) every time you upload it through the "Publish Menu" action.
     510                            </div>
     511                            <br>
     512                            <fieldset class="options">
     513                                <fieldset id="AWM_menu_structure_fieldset_<?php echo $awm_t; ?>">
     514                                    <div class="AWM_section">Menu Structure</div>
     515                                    <table width="100%" height="auto" style="padding-left: 20px;">
     516                                        <tr>
     517                                            <td>&nbsp;</td>
     518                                        </tr>
     519                                        <tr>
     520                                            <td width="100%"><input onclick="awm_select_structure(true,<?php echo $awm_t; ?>);"
     521                                                                    name="AWM_use_custom_menu_<?php echo $awm_t; ?>" value="1"
     522                                                                    type="radio" <?php if ($myrows[$awm_t]->custom_menu) {
     523                                                echo "checked='checked'";
     524                                            } ?> />&nbsp;Menu is populated from an existing "Wordpress menu" (check to
     525                                                choose menu, Wordpress 3+ only)
     526                                            </td>
     527                                        </tr>
     528                                        <tr>
     529                                            <td id="AWM_menu_structure_use_existing_<?php echo $awm_t; ?>">
     530                                                <table width="100%" height="auto" style="padding-left: 20px;">
     531                                                    <tr>
     532                                                        <td>
     533                                                            Which WordPress menu do you want to use? <select
     534                                                            id="AWM_use_custom_menu_id_<?php echo $awm_t; ?>"
     535                                                            name="AWM_use_custom_menu_id_<?php echo $awm_t; ?>">
     536                                                            <?php
     537                                                            $awm_available_custom_menus = (array)$this->wpdb->get_results("
    387538            SELECT t.term_id as menu_ID, t.name as menu_name
    388539            FROM {$this->wpdb->prefix}terms t, {$this->wpdb->prefix}term_taxonomy tt
     
    390541            AND t.term_id = tt.term_id
    391542            ORDER BY menu_ID");
    392         if (count($awm_available_custom_menus)>0) {
    393 //          echo "<option value='-1'>Please select a WordPress menu</option>";
    394             for ($awm_i=0; $awm_i<count($awm_available_custom_menus); $awm_i++) {
    395                 echo "<option value='".$awm_available_custom_menus[$awm_i]->menu_ID."'".($awm_available_custom_menus[$awm_i]->menu_ID==$myrows[$awm_t]->custom_menu_id?" selected":"").">".$awm_available_custom_menus[$awm_i]->menu_name."</option>";
     543                                                            if (count($awm_available_custom_menus) > 0) {
     544                                                                //          echo "<option value='-1'>Please select a WordPress menu</option>";
     545                                                                for ($awm_i = 0; $awm_i < count($awm_available_custom_menus); $awm_i++) {
     546                                                                    echo "<option value='" . $awm_available_custom_menus[$awm_i]->menu_ID . "'" . ($awm_available_custom_menus[$awm_i]->menu_ID == $myrows[$awm_t]->custom_menu_id ? " selected" : "") . ">" . $awm_available_custom_menus[$awm_i]->menu_name . "</option>";
     547                                                                }
     548                                                            } else {
     549                                                                echo "<option value='-1'>No WordPress menus found!</option>";
     550                                                            }
     551                                                            ?>
     552                                                        </select>&nbsp;&nbsp;&nbsp;&nbsp;<span class="awm_itemInfo"><a
     553                                                            href="nav-menus.php">Add/Edit WordPress menus</a></span
     554                                                        </td>
     555                                                    </tr>
     556                                                </table>
     557                                            </td>
     558                                        </tr>
     559                                        <tr>
     560                                            <td>&nbsp;</td>
     561                                        </tr>
     562                                        <tr>
     563                                            <td><input onclick="awm_select_structure(false,<?php echo $awm_t; ?>);"
     564                                                       name="AWM_use_custom_menu_<?php echo $awm_t; ?>" value="0"
     565                                                       type="radio"<?php if ( ! $myrows[$awm_t]->custom_menu) {
     566                                                echo "checked='checked'";
     567                                            } ?> />&nbsp;Menu is populated with specific "pages", "posts", "categories",
     568                                                etc. (check to choose items)
     569                                            </td>
     570                                        </tr>
     571                                        <tr>
     572                                            <td id="AWM_menu_structure_use_own_<?php echo $awm_t; ?>" width="100%">
     573                                                <table width="100%" height="auto" style="padding-left: 20px;">
     574                                                    <tr>
     575                                                        <td colspan="2"><p>Please select the items you want to include/exclude
     576                                                            in your menu structure:</p></td>
     577                                                    </tr>
     578                                                    <tr>
     579                                                        <td colspan="2">&nbsp;</td>
     580                                                    </tr>
     581                                                    <tr>
     582                                                        <td width="230"><input name="AWM_include_home_<?php echo $awm_t; ?>"
     583                                                                               type="checkbox"
     584                                                                               value="true" <?php if ($myrows[$awm_t]->include_home) {
     585                                                            echo "checked='checked'";
     586                                                        } ?> /> <strong>"Home"</strong></td>
     587                                                        <td class="awm_itemInfo">A "Home" item that opens the blog's Home
     588                                                            Page.
     589                                                        </td>
     590                                                    </tr>
     591
     592                                                    <tr>
     593                                                        <td colspan="2">&nbsp;</td>
     594                                                    </tr>
     595                                                    <tr>
     596                                                        <td colspan="2">&nbsp;</td>
     597                                                    </tr>
     598
     599                                                    <tr>
     600                                                        <td width="230" VALIGN="TOP"><input
     601                                                            onclick="awm_show_field(this.checked,<?php echo $awm_t; ?>,'pages');"
     602                                                            name="AWM_pages_<?php echo $awm_t; ?>"
     603                                                            type="checkbox" <?php if ($myrows[$awm_t]->pages) {
     604                                                            echo "checked='checked'";
     605                                                        } ?> /> <strong>Pages<span
     606                                                            id="awm_pages_dots_<?php echo $awm_t; ?>"><?php if ($myrows[$awm_t]->pages): ?>:<?php else: ?> ...<?php endif; ?></span></strong>
     607                                                        </td>
     608                                                        <td>
     609                                                            <fieldset
     610                                                                id="awm_pages_fieldset_<?php echo $awm_t ?>" <?php if ( ! $myrows[$awm_t]->pages) {
     611                                                                echo 'style="display:none"';
     612                                                            } ?>>
     613                                                                <span style="color: #009900">Show all Pages</span> <span
     614                                                                style="color: #990000">except the following:</span><br/>
     615                                                                <input name="AWM_excluded_pages_<?php echo $awm_t; ?>"
     616                                                                       type="text" size="55"
     617                                                                       value="<?php echo $myrows[$awm_t]->excluded_pages ?>"/>
     618
     619                                                                <br/><span class="awm_itemInfo">Page IDs, separated by commas (their sub-pages will also be excluded). Example: 34, 59, 140</span>
     620
     621                                                                <br/>
     622                                                                <br/>
     623                                                                <input
     624                                                                    onclick="awm_disable_input(false,<?php echo $awm_t; ?>,'pages');"
     625                                                                    name="AWM_pages_ms_<?php echo $awm_t; ?>" value="main"
     626                                                                    type="radio" <?php if ($myrows[$awm_t]->pages_ms == 'main') {
     627                                                                    echo "checked='checked'";
     628                                                                } ?> />&nbsp;Show Pages as Main Menu items
     629                                                                <br/><input
     630                                                                onclick="awm_disable_input(true,<?php echo $awm_t; ?>,'pages');"
     631                                                                name="AWM_pages_ms_<?php echo $awm_t; ?>" value="sub"
     632                                                                type="radio"<?php if ($myrows[$awm_t]->pages_ms != 'main') {
     633                                                                echo "checked='checked'";
     634                                                            } ?> />&nbsp;Show a Main Menu item named
     635                                                                <input <?php if ($myrows[$awm_t]->pages_ms == 'main') {
     636                                                                    echo "disabled='disabled'";
     637                                                                } ?> id="awm_pages_name_<?php echo $awm_t; ?>"
     638                                                                     name="AWM_pages_name_<?php echo $awm_t; ?>" type="text"
     639                                                                     size="10"
     640                                                                     value="<?php echo $myrows[$awm_t]->pages_name ?>"/>
     641                                                                and show Pages as its submenu items
     642                                                                <br/>
     643
     644                                                            </fieldset>
     645                                                            <br/>
     646                                                            <br/>
     647
     648                                                        </td>
     649                                                    </tr>
     650
     651                                                    <tr>
     652                                                        <td valign="top" width="230"><input
     653                                                            onclick="awm_show_field(this.checked,<?php echo $awm_t; ?>,'posts');"
     654                                                            name="AWM_posts_<?php echo $awm_t; ?>"
     655                                                            type="checkbox" <?php if ($myrows[$awm_t]->posts) {
     656                                                            echo "checked='checked'";
     657                                                        } ?> /> <strong>Posts<span
     658                                                            id="awm_posts_dots_<?php echo $awm_t; ?>"><?php if ($myrows[$awm_t]->posts): ?>:<?php else: ?> ...<?php endif; ?></span></strong>
     659                                                        </td>
     660                                                        <td>
     661                                                            <fieldset
     662                                                                id="awm_posts_fieldset_<?php echo $awm_t ?>" <?php if ( ! $myrows[$awm_t]->posts) {
     663                                                                echo 'style="display:none"';
     664                                                            } ?>>
     665                                                                <span style="display: block;color: #009900">Show the following Posts:</span>
     666                                                                <input name="AWM_posts_ids_<?php echo $awm_t; ?>" type="text"
     667                                                                       size="55"
     668                                                                       value="<?php echo $myrows[$awm_t]->posts_ids ?>"/>
     669                                                                <br/>
     670                                                                <span class="awm_itemInfo">Post IDs, separated by commas. Example: 34, 59, 140</span>
     671                                                                <br/>
     672                                                                <br/>
     673                                                                <input
     674                                                                    onclick="awm_disable_input(false,<?php echo $awm_t; ?>,'posts');"
     675                                                                    name="AWM_posts_ms_<?php echo $awm_t; ?>" value="main"
     676                                                                    type="radio" <?php if ($myrows[$awm_t]->posts_ms == 'main') {
     677                                                                    echo "checked='checked'";
     678                                                                } ?> />&nbsp;Show Posts as Main Menu items
     679                                                                <br/>
     680
     681                                                                <input
     682                                                                    onclick="awm_disable_input(true,<?php echo $awm_t; ?>,'posts');"
     683                                                                    name="AWM_posts_ms_<?php echo $awm_t; ?>" value="sub"
     684                                                                    type="radio"<?php if ($myrows[$awm_t]->posts_ms != 'main') {
     685                                                                    echo "checked='checked'";
     686                                                                } ?> />&nbsp;Show a Main Menu item named
     687                                                                <input <?php if ($myrows[$awm_t]->posts_ms == 'main') {
     688                                                                    echo "disabled='disabled'";
     689                                                                } ?> id="awm_posts_name_<?php echo $awm_t; ?>"
     690                                                                     name="AWM_posts_name_<?php echo $awm_t; ?>" type="text"
     691                                                                     size="10"
     692                                                                     value="<?php echo $myrows[$awm_t]->posts_name ?>"/>
     693                                                                and show Posts as its submenu items
     694                                                                <br/>
     695
     696                                                            </fieldset>
     697                                                            <br/>
     698                                                            <br/>
     699                                                        </td>
     700                                                    </tr>
     701                                                    <tr>
     702                                                        <td valign="top" width="230"><input
     703                                                            onclick="awm_show_field(this.checked,<?php echo $awm_t; ?>,'categories');"
     704                                                            name="AWM_categories_<?php echo $awm_t; ?>"
     705                                                            type="checkbox" <?php if ($myrows[$awm_t]->categories) {
     706                                                            echo "checked='checked'";
     707                                                        } ?> /> <strong>Categories<span
     708                                                            id="awm_categories_dots_<?php echo $awm_t; ?>"><?php if ($myrows[$awm_t]->categories): ?>:<?php else: ?> ...<?php endif; ?></span></strong>
     709                                                        </td>
     710                                                        <td>
     711                                                            <fieldset
     712                                                                id="awm_categories_fieldset_<?php echo $awm_t ?>" <?php if ( ! $myrows[$awm_t]->categories) {
     713                                                                echo 'style="display:none"';
     714                                                            } ?>>
     715                                                                <span style="color: #009900">Show all Categories</span> <span
     716                                                                style="color: #990000">except the following:</span><br/>
     717
     718                                                                <input name="AWM_excluded_cats_<?php echo $awm_t; ?>"
     719                                                                       type="text" size="55"
     720                                                                       value="<?php echo $myrows[$awm_t]->excluded_cats ?>"/><br/>
     721                                                                <span class="awm_itemInfo">Category IDs, separated by commas (their sub-categories will also be excluded). Example: 34, 59, 140</span><br/>
     722                                                                <input
     723                                                                    onclick="document.getElementById('awm_categories_subitems_no_<?php echo $awm_t; ?>').disabled=!this.checked"
     724                                                                    name="AWM_categories_subitems_<?php echo $awm_t; ?>"
     725                                                                    type="checkbox" <?php if ($myrows[$awm_t]->categories_subitems) {
     726                                                                    echo "checked='checked'";
     727                                                                } ?> /> Also show (up to) the <input
     728                                                                onblur="awm_max_min_value(this , <?php echo $awm_t ?>);"
     729                                                                onkeyup="awm_max_min_value(this,  <?php echo $awm_t ?> );"
     730                                                                onkeypress="return awm_disable_value(this,event);" <?php if ( ! $myrows[$awm_t]->categories_subitems) {
     731                                                                echo "disabled='disabled'";
     732                                                            } ?> id="awm_categories_subitems_no_<?php echo $awm_t; ?>"
     733                                                                name="AWM_categories_subitems_no_<?php echo $awm_t; ?>"
     734                                                                type="text" size="2"
     735                                                                value="<?php echo $myrows[$awm_t]->categories_subitems_no ?>"/>
     736                                                                newest posts of each Category as its submenu items<br/>
     737                                                                <span class="awm_itemInfo"
     738                                                                      id="awm_max_value_notice_<?php echo $awm_t; ?>">Value must be between 1 and 50.</span>
     739                                                                <br/>
     740                                                                <br/>
     741                                                                <input
     742                                                                    onclick="awm_disable_input(false,<?php echo $awm_t; ?>,'categories');"
     743                                                                    name="AWM_categories_ms_<?php echo $awm_t; ?>" value="main"
     744                                                                    type="radio" <?php if ($myrows[$awm_t]->categories_ms == 'main') {
     745                                                                    echo "checked='checked'";
     746                                                                } ?> />&nbsp;Show Categories as Main Menu items<br/>
     747
     748                                                                <input
     749                                                                    onclick="awm_disable_input(true,<?php echo $awm_t; ?>,'categories');"
     750                                                                    name="AWM_categories_ms_<?php echo $awm_t; ?>" value="sub"
     751                                                                    type="radio" <?php if ($myrows[$awm_t]->categories_ms != 'main') {
     752                                                                    echo "checked='checked'";
     753                                                                } ?> />&nbsp;Show a Main Menu item named
     754                                                                <input <?php if ($myrows[$awm_t]->categories_ms == 'main') {
     755                                                                    echo "disabled='disabled'";
     756                                                                } ?> id="awm_categories_name_<?php echo $awm_t; ?>"
     757                                                                     name="AWM_categories_name_<?php echo $awm_t; ?>"
     758                                                                     type="text" size="10"
     759                                                                     value="<?php echo $myrows[$awm_t]->categories_name ?>"/>
     760                                                                and show Categories as its submenu items<br/>
     761                                                            </fieldset>
     762                                                            <br/>
     763                                                            <br/>
     764
     765
     766                                                </table>
     767                                            </td>
     768                                        </tr>
     769
     770                                        <tr>
     771                                            <td>&nbsp;</td>
     772                                        </tr>
     773                                    </table>
     774                                    <div class="AWM_section">Other options for menu items</div>
     775
     776                                    <fieldset class="awm_other">
     777                                        <input type="checkbox" name="AWM_hide_future_<?php echo $awm_t; ?>"
     778                                               value="checkbox" <?php if ($myrows[$awm_t]->hide_future) {
     779                                            echo "checked='checked'";
     780                                        } ?>/> Hide future-dated posts
     781                                        <input type="checkbox" name="AWM_hide_protected_<?php echo $awm_t; ?>"
     782                                               value="checkbox" <?php if ($myrows[$awm_t]->hide_protected) {
     783                                            echo "checked='checked'";
     784                                        } ?>/> Hide password-protected items
     785                                        <input type="checkbox" name="AWM_hide_private_<?php echo $awm_t; ?>"
     786                                               value="checkbox" <?php if ($myrows[$awm_t]->hide_private) {
     787                                            echo "checked='checked'";
     788                                        } ?>/> Hide private items
     789                                    </fieldset>
     790
     791                                </fieldset>
     792
     793
     794                                <div class="AWM_section">Menu Type</div>
     795                                <p>Please select how you want your menu to behave:</p>
     796
     797                                <input type="hidden" id="awm_initial_menu_type_<?php echo $awm_t; ?>"
     798                                       value="<?php echo $myrows[$awm_t]->type; ?>"/>
     799                                <table width="100%" height="auto" style="padding-left: 40px;">
     800                                    <tr>
     801                                        <td colspan="2">&nbsp;</td>
     802                                    </tr>
     803                                    <tr>
     804                                        <td colspan="2" id="awm_changed_type_a_<?php echo $awm_t; ?>" class="updated fade"
     805                                            style="display: none;">
     806                                            <span style="color: #990000;">&quot;Menu Type&quot; changed:</span> New behavior
     807                                            will take effect only when you perform the "Publish menu" action to generate an
     808                                            updated &quot;Menu Structure Code&quot; and re-import it to AllWebMenus.
     809                                        </td>
     810                                    </tr>
     811                                    <tr>
     812                                        <td colspan="2" id="awm_changed_type_b_<?php echo $awm_t; ?>">&nbsp;</td>
     813                                    </tr>
     814
     815                                    <tr>
     816                                        <td width="230" valign="top">
     817                                            <table>
     818                                                <tr>
     819                                                    <td><span style="cursor: pointer;"
     820                                                              onclick="awm_select_menu_type('Dynamic',<?php echo $awm_t; ?>);"><strong><input
     821                                                        id="AWM_menu_type_<?php echo $awm_t; ?>_Dynamic"
     822                                                        name="AWM_menu_type_<?php echo $awm_t; ?>" value="Dynamic"
     823                                                        type="radio" <?php if ($myrows[$awm_t]->type == 'Dynamic') {
     824                                                        echo "checked='checked'";
     825                                                    } ?> />&nbsp;"Dynamic" Menu Type</strong></span></td>
     826                                                </tr>
     827                                                <tr>
     828                                                    <td><span style="cursor: pointer;"
     829                                                              onclick="awm_select_menu_type('Mixed',  <?php echo $awm_t; ?>);"><strong><input
     830                                                        id="AWM_menu_type_<?php echo $awm_t; ?>_Mixed"
     831                                                        name="AWM_menu_type_<?php echo $awm_t; ?>" value="Mixed"
     832                                                        type="radio" <?php if ($myrows[$awm_t]->type == 'Mixed') {
     833                                                        echo "checked='checked'";
     834                                                    } ?> />&nbsp;"Mixed" Menu Type</strong></span></td>
     835                                                </tr>
     836                                                <tr>
     837                                                    <td><span style="cursor: pointer;"
     838                                                              onclick="awm_select_menu_type('Static', <?php echo $awm_t; ?>);"><strong><input
     839                                                        id="AWM_menu_type_<?php echo $awm_t; ?>_Static"
     840                                                        name="AWM_menu_type_<?php echo $awm_t; ?>" value="Static"
     841                                                        type="radio" <?php if ($myrows[$awm_t]->type == 'Static') {
     842                                                        echo "checked='checked'";
     843                                                    } ?> />&nbsp;"Static" Menu Type</strong></span></td>
     844                                                </tr>
     845                                            </table>
     846                                        </td>
     847                                        <td valign="top">
     848                                            <div class="awm_itemInfo"
     849                                                 id="AWM_menu_type_<?php echo $awm_t; ?>_Dynamic_info" <?php echo $myrows[$awm_t]->type == 'Dynamic' ? '' : 'style="display:none;"'; ?>>
     850                                                <p style="margin-top: 0px; padding-top: 0px;">You have selected to create a menu
     851                                                    structure of "Dynamic Type".</p>
     852                                                <p>This means that the menu items in AllWebMenus will only be used for
     853                                                    preview/styling purposes.</p>
     854                                                <p>In your actual blog these items will be ignored and the menu will be
     855                                                    populated "dynamically" based on the plugin settings.</p>
     856                                                <p>The styles in AllWebMenus Style Editor will be used to form the actual menu
     857                                                    items.</p>
     858                                                <p><a href="https://www.likno.com/blog/wordpress-javascript-menu/1184/"
     859                                                      target="_blank">View a short presentation explaining all your settings</a>
     860                                                </p>
     861                                            </div>
     862                                            <div class="awm_itemInfo"
     863                                                 id="AWM_menu_type_<?php echo $awm_t; ?>_Mixed_info" <?php echo $myrows[$awm_t]->type == 'Mixed' ? '' : 'style="display:none;"'; ?>>
     864                                                <p style="margin-top: 0px; padding-top: 0px;">You have selected to create a menu
     865                                                    structure of "Mixed Type".</p>
     866                                                <p>This means that your menu will contain both the items you create within
     867                                                    AllWebMenus ("static") and the items you import from WordPress
     868                                                    ("dynamic").</p>
     869                                                <p>The imported Wordpress items will use the styles of the AllWebMenus Style
     870                                                    Editor but their actual content will be populated "dynamically" based on the
     871                                                    plugin settings.</p>
     872                                                <p>The static items you create within AllWebMenus will be shown as is.</p>
     873                                                <p><a href="https://www.likno.com/blog/wordpress-javascript-menu/1184/"
     874                                                      target="_blank">View a short presentation explaining all your settings</a>
     875                                                </p>
     876                                            </div>
     877                                            <div class="awm_itemInfo"
     878                                                 id="AWM_menu_type_<?php echo $awm_t; ?>_Static_info" <?php echo $myrows[$awm_t]->type == 'Static' ? '' : 'style="display:none;"'; ?>>
     879                                                <p style="margin-top: 0px; padding-top: 0px;">You have selected to create a menu
     880                                                    structure of "Static Type".</p>
     881                                                <p>Your menu will be edited (addition/removal/customization of items) within
     882                                                    AllWebMenus only.</p>
     883                                                <p>Any changes on your online blog will not affect the menu items unless you
     884                                                    perform the "Publish menu" action to generate an updated &quot;Menu
     885                                                    Structure Code&quot; and re-import it to AllWebMenus.</p>
     886                                                <p>This allows for maximum customization, as your online menu will show all
     887                                                    items and styles customized within AllWebMenus.</p>
     888                                                <p><a href="https://www.likno.com/blog/wordpress-javascript-menu/1184/"
     889                                                      target="_blank">View a short presentation explaining all your settings</a>
     890                                                </p>
     891                                            </div>
     892                                        </td>
     893                                    </tr>
     894
     895                                    <tr>
     896                                        <td colspan="2">&nbsp;</td>
     897                                    </tr>
     898                                </table>
     899
     900
     901                                <div class="AWM_section">Menu Positioning Method</div>
     902
     903
     904                                <div style="padding: 20px 0;">
     905                                    <select style="margin-left: 20px;"
     906                                            onchange="awm_menu_position(this.value , <?php echo $awm_t; ?>)"
     907                                            name="awm_menu_position_<?php echo $awm_t; ?>"
     908                                            id="awm_menu_position_<?php echo $awm_t; ?>">
     909                                        <option
     910                                            value="0" <?php selected(isset($myrows[$awm_t]->position) && $myrows[$awm_t]->position == 0); ?>>
     911                                            Custom position
     912                                        </option>
     913                                        <?php global $wp_registered_sidebars;
     914                                        global $wp_version;
     915                                        if ((float)$wp_version >= 2.2 && count($wp_registered_sidebars > 1)):?>
     916                                        <option
     917                                            value="awm_widget" <?php selected(isset($myrows[$awm_t]->position) && $myrows[$awm_t]->position == "awm_widget"); ?>>
     918                                            Widget
     919                                        </option>
     920                                        <?php endif; ?>
     921                                        <?php if (count($locations)): ?>
     922                                        <?php
     923                                        foreach ($locations as $location => $description) {
     924                                        ?>
     925                                        <option<?php selected(isset($myrows[$awm_t]->position) && $myrows[$awm_t]->position == $location); ?>
     926                                            value="<?php echo $location; ?>">Theme Menu Location: <?php
     927                                        echo $location . '&hellip;';
     928                                        ?></option>
     929                                        <?php
     930                                        }
     931                                        ?>
     932                                    </select>
     933
     934                                    <div class="awm_menu_position"
     935                                         id="awm_custom_menu_position_<?php echo $awm_t; ?>" <?php if ($myrows[$awm_t]->position != '0') {
     936                                        echo 'style="display: none;"';
     937                                    } ?>>You have selected the <em>Custom</em> positioning method.<br/><br/>This means that you
     938                                        should manually add a positioning DIV element (or image) into your blog's HTML code,
     939                                        based on the settings that you specified within AllWebMenus ("Positioning" property). In
     940                                        case you selected the "Relative to Window" option there, no positioning element needs to
     941                                        be added to your blog's HTML.
     942                                    </div>
     943                                    <div class="awm_menu_position"
     944                                         id="awm_widget_menu_position_<?php echo $awm_t; ?>" <?php if ($myrows[$awm_t]->position != "awm_widget") {
     945                                        echo 'style="display: none;"';
     946                                    } ?>>You have selected the <em>Widget</em> positioning method.<br/><br/>
     947                                        A widget instance for this menu is initially created and found in the <a
     948                                            href="<?php echo admin_url('widgets.php'); ?>#wp_inactive_widgets">widgets
     949                                            administration page</a>, under the "Inactive Widgets" section. Just drag this widget
     950                                        instance and drop it inside the Widget Area that you want.
     951                                        <br/><br/> ***Note: this method applies ONLY when you ALSO use the "Relative to Element"
     952                                        positioning option within your AllWebMenus project (without changing its "Default ID"
     953                                        selection)***
     954                                    </div>
     955                                    <div class="awm_menu_position"
     956                                         id="awm_theme_menu_position_<?php echo $awm_t; ?>" <?php if ($myrows[$awm_t]->position == "awm_widget" || $myrows[$awm_t]->position == '0') {
     957                                        echo 'style="display: none;"';
     958                                    } ?>>
     959                                        You have selected the <em>Theme Menu Location</em> positioning method.<br/><br/>
     960                                        This means that your menu will be positioned based on the "Menu Location" that your
     961                                        Blog's Theme provides.
     962                                        <br/><br/> ***Note: this method applies ONLY when you ALSO use the "Relative to Element"
     963                                        positioning option within your AllWebMenus project (without changing its "Default ID"
     964                                        selection)***
     965                                    </div>
     966
     967
     968                                </div>
     969                                <?php endif; ?>
     970
     971
     972                                <div class="AWM_section">Collaboration with external plugins</div>
     973                                <table width="100%" height="auto" style="padding-left: 40px;">
     974                                    <tr>
     975                                        <td colspan="2">&nbsp;</td>
     976                                    </tr>
     977
     978                                    <tr>
     979                                        <td width="230" valign="top"><strong>Related Posts (YARPP):</strong>
     980                                            <?php if ( ! $this->awm_is_yarpp_enabled) { ?><br><span class='awm_itemInfo'
     981                                                                                                    style='color:#990000;'>Currently not installed and activated</span>
     982                                            <br><span class="awm_itemInfo"><a
     983                                                href="https://wordpress.org/extend/plugins/yet-another-related-posts-plugin/"
     984                                                target="_blank">get it here</a></span>
     985                                            <?php
     986                                            } ?>
     987                                        </td>
     988                                        <td valign="top"><input type="checkbox" name="AWM_Related_<?php echo $awm_t; ?>"
     989                                                                value="checkbox" <?php if ($myrows[$awm_t]->related) {
     990                                            echo "checked='checked'";
     991                                        }
     992                                        if ( ! $this->awm_is_yarpp_enabled) {
     993                                            echo "disabled='disabled'";
     994                                        } else {
     995                                            echo "onclick=\"awm_disable_input(this.checked,$awm_t,'related');\"";
     996                                        } ?>/>
     997                                            Show a "Related Posts" item when viewing a post
     998                                        </td>
     999                                    <tr>
     1000                                        <td width="230" valign="top">&nbsp;</td>
     1001                                        <td>
     1002                                            <?php if ($this->awm_is_yarpp_enabled) { ?>
     1003                                            <br>
     1004                                            <label for="AWM_Related_name_<?php echo $awm_t; ?>">Name of the 'Related Posts'
     1005                                                item: </label><input name="AWM_Related_name_<?php echo $awm_t; ?>"
     1006                                                                     id="awm_related_name_<?php echo $awm_t; ?>"
     1007                                                                     value="<?php echo $myrows[$awm_t]->related_name ?>"<?php if ( ! $myrows[$awm_t]->related) {
     1008                                            echo "disabled='disabled'";
     1009                                        } ?>/>
     1010                                            <div class="awm_itemInfo">
     1011                                                <p style="margin-top: 0px; padding-top: 0px;">This feature uses the
     1012                                                    3rd-party "Related Posts (YARPP)" plugin, which needs to be installed
     1013                                                    separately.</p>
     1014                                                <p>It dynamically adds a "Related Posts" item at the end of the Main Menu,
     1015                                                    with a submenu that contains posts related to the post you are currently
     1016                                                    viewing, regardless of the menu type you have selected.</p>
     1017                                                <p>The "Related Posts" item appears only when viewing a single post.</p>
     1018                                            </div>
     1019                                            <?php } else { ?>
     1020                                            <div class="awm_itemInfo">
     1021                                                <p style="margin-top: 0px; padding-top: 0px;"><span style="color: #990000;">Note!</span>
     1022                                                    It seems that the "Related Posts (YARPP)" Plugin is not installed and
     1023                                                    activated so this option is disabled.</p>
     1024                                                <p>This feature uses the 3rd-party "Related Posts (YARPP)" plugin, which
     1025                                                    needs to be installed separately.</p>
     1026                                                <p>It dynamically adds a "Related Posts" item at the end of the Main Menu,
     1027                                                    with a submenu that contains posts related to the post you are currently
     1028                                                    viewing, regardless of the menu type you have selected.</p>
     1029                                                <p>The "Related Posts" item appears only when viewing a single post.</p>
     1030                                            </div>
     1031                                            <?php } ?>
     1032                                        </td>
     1033                                    </tr>
     1034
     1035                                    <tr>
     1036                                        <td colspan="2">&nbsp;</td>
     1037                                    </tr>
     1038                                    <tr>
     1039                                        <td colspan="2">&nbsp;</td>
     1040                                    </tr>
     1041                                </table>
     1042                            </fieldset>
     1043                        </div>
     1044                        <script
     1045                            type="text/javascript">awm_select_structure(<?php echo $myrows[$awm_t]->custom_menu ? "true" : "false";?>,<?php echo $awm_t;?>);</script>
     1046                        <?php
     1047                        }    // end of tab body for loop
     1048                        ?>
     1049                    </div>    <!-- tab_bodies -->
     1050                </div>    <!-- tab_wrapper -->
     1051
     1052                <br>
     1053                <br>
     1054                <div style="text-align: center;" class="awm_itemInfo"><span style="color:#990000;">Note:</span> Always click the
     1055                    "Save settings" button below to apply your changes. If you leave this page without saving you will lose your
     1056                    unsaved changes.
     1057                </div>
     1058                <div class="submit" style="text-align: center;">
     1059                    <input type="button" name="info_update" value="Save settings"
     1060                           onclick="theform.theaction.value='info_update'; awm_form_validate();"/>
     1061                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     1062                    <input type="button" name="generate_structure" value="Publish menu (also saves changes in settings) &raquo;"
     1063                           onclick="theform.theaction.value='generate_structure'; awm_form_validate();"/>
     1064                </div>
     1065
     1066                <input type="hidden" name="theaction" value=""/>
     1067
     1068                <?php if ($this->awm_total_tabs) : ?>
     1069                <script type="text/javascript">
     1070                    AWM_TOTAL_TABS_JS = <?php echo $this->awm_total_tabs;?>;
     1071                    awm_show_tab(<?php echo get_option('AWM_selected_tab'); ?>);
     1072                    awm_show_welcome(<?php echo get_option('AWM_show_welcome') ? "true" : "false"; ?>);
     1073                </script>
     1074                <?php endif; ?>
     1075
     1076        </div>
     1077        </form>
     1078
     1079    </div>    <!-- END OF SETTINGS SCREEN -->
     1080</div>    <!-- END OF PUBLISH/SETTINGS SCREEN -->
     1081    <?php
     1082
     1083    }    // END of AWM_options_page()
     1084
     1085    /*
     1086     * Special filter to work with wordpress menu system
     1087     */
     1088    function awm_menu_position($items, $args)
     1089    {
     1090        if (isset($this->awm_wp_nav_array[$args->theme_location])) {
     1091            return $items . "<div id='" . $this->awm_wp_nav_array[$args->theme_location] . "'>&nbsp;</div>";
     1092        } else {
     1093            return $items;
     1094        }
     1095    }
     1096
     1097    function awm_print_menu_position($args)
     1098    {
     1099        $myrows = $this->wpdb->get_results("SELECT name FROM $this->awm_table_name WHERE position LIKE '" . $args['theme_location'] . "' && active = 1 ORDER BY id ASC");
     1100        foreach ($myrows as $myrow) {
     1101            echo "<div id=awmAnchor-" . $myrow->name . ">&nbsp;</div>";
     1102        }
     1103    }
     1104
     1105    function awm_menu_args($args)
     1106    {
     1107        $args = (object)$args;
     1108        $args->fallback_cb = 'AWM_print_menu_position';
     1109        return $args;
     1110    }
     1111
     1112    /*
     1113     * Generate Linking Code
     1114     */
     1115    function AWM_generate_linking_code()
     1116    {
     1117        $filter_flag = false;
     1118        $myrows = $this->wpdb->get_results("SELECT * FROM $this->awm_table_name WHERE active=1 order by id ASC");
     1119        for ($awm_t = 0; $awm_t < count($myrows); $awm_t++) {
     1120            $gnr = $myrows[$awm_t]->menu_genre;
     1121            $tp = $myrows[$awm_t]->type;
     1122            $revs = $myrows[$awm_t]->menu_revisions;
     1123            if ($myrows[$awm_t]->position != "0" && $myrows[$awm_t]->position != "awm_widget") {
     1124                $this->awm_wp_nav_array[$myrows[$awm_t]->position] = "awmAnchor-" . $myrows[$awm_t]->name;
     1125                $filter_flag = true;
    3961126            }
    397         } else {
    398             echo "<option value='-1'>No WordPress menus found!</option>";
     1127            $awm_name = $myrows[$awm_t]->name;
     1128
     1129            echo "<!-- ******** BEGIN ALLWEBMENUS CODE FOR " . $awm_name . " ($gnr MENU)******** -->\n";
     1130            if ($gnr == "JS" || $gnr == "ULLI") {
     1131                echo "<script type='text/javascript'>var MenuLinkedBy='AllWebMenus [4]',awmMenuName='" . $awm_name . "',awmBN='WP';awmAltUrl='';</script>\n";
     1132                echo "<script charset='UTF-8' src='" . site_url() . get_option('AWM_menu_path') . $awm_name . ".js' type='text/javascript'></script>\n";
     1133                echo "<script type='text/javascript'>" . ($gnr == "JS" ? "if (typeof(Menu)!='undefined') " : "") . "awmBuildMenu();\n";
     1134                echo "<!-- -------  Add your Server-Side code right after this comment  ---------- -->\n";
     1135                if ($gnr == "ULLI") {
     1136                    echo "</script>\n";
     1137                }
     1138            } elseif ($gnr == "CSS") {
     1139                echo "<link href='" . site_url() . get_option('AWM_menu_path') . $awm_name . ".css' rel='stylesheet' type='text/css' />\n";
     1140                echo "<script charset='UTF-8' src='" . site_url() . get_option('AWM_menu_path') . $awm_name . ".js' type='text/javascript'></script>\n";
     1141            }
     1142
     1143            if ($gnr == "JS") {
     1144                for ($i = 1; $i <= $revs; $i++) {
     1145                    if ($tp == 'Dynamic') {
     1146                        AWM_create_dynamic_menu($myrows[$awm_t], false, ($i > 1) ? "_rm" . $i : "");
     1147                    } elseif ($tp == 'Mixed') {
     1148                        AWM_create_dynamic_menu($myrows[$awm_t], true, ($i > 1) ? "_rm" . $i : "");
     1149                    }
     1150                }
     1151            } elseif ($gnr == "ULLI" || $gnr == "CSS") {
     1152                $dyn_code = "";
     1153                if ($tp == 'Dynamic' || $tp == 'Mixed') {
     1154                    $dyn_code = AWM_create_ULLI_dynamic_menu($myrows[$awm_t], "");
     1155                }
     1156                //          echo $myrows[$awm_t]->menu_structure;
     1157                echo str_replace("<!--DYNAMIC STRUCTURE CODE-->", $dyn_code, $myrows[$awm_t]->menu_structure);
     1158            }
     1159
     1160
     1161            if ($gnr == "JS") {
     1162                // only if we are viewing a single post & want related (and not custom menu)
     1163                if ($this->awm_is_yarpp_enabled && $myrows[$awm_t]->related && is_single() && ! $myrows[$awm_t]->custom_menu) {
     1164                    // convert quotes to add code to item's <Text> property
     1165                    $awm_related = related_posts(array('before_related' => '<p>' . $myrows[$awm_t]->related_name . '</p><ol>'), false);
     1166                    $awm_related = str_replace('"', "'", $awm_related);
     1167                    $awm_related = str_replace("'", "\'", $awm_related);
     1168                    $awm_related = str_replace(chr(10), "", $awm_related);
     1169                    $awm_related = str_replace(chr(13), "", $awm_related);
     1170                    $awm_related = str_replace('\n', '', $awm_related);
     1171                    $awm_related = str_replace('\r', '', $awm_related);
     1172                    $awm_related = trim($awm_related);
     1173
     1174                    $awm_parentgroup = "wpgroup";
     1175                    echo "IRP=$awm_parentgroup.newItem('style=" . $awm_name . "_'+(wplevel==0?'main_item_style':'sub_item_style')+';visible=0');\n";
     1176                    echo "IRP.visible=1; IRP.text0='" . $myrows[$awm_t]->related_name . "'; IRP.text1='" . $myrows[$awm_t]->related_name . "'; IRP.text2='" . $myrows[$awm_t]->related_name . "';\n";
     1177                    echo "IRP1=IRP.newGroup('style=" . $awm_name . "_'+(wplevel==0?'sub_group_style':'sub_group_plus_style'));\n";
     1178                    echo "IRP2=IRP1.newItem('style=" . $awm_name . "_'+(wplevel==0?'sub_item_style':'sub_item_plus_style')+';text0=" . $awm_related . ";htmlMode=1;');\n";
     1179                }
     1180                echo "if (typeof(" . $awm_name . ")!='undefined') ProduceMenu(" . $awm_name . ");\n";
     1181                echo "</script>\n";
     1182            }
     1183            echo "<!-- ******** END ALLWEBMENUS CODE FOR " . $awm_name . " ($gnr MENU)******** -->\n\n";
    3991184        }
    400 ?>
    401                                     </select>&nbsp;&nbsp;&nbsp;&nbsp;<span class="awm_itemInfo"><a href="nav-menus.php">Add/Edit WordPress menus</a></span
    402                                 </td></tr>
    403                             </table>
    404                         </td></tr>
    405                         <tr><td>&nbsp;</td></tr>
    406                         <tr><td><input onclick="awm_select_structure(false,<?php echo $awm_t;?>);" name="AWM_use_custom_menu_<?php echo $awm_t;?>" value="0" type="radio"<?php if (!$myrows[$awm_t]->custom_menu) echo "checked='checked'"; ?> />&nbsp;Menu is populated with specific "pages", "posts", "categories", etc. (check to choose items)</td></tr>
    407                         <tr><td id="AWM_menu_structure_use_own_<?php echo $awm_t;?>" width="100%">
    408                             <table width="100%" height="auto" style="padding-left: 20px;">
    409                                 <tr><td colspan="2"><p>Please select the items you want to include/exclude in your menu structure:</p></td></tr>
    410                                 <tr><td colspan="2">&nbsp;</td></tr>
    411                                 <tr><td width="230"><input name="AWM_include_home_<?php echo $awm_t;?>" type="checkbox" value="true" <?php if ($myrows[$awm_t]->include_home) echo "checked='checked'"; ?> /> <strong>"Home"</strong></td>
    412                                 <td class="awm_itemInfo">A "Home" item that opens the blog's Home Page.</td></tr>
    413 
    414                                 <tr><td colspan="2">&nbsp;</td></tr>
    415                                 <tr><td colspan="2">&nbsp;</td></tr>
    416 
    417                                 <tr><td width="230" VALIGN="TOP"><input onclick="awm_show_field(this.checked,<?php echo $awm_t;?>,'pages');" name="AWM_pages_<?php echo $awm_t;?>" type="checkbox" <?php if ($myrows[$awm_t]->pages) echo "checked='checked'"; ?> /> <strong>Pages<span id="awm_pages_dots_<?php echo $awm_t;?>"><?php if ($myrows[$awm_t]->pages):?>:<?php else:?> ...<?php endif;?></span></strong></td>
    418                                 <td>
    419                                                                     <fieldset id="awm_pages_fieldset_<?php echo $awm_t?>" <?php if (!$myrows[$awm_t]->pages)echo 'style="display:none"';?>>
    420                                                                     <span style="color: #009900">Show all Pages</span> <span style="color: #990000">except the following:</span><br />
    421                                                                 <input name="AWM_excluded_pages_<?php echo $awm_t;?>" type="text" size="55" value="<?php echo $myrows[$awm_t]->excluded_pages ?>"/>
    422 
    423                                 <br /><span class="awm_itemInfo">Page IDs, separated by commas (their sub-pages will also be excluded). Example: 34, 59, 140</span>
    424 
    425                                                                 <br />
    426                                 <br />
    427                                                                 <input onclick="awm_disable_input(false,<?php echo $awm_t;?>,'pages');" name="AWM_pages_ms_<?php echo $awm_t;?>" value="main" type="radio" <?php if ($myrows[$awm_t]->pages_ms == 'main') echo "checked='checked'"; ?> />&nbsp;Show Pages as Main Menu items
    428                                 <br /><input onclick="awm_disable_input(true,<?php echo $awm_t;?>,'pages');" name="AWM_pages_ms_<?php echo $awm_t;?>" value="sub" type="radio"<?php if ($myrows[$awm_t]->pages_ms != 'main') echo "checked='checked'"; ?> />&nbsp;Show a Main Menu item named <input <?php if ($myrows[$awm_t]->pages_ms == 'main') echo "disabled='disabled'"; ?> id="awm_pages_name_<?php echo $awm_t;?>" name="AWM_pages_name_<?php echo $awm_t;?>" type="text" size="10" value="<?php echo $myrows[$awm_t]->pages_name ?>"/>
    429                                 and show Pages as its submenu items
    430                                 <br/>
    431 
    432                                                                 </fieldset>
    433                                                                     <br/>
    434                                                                 <br/>
    435 
    436                                                                 </td></tr>
    437 
    438                                 <tr><td valign="top" width="230"><input onclick="awm_show_field(this.checked,<?php echo $awm_t;?>,'posts');" name="AWM_posts_<?php echo $awm_t;?>" type="checkbox" <?php if ($myrows[$awm_t]->posts) echo "checked='checked'"; ?> /> <strong>Posts<span id="awm_posts_dots_<?php echo $awm_t;?>"><?php if ($myrows[$awm_t]->posts):?>:<?php else:?> ...<?php endif;?></span></strong></td>
    439                                 <td>
    440                                                                     <fieldset id="awm_posts_fieldset_<?php echo $awm_t?>" <?php if (!$myrows[$awm_t]->posts)echo 'style="display:none"';?>>
    441                                                                         <span style="display: block;color: #009900">Show the following Posts:</span>
    442                                 <input name="AWM_posts_ids_<?php echo $awm_t;?>" type="text" size="55" value="<?php echo $myrows[$awm_t]->posts_ids ?>"/>
    443                                 <br />
    444                                 <span class="awm_itemInfo">Post IDs, separated by commas. Example: 34, 59, 140</span>
    445                                                                 <br />
    446                                 <br />
    447                                 <input onclick="awm_disable_input(false,<?php echo $awm_t;?>,'posts');" name="AWM_posts_ms_<?php echo $awm_t;?>" value="main" type="radio" <?php if ($myrows[$awm_t]->posts_ms == 'main') echo "checked='checked'"; ?> />&nbsp;Show Posts as Main Menu items
    448                                                                 <br />
    449 
    450                                 <input onclick="awm_disable_input(true,<?php echo $awm_t;?>,'posts');" name="AWM_posts_ms_<?php echo $awm_t;?>" value="sub" type="radio"<?php if ($myrows[$awm_t]->posts_ms != 'main') echo "checked='checked'"; ?> />&nbsp;Show a Main Menu item named <input <?php if ($myrows[$awm_t]->posts_ms == 'main') echo "disabled='disabled'"; ?> id="awm_posts_name_<?php echo $awm_t;?>" name="AWM_posts_name_<?php echo $awm_t;?>" type="text" size="10" value="<?php echo $myrows[$awm_t]->posts_name ?>"/>
    451                                 and show Posts as its submenu items
    452                                 <br />
    453 
    454                                                                 </fieldset>
    455                                                                     <br />
    456                                                                 <br />
    457                                 </td></tr>
    458                                 <tr><td valign="top" width="230"><input onclick="awm_show_field(this.checked,<?php echo $awm_t;?>,'categories');" name="AWM_categories_<?php echo $awm_t;?>" type="checkbox" <?php if ($myrows[$awm_t]->categories) echo "checked='checked'"; ?> /> <strong>Categories<span id="awm_categories_dots_<?php echo $awm_t;?>"><?php if ($myrows[$awm_t]->categories):?>:<?php else:?> ...<?php endif;?></span></strong></td>
    459                                 <td>
    460                                                                     <fieldset id="awm_categories_fieldset_<?php echo $awm_t?>" <?php if (!$myrows[$awm_t]->categories)echo 'style="display:none"';?>>
    461                                                                         <span style="color: #009900">Show all Categories</span> <span style="color: #990000">except the following:</span><br/>
    462 
    463                                 <input name="AWM_excluded_cats_<?php echo $awm_t;?>" type="text" size="55" value="<?php echo $myrows[$awm_t]->excluded_cats ?>"/><br />
    464                                 <span class="awm_itemInfo">Category IDs, separated by commas (their sub-categories will also be excluded). Example: 34, 59, 140</span><br />
    465                                                                 <input onclick="document.getElementById('awm_categories_subitems_no_<?php echo $awm_t;?>').disabled=!this.checked" name="AWM_categories_subitems_<?php echo $awm_t;?>" type="checkbox" <?php if ($myrows[$awm_t]->categories_subitems) echo "checked='checked'"; ?> /> Also show (up to) the <input onblur="awm_max_min_value(this , <?php echo $awm_t?>);" onkeyup="awm_max_min_value(this,  <?php echo $awm_t?> );" onkeypress="return awm_disable_value(this,event);" <?php if (!$myrows[$awm_t]->categories_subitems) echo "disabled='disabled'"; ?> id="awm_categories_subitems_no_<?php echo $awm_t;?>" name="AWM_categories_subitems_no_<?php echo $awm_t;?>" type="text" size="2" value="<?php echo $myrows[$awm_t]->categories_subitems_no ?>"/> newest posts of each Category as its submenu items<br />
    466                                 <span class="awm_itemInfo" id="awm_max_value_notice_<?php echo $awm_t;?>">Value must be between 1 and 50.</span>
    467                                 <br />
    468                                                                 <br />
    469                                 <input onclick="awm_disable_input(false,<?php echo $awm_t;?>,'categories');"name="AWM_categories_ms_<?php echo $awm_t;?>" value="main" type="radio" <?php if ($myrows[$awm_t]->categories_ms == 'main') echo "checked='checked'"; ?> />&nbsp;Show Categories as Main Menu items<br />
    470 
    471                                 <input onclick="awm_disable_input(true,<?php echo $awm_t;?>,'categories');"name="AWM_categories_ms_<?php echo $awm_t;?>" value="sub" type="radio" <?php if ($myrows[$awm_t]->categories_ms != 'main') echo "checked='checked'"; ?> />&nbsp;Show a Main Menu item named <input <?php if ($myrows[$awm_t]->categories_ms == 'main') echo "disabled='disabled'"; ?> id="awm_categories_name_<?php echo $awm_t;?>" name="AWM_categories_name_<?php echo $awm_t;?>" type="text" size="10" value="<?php echo $myrows[$awm_t]->categories_name ?>"/>
    472                                 and show Categories as its submenu items<br />
    473                                 </fieldset>
    474                                 <br />
    475                                                                 <br />
    476 
    477 
    478 
    479                             </table>
    480                         </td></tr>
    481 
    482                         <tr><td>&nbsp;</td></tr></table>
    483                                                 <div class="AWM_section">Other options for menu items</div>
    484 
    485                                                 <fieldset class="awm_other">
    486                             <input type="checkbox" name="AWM_hide_future_<?php echo $awm_t;?>" value="checkbox" <?php if ($myrows[$awm_t]->hide_future) echo "checked='checked'"; ?>/> Hide future-dated posts
    487                             <input type="checkbox" name="AWM_hide_protected_<?php echo $awm_t;?>" value="checkbox" <?php if ($myrows[$awm_t]->hide_protected) echo "checked='checked'"; ?>/> Hide password-protected items
    488                             <input type="checkbox" name="AWM_hide_private_<?php echo $awm_t;?>" value="checkbox" <?php if ($myrows[$awm_t]->hide_private) echo "checked='checked'"; ?>/> Hide private items
    489                                                  </fieldset>
    490 
    491                                                 </fieldset>
    492 
    493 
    494 
    495                                     <div class="AWM_section">Menu Type</div>
    496                     <p>Please select how you want your menu to behave:</p>
    497 
    498                     <input type="hidden" id="awm_initial_menu_type_<?php echo $awm_t;?>" value="<?php echo $myrows[$awm_t]->type;?>"/>
    499                     <table width="100%" height="auto" style="padding-left: 40px;">
    500                         <tr><td colspan="2">&nbsp;</td></tr>
    501                         <tr><td colspan="2" id="awm_changed_type_a_<?php echo $awm_t;?>" class="updated fade" style="display: none;">
    502                                 <span style="color: #990000;">&quot;Menu Type&quot; changed:</span> New behavior will take effect only when you perform the "Publish menu" action to generate an updated &quot;Menu Structure Code&quot; and re-import it to AllWebMenus.
    503                         </td></tr>
    504                         <tr><td colspan="2" id="awm_changed_type_b_<?php echo $awm_t;?>">&nbsp;</td></tr>
    505 
    506                         <tr><td width="230" valign="top"><table>
    507                             <tr><td><span style="cursor: pointer;" onclick="awm_select_menu_type('Dynamic',<?php echo $awm_t;?>);"><strong><input id="AWM_menu_type_<?php echo $awm_t;?>_Dynamic" name="AWM_menu_type_<?php echo $awm_t;?>" value="Dynamic" type="radio" <?php if ($myrows[$awm_t]->type == 'Dynamic') echo "checked='checked'"; ?> />&nbsp;"Dynamic" Menu Type</strong></span></td></tr>
    508                             <tr><td><span style="cursor: pointer;" onclick="awm_select_menu_type('Mixed',  <?php echo $awm_t;?>);"><strong><input id="AWM_menu_type_<?php echo $awm_t;?>_Mixed" name="AWM_menu_type_<?php echo $awm_t;?>" value="Mixed" type="radio" <?php if ($myrows[$awm_t]->type == 'Mixed') echo "checked='checked'"; ?> />&nbsp;"Mixed" Menu Type</strong></span></td></tr>
    509                             <tr><td><span style="cursor: pointer;" onclick="awm_select_menu_type('Static', <?php echo $awm_t;?>);"><strong><input id="AWM_menu_type_<?php echo $awm_t;?>_Static" name="AWM_menu_type_<?php echo $awm_t;?>" value="Static" type="radio" <?php if ($myrows[$awm_t]-> type == 'Static') echo "checked='checked'"; ?> />&nbsp;"Static" Menu Type</strong></span></td></tr>
    510                         </table></td><td valign="top">
    511                             <div class="awm_itemInfo" id="AWM_menu_type_<?php echo $awm_t;?>_Dynamic_info" <?php echo $myrows[$awm_t]->type=='Dynamic'?'':'style="display:none;"'; ?>>
    512                                 <p style="margin-top: 0px; padding-top: 0px;">You have selected to create a menu structure of "Dynamic Type".</p>
    513                                 <p>This means that the menu items in AllWebMenus will only be used for preview/styling purposes.</p>
    514                                 <p>In your actual blog these items will be ignored and the menu will be populated "dynamically" based on the plugin settings.</p>
    515                                 <p>The styles in AllWebMenus Style Editor will be used to form the actual menu items.</p>
    516                                 <p><a href="http://www.likno.com/blog/wordpress-javascript-menu/1184/" target="_blank">View a short presentation explaining all your settings</a></p>
    517                             </div>
    518                             <div class="awm_itemInfo" id="AWM_menu_type_<?php echo $awm_t;?>_Mixed_info" <?php echo $myrows[$awm_t]->type =='Mixed'?'':'style="display:none;"'; ?>>
    519                                 <p style="margin-top: 0px; padding-top: 0px;">You have selected to create a menu structure of "Mixed Type".</p>
    520                                 <p>This means that your menu will contain both the items you create within AllWebMenus ("static") and the items you import from WordPress ("dynamic").</p>
    521                                 <p>The imported Wordpress items will use the styles of the AllWebMenus Style Editor but their actual content will be populated "dynamically" based on the plugin settings.</p>
    522                                 <p>The static items you create within AllWebMenus will be shown as is.</p>
    523                                 <p><a href="http://www.likno.com/blog/wordpress-javascript-menu/1184/" target="_blank">View a short presentation explaining all your settings</a></p>
    524                             </div>
    525                             <div class="awm_itemInfo" id="AWM_menu_type_<?php echo $awm_t;?>_Static_info" <?php echo $myrows[$awm_t]->type=='Static'?'':'style="display:none;"'; ?>>
    526                                 <p style="margin-top: 0px; padding-top: 0px;">You have selected to create a menu structure of "Static Type".</p>
    527                                 <p>Your menu will be edited (addition/removal/customization of items) within AllWebMenus only.</p>
    528                                 <p>Any changes on your online blog will not affect the menu items unless you perform the "Publish menu" action to generate an updated &quot;Menu Structure Code&quot; and re-import it to AllWebMenus.</p>                             
    529                                 <p>This allows for maximum customization, as your online menu will show all items and styles customized within AllWebMenus.</p>
    530                                 <p><a href="http://www.likno.com/blog/wordpress-javascript-menu/1184/" target="_blank">View a short presentation explaining all your settings</a></p>
    531                             </div>
    532                         </td></tr>
    533 
    534                         <tr><td colspan="2">&nbsp;</td></tr>
    535                     </table>
    536 
    537 
    538 
    539                                         <div class="AWM_section">Menu Positioning Method</div>
    540 
    541 
    542                                            
    543                 <div style="padding: 20px 0;">
    544                 <select style="margin-left: 20px;" onchange="awm_menu_position(this.value , <?php echo $awm_t;?>)" name="awm_menu_position_<?php echo $awm_t;?>" id="awm_menu_position_<?php echo $awm_t;?>">
    545                                             <option value="0" <?php selected( isset( $myrows[$awm_t]->position ) && $myrows[$awm_t]->position == 0 ); ?>>Custom position</option>
    546                                             <?php global $wp_registered_sidebars;
    547                                             global $wp_version;
    548                                             if ((float)$wp_version>=2.2 &&  count($wp_registered_sidebars > 1)):?>
    549                                             <option value="awm_widget" <?php selected( isset( $myrows[$awm_t]->position ) && $myrows[$awm_t]->position == "awm_widget" ); ?>>Widget</option>
    550                                             <?php endif;?>
    551                                             <?php  if (count($locations)):?>
    552                  <?php
    553                                         foreach ( $locations as $location => $description ) {
    554         ?>
    555                     <option<?php selected( isset( $myrows[$awm_t]->position ) && $myrows[$awm_t]->position == $location ); ?>
    556                         value="<?php echo $location; ?>">Theme Menu Location: <?php
    557                         echo $location . '&hellip;';
    558                     ?></option>
    559     <?php
    560     }
     1185        if ($filter_flag) {
     1186            echo "<script> jQuery(document).ready( function (){jQuery('div[id*=\'awmAnchor\']').siblings('.genesis-nav-menu').remove();});</script>";  // genesis_markup case
     1187            add_filter('wp_nav_menu', array($this, 'awm_menu_position'), 10, 2);
     1188            add_filter('wp_nav_menu_args', array($this, 'awm_menu_args'), 10, 1);
     1189        }
     1190    }
     1191
     1192
     1193    /*
     1194     * Initialize query var for sitemap permalinks
     1195     */
     1196    function AWM_query_vars($awm_vars)
     1197    {
     1198        $awm_vars[] = "pg";
     1199        return $awm_vars;
     1200    }
     1201
     1202    //add_filter('query_vars', 'AWM_query_vars');
     1203
     1204
     1205    }    // END of Class AWM_Plugin
     1206
     1207
     1208    //this functions calls the object's generate linking code
     1209    function AWM_generate_linking_code()
     1210    {
     1211        global $awmPluginInstance;
     1212        $awmPluginInstance->AWM_generate_linking_code();
     1213    }
     1214
     1215    //this functions is the callback function that calls the function that prints the div at the Menu Position
     1216    function AWM_print_menu_position($args)
     1217    {
     1218        global $awmPluginInstance;
     1219        $awmPluginInstance->awm_print_menu_position($args);
     1220    }
     1221
    5611222    ?>
    562                                         </select>
    563 
    564                                     <div class="awm_menu_position" id="awm_custom_menu_position_<?php echo $awm_t;?>" <?php if ($myrows[$awm_t]->position != '0') echo 'style="display: none;"';?>>You have selected the <em>Custom</em> positioning method.<br/><br/>This means that you should manually add a positioning DIV element (or image) into your blog's HTML code, based on the settings that you specified within AllWebMenus ("Positioning" property). In case you selected the "Relative to Window" option there, no positioning element needs to be added to your blog's HTML.</div>
    565                                     <div class="awm_menu_position" id="awm_widget_menu_position_<?php echo $awm_t;?>" <?php if ($myrows[$awm_t]->position !="awm_widget") echo 'style="display: none;"';?>>You have selected the <em>Widget</em> positioning method.<br /><br/>
    566                                         A widget instance for this menu is initially created and found in the <a href="<?php echo admin_url('widgets.php');?>#wp_inactive_widgets">widgets administration page</a>, under the "Inactive Widgets" section. Just drag this widget instance and drop it inside the Widget Area that you want.
    567                                         <br/><br/> ***Note: this method applies ONLY when you ALSO use the "Relative to Element" positioning option within your AllWebMenus project (without changing its "Default ID" selection)***</div>
    568                                     <div class="awm_menu_position" id="awm_theme_menu_position_<?php echo $awm_t;?>" <?php if ($myrows[$awm_t]->position =="awm_widget" || $myrows[$awm_t]->position == '0') echo 'style="display: none;"';?>>
    569                                         You have selected the <em>Theme Menu Location</em> positioning method.<br /><br/>
    570                                         This means that your menu will be positioned based on the "Menu Location" that your Blog's Theme provides.
    571                                         <br/><br/> ***Note: this method applies ONLY when you ALSO use the "Relative to Element" positioning option within your AllWebMenus project (without changing its "Default ID" selection)***</div>
    572                                
    573 
    574 
    575         </div>
    576                                         <?php endif;?>
    577                    
    578 
    579                     <div class="AWM_section">Collaboration with external plugins</div>
    580                     <table width="100%" height="auto" style="padding-left: 40px;">
    581                         <tr><td colspan="2">&nbsp;</td></tr>
    582 
    583                         <tr><td width="230" valign="top"><strong>Related Posts (YARPP):</strong>
    584                         <?php if (!$this->awm_is_yarpp_enabled) {?><br><span class='awm_itemInfo' style='color:#990000;'>Currently not installed and activated</span>
    585                         <br><span class="awm_itemInfo"><a href="http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/" target="_blank">get it here</a></span>
    586                                                     <?php
    587                                                 }?>
    588                                                     </td>
    589                         <td valign="top"><input type="checkbox" name="AWM_Related_<?php echo $awm_t;?>" value="checkbox" <?php if ($myrows[$awm_t]->related) echo "checked='checked'"; if (!$this->awm_is_yarpp_enabled) echo "disabled='disabled'";else echo "onclick=\"awm_disable_input(this.checked,$awm_t,'related');\""; ?>/>
    590                         Show a "Related Posts" item when viewing a post</td>
    591                         <tr><td width="230" valign="top">&nbsp;</td>
    592                         <td >
    593                             <?php if ($this->awm_is_yarpp_enabled) { ?>
    594                                                                 <br>
    595                                                                 <label for="AWM_Related_name_<?php echo $awm_t;?>" >Name of the 'Related Posts' item: </label><input name="AWM_Related_name_<?php echo $awm_t;?>" id="awm_related_name_<?php echo $awm_t;?>" value="<?php echo $myrows[$awm_t]->related_name?>"<?php if (!$myrows[$awm_t]->related) echo "disabled='disabled'"; ?>/>
    596                                 <div class="awm_itemInfo">
    597                                                                 <p style="margin-top: 0px; padding-top: 0px;" >This feature uses the 3rd-party "Related Posts (YARPP)" plugin, which needs to be installed separately.</p>
    598                                 <p>It dynamically adds a "Related Posts" item at the end of the Main Menu, with a submenu that contains posts related to the post you are currently viewing, regardless of the menu type you have selected.</p>
    599                                 <p>The "Related Posts" item appears only when viewing a single post.</p>
    600                                                                 </div>
    601                             <?php } else { ?>
    602                                                                 <div class="awm_itemInfo">
    603                                 <p style="margin-top: 0px; padding-top: 0px;" ><span style="color: #990000;">Note!</span> It seems that the "Related Posts (YARPP)" Plugin is not installed and activated so this option is disabled.</p>
    604                                 <p>This feature uses the 3rd-party "Related Posts (YARPP)" plugin, which needs to be installed separately.</p>
    605                                 <p>It dynamically adds a "Related Posts" item at the end of the Main Menu, with a submenu that contains posts related to the post you are currently viewing, regardless of the menu type you have selected.</p>
    606                                 <p>The "Related Posts" item appears only when viewing a single post.</p>
    607                                                                 </div>
    608                             <?php } ?>
    609                         </td></tr>
    610 
    611                         <tr><td colspan="2">&nbsp;</td></tr>
    612                         <tr><td colspan="2">&nbsp;</td></tr>
    613                     </table>
    614                 </fieldset>
    615             </div>
    616             <script type="text/javascript">awm_select_structure(<?php echo $myrows[$awm_t]->custom_menu?"true":"false";?>,<?php echo $awm_t;?>);</script>
    617 <?php
    618     }   // end of tab body for loop
    619 ?>
    620         </div>  <!-- tab_bodies -->
    621     </div>  <!-- tab_wrapper -->
    622 
    623     <br>
    624     <br>
    625     <div style="text-align: center;" class="awm_itemInfo"><span style="color:#990000;">Note:</span> Always click the "Save settings" button below to apply your changes. If you leave this page without saving you will lose your unsaved changes.</div>
    626     <div class="submit" style="text-align: center;">
    627         <input type="button" name="info_update" value="Save settings" onclick="theform.theaction.value='info_update'; awm_form_validate();"/>
    628         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    629         <input type="button" name="generate_structure" value="Publish menu (also saves changes in settings) &raquo;" onclick="theform.theaction.value='generate_structure'; awm_form_validate();"/>
    630     </div>
    631 
    632     <input type="hidden" name="theaction" value="" />
    633 
    634         <?php if ($this->awm_total_tabs) :?>
    635     <script type="text/javascript">
    636         AWM_TOTAL_TABS_JS = <?php echo $this->awm_total_tabs;?>;
    637         awm_show_tab(<?php echo get_option('AWM_selected_tab'); ?>);
    638         awm_show_welcome(<?php echo get_option('AWM_show_welcome')?"true":"false"; ?>);
    639     </script>
    640         <?php endif;?>
    641 
    642 </div>
    643 </form>
    644 
    645 </div>  <!-- END OF SETTINGS SCREEN -->
    646 </div>  <!-- END OF PUBLISH/SETTINGS SCREEN -->
    647 <?php
    648 
    649 }   // END of AWM_options_page()
    650 
    651 /*
    652  * Special filter to work with wordpress menu system
    653  */
    654 function awm_menu_position( $items, $args) {
    655     if (isset($this->awm_wp_nav_array[$args->theme_location]))
    656         return $items."<div id='".$this->awm_wp_nav_array[$args->theme_location]."'>&nbsp;</div>";
    657     else
    658         return $items;
    659 }
    660 
    661 function awm_print_menu_position($args) {
    662    $myrows =  $this->wpdb->get_results("SELECT name FROM $this->awm_table_name WHERE position LIKE '". $args['theme_location']."' && active = 1 ORDER BY id ASC" );
    663    foreach ($myrows as $myrow)
    664        echo "<div id=awmAnchor-".$myrow->name.">&nbsp;</div>";
    665 }
    666 
    667 function awm_menu_args($args) {
    668     $args = (object) $args;
    669     $args->fallback_cb = 'AWM_print_menu_position';
    670     return $args;
    671 }
    672 /*
    673  * Generate Linking Code
    674  */
    675 function AWM_generate_linking_code() {
    676     $filter_flag = false;
    677     $myrows = $this->wpdb->get_results( "SELECT * FROM $this->awm_table_name WHERE active=1 order by id ASC" );
    678     for ($awm_t=0; $awm_t<count($myrows); $awm_t++) {
    679         $gnr = $myrows[$awm_t]->menu_genre;
    680         $tp = $myrows[$awm_t]->type;
    681         $revs = $myrows[$awm_t]->menu_revisions;
    682         if ( $myrows[$awm_t]->position !=  "0" && $myrows[$awm_t]->position !=  "awm_widget") {
    683             $this->awm_wp_nav_array[$myrows[$awm_t]->position] = "awmAnchor-".$myrows[$awm_t]->name;
    684             $filter_flag = true;
    685         }
    686         $awm_name = $myrows[$awm_t]->name;
    687        
    688         echo "<!-- ******** BEGIN ALLWEBMENUS CODE FOR " . $awm_name . " ($gnr MENU)******** -->\n";
    689         if ($gnr=="JS" || $gnr=="ULLI") {
    690             echo "<script type='text/javascript'>var MenuLinkedBy='AllWebMenus [4]',awmMenuName='" . $awm_name . "',awmBN='WP';awmAltUrl='';</script>\n";
    691             echo "<script charset='UTF-8' src='" . site_url() . get_option('AWM_menu_path') . $awm_name . ".js' type='text/javascript'></script>\n";
    692             echo "<script type='text/javascript'>".($gnr=="JS"?"if (typeof(Menu)!='undefined') ":"")."awmBuildMenu();\n";
    693             echo "<!-- -------  Add your Server-Side code right after this comment  ---------- -->\n";
    694             if ($gnr=="ULLI") echo "</script>\n";
    695         } elseif ($gnr=="CSS") {
    696             echo "<link href='". site_url() . get_option('AWM_menu_path') .$awm_name.".css' rel='stylesheet' type='text/css' />\n";
    697             echo "<script charset='UTF-8' src='". site_url() . get_option('AWM_menu_path') .$awm_name.".js' type='text/javascript'></script>\n";
    698         }
    699 
    700         if ($gnr=="JS") {
    701             for ($i=1; $i<=$revs; $i++) {
    702                 if ($tp=='Dynamic') {
    703                     AWM_create_dynamic_menu($myrows[$awm_t],false, ($i>1)?"_rm".$i:"");
    704                 } elseif ($tp=='Mixed') {
    705                     AWM_create_dynamic_menu($myrows[$awm_t],true, ($i>1)?"_rm".$i:"");
    706                 }
    707             }
    708         } elseif ($gnr=="ULLI" || $gnr=="CSS") {
    709             $dyn_code = "";
    710             if ($tp=='Dynamic' || $tp=='Mixed') $dyn_code = AWM_create_ULLI_dynamic_menu($myrows[$awm_t], "");
    711 //          echo $myrows[$awm_t]->menu_structure;
    712             echo str_replace("<!--DYNAMIC STRUCTURE CODE-->",$dyn_code,$myrows[$awm_t]->menu_structure);
    713         }
    714 
    715 
    716        
    717         if ($gnr=="JS") {
    718             // only if we are viewing a single post & want related (and not custom menu)
    719             if ($this->awm_is_yarpp_enabled && $myrows[$awm_t]->related && is_single() && !$myrows[$awm_t]->custom_menu) {
    720                 // convert quotes to add code to item's <Text> property
    721                 $awm_related = related_posts(array('before_related'=> '<p>'.$myrows[$awm_t]->related_name.'</p><ol>' ), false);
    722                 $awm_related = str_replace('"', "'", $awm_related);
    723                 $awm_related = str_replace("'", "\'", $awm_related);
    724                 $awm_related = str_replace(chr(10), "", $awm_related);
    725                 $awm_related = str_replace(chr(13), "", $awm_related);
    726                 $awm_related = str_replace('\n', '', $awm_related);
    727                 $awm_related = str_replace('\r', '', $awm_related);
    728                 $awm_related = trim($awm_related);
    729                
    730                 $awm_parentgroup = "wpgroup";
    731                 echo "IRP=$awm_parentgroup.newItem('style=". $awm_name ."_'+(wplevel==0?'main_item_style':'sub_item_style')+';visible=0');\n";
    732                 echo "IRP.visible=1; IRP.text0='".$myrows[$awm_t]->related_name."'; IRP.text1='".$myrows[$awm_t]->related_name."'; IRP.text2='".$myrows[$awm_t]->related_name."';\n";
    733                 echo "IRP1=IRP.newGroup('style=". $awm_name ."_'+(wplevel==0?'sub_group_style':'sub_group_plus_style'));\n";
    734                 echo "IRP2=IRP1.newItem('style=". $awm_name ."_'+(wplevel==0?'sub_item_style':'sub_item_plus_style')+';text0=" . $awm_related . ";htmlMode=1;');\n";
    735             }
    736             echo "if (typeof(" . $awm_name . ")!='undefined') ProduceMenu(" . $awm_name . ");\n";
    737             echo "</script>\n";
    738         }
    739         echo "<!-- ******** END ALLWEBMENUS CODE FOR " . $awm_name . " ($gnr MENU)******** -->\n\n";
    740     }
    741     if ($filter_flag) {
    742        echo "<script> jQuery(document).ready( function (){jQuery('div[id*=\'awmAnchor\']').siblings('.genesis-nav-menu').remove();});</script>";  // genesis_markup case
    743         add_filter('wp_nav_menu', array($this,'awm_menu_position'), 10, 2);
    744         add_filter('wp_nav_menu_args',array($this,'awm_menu_args'), 10 ,1);
    745     }
    746 }
    747 
    748 
    749 
    750 /*
    751  * Initialize query var for sitemap permalinks
    752  */
    753 function AWM_query_vars ( $awm_vars ) {
    754     $awm_vars[] = "pg";
    755     return $awm_vars;
    756 }
    757 
    758 //add_filter('query_vars', 'AWM_query_vars');
    759 
    760 
    761 }   // END of Class AWM_Plugin
    762 
    763 
    764 //this functions calls the object's generate linking code
    765 function AWM_generate_linking_code(){
    766     global $awmPluginInstance;
    767     $awmPluginInstance->AWM_generate_linking_code();
    768 }
    769 //this functions is the callback function that calls the function that prints the div at the Menu Position
    770 function AWM_print_menu_position($args){
    771     global $awmPluginInstance;
    772     $awmPluginInstance->awm_print_menu_position($args);
    773 }
    774 ?>
  • allwebmenus-wordpress-menu-plugin/trunk/include.php

    r1165179 r2008056  
    11<?php
    22/* automatically adds code to header.php file*/
    3 function awm_add_code(){
    4     if (!defined ('TEMPLATEPATH') || !defined('STYLESHEETPATH') )
     3function awm_add_code()
     4{
     5    if ( ! defined('TEMPLATEPATH') || ! defined('STYLESHEETPATH')) {
    56        wp_templating_constants();
     7    }
    68    $file_path = locate_template(array("header.php"));
    7     if (!empty($file_path))
    8         $file = @file_get_contents( $file_path );
    9     else
     9    if ( ! empty($file_path)) {
     10        $file = @file_get_contents($file_path);
     11    } else {
    1012        return false;
     13    }
    1114    //checking if htmp.tpl.php is writable
    1215    $wantedPerms = octdec("0755");
    13     $actualPerms = octdec(substr(sprintf("%o",fileperms($file_path)),-4));
    14    
    15     if($actualPerms < $wantedPerms){
    16         if (!chmod ( $file_path , $wantedPerms )){
     16    $actualPerms = octdec(substr(sprintf("%o", fileperms($file_path)), -4));
     17
     18    if ($actualPerms < $wantedPerms) {
     19        if ( ! chmod($file_path, $wantedPerms)) {
    1720            return false;
    1821        }
    1922    }
    20     if (substr_count($file,'AWM_generate_linking_code')==0) {
    21         // genesis_markup case
    22         if (substr_count($file,'genesis_markup')!=0) {
    23             $file = str_replace("do_action( 'genesis_before' );", "if (function_exists('AWM_generate_linking_code'))AWM_generate_linking_code();\ndo_action( 'genesis_before' );", $file);
    24         }
    25         // generic case
    26         else
    27         {
    28         preg_match ( "/<body([^\?>])*(<\?([^>])*\?>([^>\?])*)*>/", $file, $matches );
    29         if (count($matches)>0) {
    30             $pieces = explode($matches[0],$file);
    31             if (count($pieces) == 2) {
    32                 $file =$pieces[0].$matches[0]."\n<?php if (function_exists('AWM_generate_linking_code'))AWM_generate_linking_code(); ?>".$pieces[1];
    33             }
    34         } else {
    35             if ($actualPerms < $wantedPerms) @chmod ( $file_path , $actualPerms );
    36             return false;
    37         }
    38     }
    39                 $fp = fopen($file_path, 'w');
    40                 if (!$fp) {
    41                     if ($actualPerms < $wantedPerms) @chmod ( $file_path , $actualPerms );
    42                     return false;
    43                 }
    44                fwrite($fp, $file);
    45                fclose($fp);
    46                 if ($actualPerms < $wantedPerms) @chmod ( $file_path , $actualPerms );
    47                return true;
    48             }
    49     if ($actualPerms < $wantedPerms) @chmod ( $file_path , $actualPerms );
     23    if (substr_count($file, 'AWM_generate_linking_code') == 0) {
     24        // genesis_markup case
     25        if (substr_count($file, 'genesis_markup') != 0) {
     26            $file = str_replace("do_action( 'genesis_before' );",
     27                "if (function_exists('AWM_generate_linking_code'))AWM_generate_linking_code();\ndo_action( 'genesis_before' );", $file);
     28        } // generic case
     29        else {
     30            preg_match("/<body([^\?>])*(<\?([^>])*\?>([^>\?])*)*>/", $file, $matches);
     31            if (count($matches) > 0) {
     32                $pieces = explode($matches[0], $file);
     33                if (count($pieces) == 2) {
     34                    $file = $pieces[0] . $matches[0] . "\n<?php if (function_exists('AWM_generate_linking_code'))AWM_generate_linking_code(); ?>" . $pieces[1];
     35                }
     36            } else {
     37                if ($actualPerms < $wantedPerms) {
     38                    @chmod($file_path, $actualPerms);
     39                }
     40                return false;
     41            }
     42        }
     43        $fp = fopen($file_path, 'w');
     44        if ( ! $fp) {
     45            if ($actualPerms < $wantedPerms) {
     46                @chmod($file_path, $actualPerms);
     47            }
     48            return false;
     49        }
     50        fwrite($fp, $file);
     51        fclose($fp);
     52        if ($actualPerms < $wantedPerms) {
     53            @chmod($file_path, $actualPerms);
     54        }
     55        return true;
     56    }
     57    if ($actualPerms < $wantedPerms) {
     58        @chmod($file_path, $actualPerms);
     59    }
    5060    return true;
    5161}
    5262
    5363/* This code sets the plugin up for first-time-run */
    54 function awm_set_first_time_options() {
    55     add_option('AWM_menu_path', str_ireplace(home_url(), "", plugins_url())."/allwebmenus-wordpress-menu-plugin/menu/");
    56     add_option('AWM_Checked', FALSE);
    57     add_option('AWM_Check_show', TRUE);
    58     add_option('AWM_show_welcome', TRUE);
     64function awm_set_first_time_options()
     65{
     66    add_option('AWM_menu_path', str_ireplace(home_url(), "", plugins_url()) . "/allwebmenus-wordpress-menu-plugin/menu/");
     67    add_option('AWM_Checked', false);
     68    add_option('AWM_Check_show', true);
     69    add_option('AWM_show_welcome', true);
    5970    add_option('AWM_Checked_Date', '00');
    6071    add_option('AWM_selected_tab', '0');
     
    6273
    6374/* This code sets the default option values for a given tab */
    64 function awm_set_default_option_values($awm_t) {
     75function awm_set_default_option_values($awm_t)
     76{
    6577    global $wpdb, $awm_table_name;
    66     $wpdb->update( $awm_table_name, array( 'name' => (string) "menu".$awm_t ,'pages_name'=>'Pages','pages_ms'=>'main','posts_name'=>'Posts','posts_ms'=>'sub','categories_ms'=>'sub','categories_name'=>'Categories','type'=>'Dynamic','genre'=>'JS' ),array('id'=>$_POST['AWM_menu_id_'.$awm_t]) );
    67 //  update_option('AWM_menu_path', '/menu/');
     78    $wpdb->update($awm_table_name,
     79        array('name' => (string)"menu" . $awm_t, 'pages_name' => 'Pages', 'pages_ms' => 'main', 'posts_name' => 'Posts', 'posts_ms' => 'sub', 'categories_ms' => 'sub', 'categories_name' => 'Categories', 'type' => 'Dynamic', 'genre' => 'JS'),
     80        array('id' => $_POST['AWM_menu_id_' . $awm_t]));
     81    //  update_option('AWM_menu_path', '/menu/');
    6882}
    6983
    7084/* This code converts the options from old single-tab version to multi-tab */
    71 function awm_convert_from_single_to_multi_tab() {
     85function awm_convert_from_single_to_multi_tab()
     86{
    7287    global $awm_total_tabs;
    73     add_option('AWM_menu_name','nowayyouhavethisvalue');    // first create an impossible value
    74     if (get_option('AWM_menu_name')=='nowayyouhavethisvalue') { // if the option now has this value, it did not exist (this means you already have the new version
     88    add_option('AWM_menu_name', 'nowayyouhavethisvalue');    // first create an impossible value
     89    if (get_option('AWM_menu_name') == 'nowayyouhavethisvalue') {    // if the option now has this value, it did not exist (this means you already have the new version
    7590        delete_option('AWM_menu_name');
    76     } else {                                        // else you had the old so you need to convert
    77         for ($awm_t=0; $awm_t<$awm_total_tabs; $awm_t++) {
    78             update_option('AWM_include_home_'.$awm_t, get_option('AWM_include_home'));
    79             update_option('AWM_pages_'.$awm_t, get_option('AWM_pages'));
    80             update_option('AWM_pages_ms_'.$awm_t, get_option('AWM_pages_ms'));
    81             update_option('AWM_pages_name_'.$awm_t, get_option('AWM_pages_name'));
    82             update_option('AWM_posts_'.$awm_t, get_option('AWM_posts'));
    83             update_option('AWM_posts_ms_'.$awm_t, get_option('AWM_posts_ms'));
    84             update_option('AWM_posts_name_'.$awm_t, get_option('AWM_posts_name'));
    85             update_option('AWM_posts_ids_'.$awm_t, get_option('AWM_posts_ids'));
    86             update_option('AWM_categories_'.$awm_t, get_option('AWM_categories'));
    87             update_option('AWM_categories_ms_'.$awm_t, get_option('AWM_categories_ms'));
    88             update_option('AWM_categories_name_'.$awm_t, get_option('AWM_categories_name'));
    89             update_option('AWM_categories_subitems_'.$awm_t, get_option('AWM_categories_subitems'));
    90             update_option('AWM_categories_subitems_no_'.$awm_t, get_option('AWM_categories_subitems_no'));
    91             update_option('AWM_hide_future_'.$awm_t, get_option('AWM_hide_future'));
    92             update_option('AWM_hide_protected_'.$awm_t, get_option('AWM_hide_protected'));
    93             update_option('AWM_excluded_cats_'.$awm_t, get_option('AWM_excluded_cats'));
    94             update_option('AWM_excluded_pages_'.$awm_t, get_option('AWM_excluded_pages'));
    95             update_option('AWM_Related_'.$awm_t, get_option('AWM_Related'));
     91    } else {                                        // else you had the old so you need to convert
     92        for ($awm_t = 0; $awm_t < $awm_total_tabs; $awm_t++) {
     93            update_option('AWM_include_home_' . $awm_t, get_option('AWM_include_home'));
     94            update_option('AWM_pages_' . $awm_t, get_option('AWM_pages'));
     95            update_option('AWM_pages_ms_' . $awm_t, get_option('AWM_pages_ms'));
     96            update_option('AWM_pages_name_' . $awm_t, get_option('AWM_pages_name'));
     97            update_option('AWM_posts_' . $awm_t, get_option('AWM_posts'));
     98            update_option('AWM_posts_ms_' . $awm_t, get_option('AWM_posts_ms'));
     99            update_option('AWM_posts_name_' . $awm_t, get_option('AWM_posts_name'));
     100            update_option('AWM_posts_ids_' . $awm_t, get_option('AWM_posts_ids'));
     101            update_option('AWM_categories_' . $awm_t, get_option('AWM_categories'));
     102            update_option('AWM_categories_ms_' . $awm_t, get_option('AWM_categories_ms'));
     103            update_option('AWM_categories_name_' . $awm_t, get_option('AWM_categories_name'));
     104            update_option('AWM_categories_subitems_' . $awm_t, get_option('AWM_categories_subitems'));
     105            update_option('AWM_categories_subitems_no_' . $awm_t, get_option('AWM_categories_subitems_no'));
     106            update_option('AWM_hide_future_' . $awm_t, get_option('AWM_hide_future'));
     107            update_option('AWM_hide_protected_' . $awm_t, get_option('AWM_hide_protected'));
     108            update_option('AWM_excluded_cats_' . $awm_t, get_option('AWM_excluded_cats'));
     109            update_option('AWM_excluded_pages_' . $awm_t, get_option('AWM_excluded_pages'));
     110            update_option('AWM_Related_' . $awm_t, get_option('AWM_Related'));
    96111        }
    97112
    98113        $awm_mn = explode(",", get_option('AWM_menu_name'));
    99         for ($awm_i=0; $awm_i<count($awm_mn) && $awm_i<$awm_total_tabs; $awm_i++) {
     114        for ($awm_i = 0; $awm_i < count($awm_mn) && $awm_i < $awm_total_tabs; $awm_i++) {
    100115            $awm_n = awm_fix_menu_name(trim($awm_mn[$awm_i]));
    101             update_option('AWM_use_custom_menu_'.$awm_t, FALSE);
    102             update_option('AWM_use_custom_menu_id_'.$awm_t, '');
    103             update_option('AWM_menu_name_'.$awm_i, $awm_n);
    104             update_option('AWM_menu_active_'.$awm_i, TRUE);
     116            update_option('AWM_use_custom_menu_' . $awm_t, false);
     117            update_option('AWM_use_custom_menu_id_' . $awm_t, '');
     118            update_option('AWM_menu_name_' . $awm_i, $awm_n);
     119            update_option('AWM_menu_active_' . $awm_i, true);
    105120        }
    106121
     
    134149
    135150/* This code converts the plugin to database version */
    136 function awm_convert_to_database() {
    137     global $dataArray,$awm_table_name,$wpdb,$awm_total_tabs;
    138     if ( isset($awm_total_tabs) ) {
    139         if($wpdb->get_var("SHOW TABLES LIKE '$awm_table_name'") != $awm_table_name) {
     151function awm_convert_to_database()
     152{
     153    global $dataArray, $awm_table_name, $wpdb, $awm_total_tabs;
     154    if (isset($awm_total_tabs)) {
     155        if ($wpdb->get_var("SHOW TABLES LIKE '$awm_table_name'") != $awm_table_name) {
    140156            $sql = "CREATE TABLE " . $awm_table_name . " (
    141157                id mediumint(9) NOT NULL AUTO_INCREMENT,
     
    168184                UNIQUE KEY id (id)
    169185            );";
    170            
     186
    171187            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    172188            dbDelta($sql);
    173            
     189
    174190            if ($wpdb->get_var("SHOW TABLES LIKE '$awm_table_name'") != $awm_table_name) {
    175191                return "Could not create table. Please check your privileges";
    176192            }
    177             if ( $awm_total_tabs == 0) {
     193            if ($awm_total_tabs == 0) {
    178194                awm_create_new_menu(true);
    179195                update_option('AWM_selected_tab', 0);
    180196            }
    181197        }
    182         for ($awm_t=0; $awm_t<$awm_total_tabs; $awm_t++) {
    183             $dataArray[$awm_t]['custom_menu'] = get_option('AWM_use_custom_menu_'.$awm_t);
    184             $dataArray[$awm_t]['custom_menu_id'] = get_option('AWM_use_custom_menu_id_'.$awm_t);
    185             $dataArray[$awm_t]['active'] = get_option('AWM_menu_active_'.$awm_t);
    186             $dataArray[$awm_t]['type'] = get_option('AWM_menu_type_'.$awm_t);
    187             $dataArray[$awm_t]['name'] = get_option('AWM_menu_name_'.$awm_t);
    188             $dataArray[$awm_t]['include_home'] = get_option('AWM_include_home_'.$awm_t);
    189             $dataArray[$awm_t]['pages'] = get_option('AWM_pages_'.$awm_t);
    190             $dataArray[$awm_t]['pages_ms'] =  get_option('AWM_pages_ms_'.$awm_t);
    191             $dataArray[$awm_t]['pages_name'] = get_option('AWM_pages_name_'.$awm_t);
    192             $dataArray[$awm_t]['excluded_pages'] =  get_option('AWM_excluded_pages_'.$awm_t);
    193             $dataArray[$awm_t]['posts'] = get_option('AWM_posts_'.$awm_t);
    194             $dataArray[$awm_t]['posts_ms'] = get_option('AWM_posts_ms_'.$awm_t);
    195             $dataArray[$awm_t]['posts_name'] = get_option('AWM_posts_name_'.$awm_t);
    196             $dataArray[$awm_t]['posts_ids'] = get_option('AWM_posts_ids_'.$awm_t);
    197             $dataArray[$awm_t]['categories'] = get_option('AWM_categories_'.$awm_t);
    198             $dataArray[$awm_t]['categories_ms'] =  get_option('AWM_categories_ms_'.$awm_t);
    199             $dataArray[$awm_t]['categories_name'] =  get_option('AWM_categories_name_'.$awm_t);
    200             $dataArray[$awm_t]['categories_subitems'] = get_option('AWM_categories_subitems_'.$awm_t);
    201             $dataArray[$awm_t]['categories_subitems_no'] = get_option('AWM_categories_subitems_no_'.$awm_t);
    202             $dataArray[$awm_t]['excluded_cats'] =  get_option('AWM_excluded_cats_'.$awm_t);
    203             $dataArray[$awm_t]['hide_future'] = get_option('AWM_hide_future_'.$awm_t);
    204             $dataArray[$awm_t]['hide_protected'] = get_option('AWM_hide_protected_'.$awm_t);
    205             $dataArray[$awm_t]['hide_private'] = get_option('AWM_hide_private_'.$awm_t);
    206             $dataArray[$awm_t]['Related'] =  get_option('AWM_Related_'.$awm_t);
    207             $dataArray[$awm_t]['position'] =  0;
    208                    
    209             if ($wpdb->insert( $awm_table_name, $dataArray[$awm_t])) {
    210                 delete_option('AWM_include_home_'.$awm_t);
    211                 delete_option('AWM_pages_'.$awm_t);
    212                 delete_option('AWM_pages_ms_'.$awm_t);
    213                 delete_option('AWM_pages_name_'.$awm_t);
    214                 delete_option('AWM_exluded_pages_'.$awm_t);
    215                 delete_option('AWM_posts_'.$awm_t);
    216                 delete_option('AWM_posts_ms_'.$awm_t);
    217                 delete_option('AWM_posts_name_'.$awm_t);
    218                 delete_option('AWM_posts_ids_'.$awm_t);
    219                 delete_option('AWM_categories_'.$awm_t);
    220                 delete_option('AWM_categories_ms_'.$awm_t);
    221                 delete_option('AWM_categories_name_'.$awm_t);
    222                 delete_option('AWM_categories_subitems_'.$awm_t);
    223                 delete_option('AWM_categories_subitems_no_'.$awm_t);
    224                 delete_option('AWM_archives_'.$awm_t);
    225                 delete_option('AWM_hide_future_'.$awm_t);
    226                 delete_option('AWM_new_window_'.$awm_t);
    227                 delete_option('AWM_show_post_date_'.$awm_t);
    228                 delete_option('AWM_date_format_'.$awm_t);
    229                 delete_option('AWM_hide_protected_'.$awm_t);
    230                 delete_option('AWM_excluded_cats_'.$awm_t);
    231                 delete_option('AWM_menu_name_'.$awm_t);
    232                 delete_option('AWM_Related_'.$awm_t);
    233             }
    234         }
    235        
     198        for ($awm_t = 0; $awm_t < $awm_total_tabs; $awm_t++) {
     199            $dataArray[$awm_t]['custom_menu'] = get_option('AWM_use_custom_menu_' . $awm_t);
     200            $dataArray[$awm_t]['custom_menu_id'] = get_option('AWM_use_custom_menu_id_' . $awm_t);
     201            $dataArray[$awm_t]['active'] = get_option('AWM_menu_active_' . $awm_t);
     202            $dataArray[$awm_t]['type'] = get_option('AWM_menu_type_' . $awm_t);
     203            $dataArray[$awm_t]['name'] = get_option('AWM_menu_name_' . $awm_t);
     204            $dataArray[$awm_t]['include_home'] = get_option('AWM_include_home_' . $awm_t);
     205            $dataArray[$awm_t]['pages'] = get_option('AWM_pages_' . $awm_t);
     206            $dataArray[$awm_t]['pages_ms'] = get_option('AWM_pages_ms_' . $awm_t);
     207            $dataArray[$awm_t]['pages_name'] = get_option('AWM_pages_name_' . $awm_t);
     208            $dataArray[$awm_t]['excluded_pages'] = get_option('AWM_excluded_pages_' . $awm_t);
     209            $dataArray[$awm_t]['posts'] = get_option('AWM_posts_' . $awm_t);
     210            $dataArray[$awm_t]['posts_ms'] = get_option('AWM_posts_ms_' . $awm_t);
     211            $dataArray[$awm_t]['posts_name'] = get_option('AWM_posts_name_' . $awm_t);
     212            $dataArray[$awm_t]['posts_ids'] = get_option('AWM_posts_ids_' . $awm_t);
     213            $dataArray[$awm_t]['categories'] = get_option('AWM_categories_' . $awm_t);
     214            $dataArray[$awm_t]['categories_ms'] = get_option('AWM_categories_ms_' . $awm_t);
     215            $dataArray[$awm_t]['categories_name'] = get_option('AWM_categories_name_' . $awm_t);
     216            $dataArray[$awm_t]['categories_subitems'] = get_option('AWM_categories_subitems_' . $awm_t);
     217            $dataArray[$awm_t]['categories_subitems_no'] = get_option('AWM_categories_subitems_no_' . $awm_t);
     218            $dataArray[$awm_t]['excluded_cats'] = get_option('AWM_excluded_cats_' . $awm_t);
     219            $dataArray[$awm_t]['hide_future'] = get_option('AWM_hide_future_' . $awm_t);
     220            $dataArray[$awm_t]['hide_protected'] = get_option('AWM_hide_protected_' . $awm_t);
     221            $dataArray[$awm_t]['hide_private'] = get_option('AWM_hide_private_' . $awm_t);
     222            $dataArray[$awm_t]['Related'] = get_option('AWM_Related_' . $awm_t);
     223            $dataArray[$awm_t]['position'] = 0;
     224
     225            if ($wpdb->insert($awm_table_name, $dataArray[$awm_t])) {
     226                delete_option('AWM_include_home_' . $awm_t);
     227                delete_option('AWM_pages_' . $awm_t);
     228                delete_option('AWM_pages_ms_' . $awm_t);
     229                delete_option('AWM_pages_name_' . $awm_t);
     230                delete_option('AWM_exluded_pages_' . $awm_t);
     231                delete_option('AWM_posts_' . $awm_t);
     232                delete_option('AWM_posts_ms_' . $awm_t);
     233                delete_option('AWM_posts_name_' . $awm_t);
     234                delete_option('AWM_posts_ids_' . $awm_t);
     235                delete_option('AWM_categories_' . $awm_t);
     236                delete_option('AWM_categories_ms_' . $awm_t);
     237                delete_option('AWM_categories_name_' . $awm_t);
     238                delete_option('AWM_categories_subitems_' . $awm_t);
     239                delete_option('AWM_categories_subitems_no_' . $awm_t);
     240                delete_option('AWM_archives_' . $awm_t);
     241                delete_option('AWM_hide_future_' . $awm_t);
     242                delete_option('AWM_new_window_' . $awm_t);
     243                delete_option('AWM_show_post_date_' . $awm_t);
     244                delete_option('AWM_date_format_' . $awm_t);
     245                delete_option('AWM_hide_protected_' . $awm_t);
     246                delete_option('AWM_excluded_cats_' . $awm_t);
     247                delete_option('AWM_menu_name_' . $awm_t);
     248                delete_option('AWM_Related_' . $awm_t);
     249            }
     250        }
     251
    236252        delete_option('AWM_total_menus');
    237         if($wpdb->get_var("show columns from $awm_table_name LIKE 'related_name'")!= 'related_name'){
    238             $wpdb->query("ALTER TABLE ".$awm_table_name." ADD related_name tinytext NOT NULL DEFAULT ''");
     253        if ($wpdb->get_var("show columns from $awm_table_name LIKE 'related_name'") != 'related_name') {
     254            $wpdb->query("ALTER TABLE " . $awm_table_name . " ADD related_name tinytext NOT NULL DEFAULT ''");
    239255            $wpdb->query("UPDATE $awm_table_name SET related_name='Related Posts'");
    240256        }
     
    244260}
    245261
    246 function awm_add_genre_column() {
     262function awm_add_genre_column()
     263{
    247264    global $awm_total_tabs, $awm_table_name, $wpdb;
    248     if($wpdb->get_var("show columns from $awm_table_name LIKE 'menu_genre'")!= 'menu_genre'){
    249         $wpdb->query("ALTER TABLE ".$awm_table_name." ADD menu_genre tinytext NOT NULL DEFAULT ''");
    250         $wpdb->query("ALTER TABLE ".$awm_table_name." ADD menu_structure text NOT NULL DEFAULT ''");
     265    if ($wpdb->get_var("show columns from $awm_table_name LIKE 'menu_genre'") != 'menu_genre') {
     266        $wpdb->query("ALTER TABLE " . $awm_table_name . " ADD menu_genre tinytext NOT NULL DEFAULT ''");
     267        $wpdb->query("ALTER TABLE " . $awm_table_name . " ADD menu_structure text NOT NULL DEFAULT ''");
    251268        $wpdb->query("UPDATE $awm_table_name SET menu_genre='JS'");
    252269    }
    253270}
    254271
    255 function awm_add_revision_column() {
     272function awm_add_revision_column()
     273{
    256274    global $awm_total_tabs, $awm_table_name, $wpdb;
    257     if($wpdb->get_var("show columns from $awm_table_name LIKE 'menu_revisions'")!= 'menu_revisions'){
    258         $wpdb->query("ALTER TABLE ".$awm_table_name." ADD menu_revisions tinytext NOT NULL DEFAULT ''");
     275    if ($wpdb->get_var("show columns from $awm_table_name LIKE 'menu_revisions'") != 'menu_revisions') {
     276        $wpdb->query("ALTER TABLE " . $awm_table_name . " ADD menu_revisions tinytext NOT NULL DEFAULT ''");
    259277        $wpdb->query("UPDATE $awm_table_name SET menu_revisions='1'");
    260278    }
     
    262280
    263281/* This code creates new menu */
    264 function awm_create_new_menu($firstTime = false) {
    265     update_option('AWM_show_welcome', FALSE);
    266     global $wpdb,$awm_table_name;
     282function awm_create_new_menu($firstTime = false)
     283{
     284    update_option('AWM_show_welcome', false);
     285    global $wpdb, $awm_table_name;
    267286    $rows_affected = $wpdb->insert($awm_table_name, array('name' => ""));
    268287    $i = 1;
    269     while ($wpdb->get_var("SELECT COUNT(*) as cnt from $awm_table_name where name LIKE 'menu".$i."'")) {
     288    while ($wpdb->get_var("SELECT COUNT(*) as cnt from $awm_table_name where name LIKE 'menu" . $i . "'")) {
    270289        $i++;
    271290    }
    272     $wpdb->update( $awm_table_name, array( 'active' => $firstTime,'name' => (string) "menu".$i ,'pages_name'=>'Pages','pages_ms'=>'main','posts_name'=>'Posts','posts_ms'=>'sub','categories_ms'=>'sub','categories_name'=>'Categories','type'=>'Dynamic' ),array('id'=>$wpdb->insert_id) );
     291    $wpdb->update($awm_table_name,
     292        array('active' => $firstTime, 'name' => (string)"menu" . $i, 'pages_name' => 'Pages', 'pages_ms' => 'main', 'posts_name' => 'Posts', 'posts_ms' => 'sub', 'categories_ms' => 'sub', 'categories_name' => 'Categories', 'type' => 'Dynamic'),
     293        array('id' => $wpdb->insert_id));
    273294    return '<div class="updated fade"><p><strong>Additional menu succesfully created.</strong></p></div>';
    274295}
    275296
    276 function awm_delete_menu(){
    277     update_option('AWM_show_welcome', FALSE);
    278     global $wpdb,$awm_table_name, $awm_total_tabs;
    279     if ($awm_total_tabs == 1)
    280         return  "This is the last menu. You cannot delete it.";
    281     $wpdb->query("DELETE from $awm_table_name where id =".(int) $_POST['AWM_menu_id']);
    282     awm_delete_widget_instance((int) $_POST['AWM_menu_id'], true);
    283     if ((int) $_POST["AWM_selected_tab_c"] == ($awm_total_tabs-1) &&  get_option('AWM_selected_tab') == (int) $_POST["AWM_selected_tab_c"])
    284         update_option('AWM_selected_tab', ((int) $_POST["AWM_selected_tab_c"])-1);
    285     return  "Menu deleted succesfully.";
    286 }           
     297function awm_delete_menu()
     298{
     299    update_option('AWM_show_welcome', false);
     300    global $wpdb, $awm_table_name, $awm_total_tabs;
     301    if ($awm_total_tabs == 1) {
     302        return "This is the last menu. You cannot delete it.";
     303    }
     304    $wpdb->query("DELETE from $awm_table_name where id =" . (int)$_POST['AWM_menu_id']);
     305    awm_delete_widget_instance((int)$_POST['AWM_menu_id'], true);
     306    if ((int)$_POST["AWM_selected_tab_c"] == ($awm_total_tabs - 1) && get_option('AWM_selected_tab') == (int)$_POST["AWM_selected_tab_c"]) {
     307        update_option('AWM_selected_tab', ((int)$_POST["AWM_selected_tab_c"]) - 1);
     308    }
     309    return "Menu deleted succesfully.";
     310}
    287311
    288312/* This code saves the form values */
    289 function awm_update_option_values() {
    290     update_option('AWM_show_welcome', FALSE);
    291     global $awm_total_tabs,$awm_table_name,$wpdb;
    292    
    293     if ($awm_total_tabs){
    294         $checkNames = array();
    295         $duplArray = array();
    296         $message = "";
    297         //checking for name duplication
    298         for ($awm_t=0; $awm_t<$awm_total_tabs; $awm_t++) {
    299             $fndIndex = array_search((string) $_POST["AWM_menu_name_".$awm_t], $checkNames);
    300            
    301             if ($fndIndex===false) {
    302                 $checkNames[$awm_t] = (string) $_POST["AWM_menu_name_".$awm_t];
     313function awm_update_option_values()
     314{
     315    update_option('AWM_show_welcome', false);
     316    global $awm_total_tabs, $awm_table_name, $wpdb;
     317
     318    if ($awm_total_tabs) {
     319        $checkNames = array();
     320        $duplArray = array();
     321        $message = "";
     322        //checking for name duplication
     323        for ($awm_t = 0; $awm_t < $awm_total_tabs; $awm_t++) {
     324            $fndIndex = array_search((string)$_POST["AWM_menu_name_" . $awm_t], $checkNames);
     325
     326            if ($fndIndex === false) {
     327                $checkNames[$awm_t] = (string)$_POST["AWM_menu_name_" . $awm_t];
    303328            } else {
    304                 if (array_key_exists((string)$_POST["AWM_menu_name_".$awm_t], $duplArray)) {
    305                     $duplArray[(string)$_POST["AWM_menu_name_".$awm_t]][] = $awm_t;
     329                if (array_key_exists((string)$_POST["AWM_menu_name_" . $awm_t], $duplArray)) {
     330                    $duplArray[(string)$_POST["AWM_menu_name_" . $awm_t]][] = $awm_t;
    306331                } else {
    307                     $duplArray[(string)$_POST["AWM_menu_name_".$awm_t]] = array($fndIndex, $awm_t);
    308                 }
    309             }
    310         }
    311        
     332                    $duplArray[(string)$_POST["AWM_menu_name_" . $awm_t]] = array($fndIndex, $awm_t);
     333                }
     334            }
     335        }
     336
    312337        if (count($duplArray)) {
    313338            foreach ($duplArray as $name => $keys) {
    314                 $message .= "Name ".$name." exists in ".count($keys)." menus. Check name field in ";
    315                 foreach ($keys as  $i=>$tab) {
    316                     if ($i != count($keys)-1)
    317                         $message .= "<a href=\"javascript:void(0)\" onclick=\"awm_show_tab(".$tab.");window.location.hash = '#AWM_tab_header_".$tab."';\">".($tab + 1)."</a>, ";
    318                     else
    319                         $message .= "<a href=\"javascript:void(0)\" onclick=\"awm_show_tab(".$tab.");window.location.hash =  '#AWM_tab_header_".$tab."';\">".($tab + 1)."</a> ";
    320                 }
    321                 $message .="menu tabs.<br />";
     339                $message .= "Name " . $name . " exists in " . count($keys) . " menus. Check name field in ";
     340                foreach ($keys as $i => $tab) {
     341                    if ($i != count($keys) - 1) {
     342                        $message .= "<a href=\"javascript:void(0)\" onclick=\"awm_show_tab(" . $tab . ");window.location.hash = '#AWM_tab_header_" . $tab . "';\">" . ($tab + 1) . "</a>, ";
     343                    } else {
     344                        $message .= "<a href=\"javascript:void(0)\" onclick=\"awm_show_tab(" . $tab . ");window.location.hash =  '#AWM_tab_header_" . $tab . "';\">" . ($tab + 1) . "</a> ";
     345                    }
     346                }
     347                $message .= "menu tabs.<br />";
    322348            }
    323349            $message .= "Names must be unique for each menu.";
    324350            return $message;
    325         }
    326         for ($awm_t=0; $awm_t<$awm_total_tabs; $awm_t++) {
    327             $dataArray[$awm_t]['custom_menu'] = (bool) $_POST["AWM_use_custom_menu_".$awm_t];
    328             $dataArray[$awm_t]['custom_menu_id'] = (string) $_POST["AWM_use_custom_menu_id_".$awm_t];
    329             $dataArray[$awm_t]['active'] =  isset($_POST["AWM_menu_active_".$awm_t])?true:false;
    330             $dataArray[$awm_t]['position'] = (string) $_POST["awm_menu_position_".$awm_t];
     351        }
     352        for ($awm_t = 0; $awm_t < $awm_total_tabs; $awm_t++) {
     353            $dataArray[$awm_t]['custom_menu'] = (bool)$_POST["AWM_use_custom_menu_" . $awm_t];
     354            $dataArray[$awm_t]['custom_menu_id'] = (string)$_POST["AWM_use_custom_menu_id_" . $awm_t];
     355            $dataArray[$awm_t]['active'] = isset($_POST["AWM_menu_active_" . $awm_t]) ? true : false;
     356            $dataArray[$awm_t]['position'] = (string)$_POST["awm_menu_position_" . $awm_t];
    331357            //if user choses awm_widget position, we should create a new 'inactive' widget instance
    332             if ($dataArray[$awm_t]['position'] == 'awm_widget' && $dataArray[$awm_t]['active'] ){
     358            if ($dataArray[$awm_t]['position'] == 'awm_widget' && $dataArray[$awm_t]['active']) {
    333359                awm_create_widget_instance($awm_t);
    334360            } else {
    335361                awm_delete_widget_instance($awm_t);
    336362            }
    337             $dataArray[$awm_t]['type'] =  (string) $_POST["AWM_menu_type_".$awm_t];
    338             $dataArray[$awm_t]['name'] =  (string) $_POST["AWM_menu_name_".$awm_t];
    339             $dataArray[$awm_t]['include_home'] =  isset( $_POST["AWM_include_home_".$awm_t])?true:false;
    340             $dataArray[$awm_t]['pages'] =  isset( $_POST["AWM_pages_".$awm_t])?true:false;
    341             $dataArray[$awm_t]['pages_ms'] =  (string) $_POST["AWM_pages_ms_".$awm_t];
    342             if (isset ($_POST["AWM_pages_name_".$awm_t]))
    343                 $dataArray[$awm_t]['pages_name'] =  (string) $_POST["AWM_pages_name_".$awm_t];
    344             $dataArray[$awm_t]['excluded_pages'] =  (string) $_POST["AWM_excluded_pages_".$awm_t];
    345             $dataArray[$awm_t]['posts'] =  isset($_POST["AWM_posts_".$awm_t])?true:false;
    346             $dataArray[$awm_t]['posts_ms'] =  (string) $_POST["AWM_posts_ms_".$awm_t];
    347             if (isset ($_POST["AWM_posts_name_".$awm_t]))
    348                 $dataArray[$awm_t]['posts_name'] =  (string) $_POST["AWM_posts_name_".$awm_t];
    349             $dataArray[$awm_t]['posts_ids'] =  (string) $_POST["AWM_posts_ids_".$awm_t];
    350             $dataArray[$awm_t]['categories'] =  isset ($_POST["AWM_categories_".$awm_t])? true :false;
    351             $dataArray[$awm_t]['categories_ms'] =  (string) $_POST["AWM_categories_ms_".$awm_t];
    352             if (isset ($_POST["AWM_categories_name_".$awm_t]))
    353                 $dataArray[$awm_t]['categories_name'] =  (string) $_POST["AWM_categories_name_".$awm_t];
    354             $dataArray[$awm_t]['categories_subitems'] =  isset ($_POST["AWM_categories_subitems_".$awm_t])? true :false;
    355             if (isset ($_POST["AWM_categories_subitems_no_".$awm_t]))
    356                 $dataArray[$awm_t]['categories_subitems_no'] =  (string) $_POST["AWM_categories_subitems_no_".$awm_t];
    357             $dataArray[$awm_t]['excluded_cats'] =  (string) $_POST["AWM_excluded_cats_".$awm_t];
    358             $dataArray[$awm_t]['hide_future'] =  isset($_POST["AWM_hide_future_".$awm_t])? true : false;
    359             $dataArray[$awm_t]['hide_protected'] =  isset($_POST["AWM_hide_protected_".$awm_t])?true : false;
    360             $dataArray[$awm_t]['hide_private'] =  isset($_POST["AWM_hide_private_".$awm_t])?true : false;
    361             $dataArray[$awm_t]['related'] = isset( $_POST["AWM_Related_".$awm_t])?true:false;
    362             if (isset ($_POST["AWM_Related_name_".$awm_t]))
    363                 $dataArray[$awm_t]['related_name'] = $_POST["AWM_Related_name_".$awm_t];
    364             $wpdb->update($awm_table_name,$dataArray[$awm_t],array( 'id' => (int) $_POST["AWM_menu_id_".$awm_t] ));
    365         }
    366         update_option('AWM_menu_path', (string) $_POST["AWM_menu_path_0"]);
    367         update_option('AWM_selected_tab', (string) $_POST["AWM_selected_tab"]);
    368         return "Settings updated!";
    369     } else return "There are no menus. You can create one using the appropriate button.";
     363            $dataArray[$awm_t]['type'] = (string)$_POST["AWM_menu_type_" . $awm_t];
     364            $dataArray[$awm_t]['name'] = (string)$_POST["AWM_menu_name_" . $awm_t];
     365            $dataArray[$awm_t]['include_home'] = isset($_POST["AWM_include_home_" . $awm_t]) ? true : false;
     366            $dataArray[$awm_t]['pages'] = isset($_POST["AWM_pages_" . $awm_t]) ? true : false;
     367            $dataArray[$awm_t]['pages_ms'] = (string)$_POST["AWM_pages_ms_" . $awm_t];
     368            if (isset ($_POST["AWM_pages_name_" . $awm_t])) {
     369                $dataArray[$awm_t]['pages_name'] = (string)$_POST["AWM_pages_name_" . $awm_t];
     370            }
     371            $dataArray[$awm_t]['excluded_pages'] = (string)$_POST["AWM_excluded_pages_" . $awm_t];
     372            $dataArray[$awm_t]['posts'] = isset($_POST["AWM_posts_" . $awm_t]) ? true : false;
     373            $dataArray[$awm_t]['posts_ms'] = (string)$_POST["AWM_posts_ms_" . $awm_t];
     374            if (isset ($_POST["AWM_posts_name_" . $awm_t])) {
     375                $dataArray[$awm_t]['posts_name'] = (string)$_POST["AWM_posts_name_" . $awm_t];
     376            }
     377            $dataArray[$awm_t]['posts_ids'] = (string)$_POST["AWM_posts_ids_" . $awm_t];
     378            $dataArray[$awm_t]['categories'] = isset ($_POST["AWM_categories_" . $awm_t]) ? true : false;
     379            $dataArray[$awm_t]['categories_ms'] = (string)$_POST["AWM_categories_ms_" . $awm_t];
     380            if (isset ($_POST["AWM_categories_name_" . $awm_t])) {
     381                $dataArray[$awm_t]['categories_name'] = (string)$_POST["AWM_categories_name_" . $awm_t];
     382            }
     383            $dataArray[$awm_t]['categories_subitems'] = isset ($_POST["AWM_categories_subitems_" . $awm_t]) ? true : false;
     384            if (isset ($_POST["AWM_categories_subitems_no_" . $awm_t])) {
     385                $dataArray[$awm_t]['categories_subitems_no'] = (string)$_POST["AWM_categories_subitems_no_" . $awm_t];
     386            }
     387            $dataArray[$awm_t]['excluded_cats'] = (string)$_POST["AWM_excluded_cats_" . $awm_t];
     388            $dataArray[$awm_t]['hide_future'] = isset($_POST["AWM_hide_future_" . $awm_t]) ? true : false;
     389            $dataArray[$awm_t]['hide_protected'] = isset($_POST["AWM_hide_protected_" . $awm_t]) ? true : false;
     390            $dataArray[$awm_t]['hide_private'] = isset($_POST["AWM_hide_private_" . $awm_t]) ? true : false;
     391            $dataArray[$awm_t]['related'] = isset($_POST["AWM_Related_" . $awm_t]) ? true : false;
     392            if (isset ($_POST["AWM_Related_name_" . $awm_t])) {
     393                $dataArray[$awm_t]['related_name'] = $_POST["AWM_Related_name_" . $awm_t];
     394            }
     395            $wpdb->update($awm_table_name, $dataArray[$awm_t], array('id' => (int)$_POST["AWM_menu_id_" . $awm_t]));
     396        }
     397        update_option('AWM_menu_path', (string)$_POST["AWM_menu_path_0"]);
     398        update_option('AWM_selected_tab', (string)$_POST["AWM_selected_tab"]);
     399        return "Settings updated!";
     400    } else {
     401        return "There are no menus. You can create one using the appropriate button.";
     402    }
    370403}
    371404
     
    373406 * Helper function that creates AllWebMenu Widget Instances
    374407 */
    375 function awm_create_widget_instance($awm_t) {
     408function awm_create_widget_instance($awm_t)
     409{
    376410    //retrieve all instances of widget.
    377411    $a = get_option('widget_widget_allwebmenus');
     
    384418    $keyToSave = -1;
    385419    $keyThatExists = -1;
    386     foreach ( (array) $a as $_key=>$m_instance) {
     420    foreach ((array)$a as $_key => $m_instance) {
    387421        //save the key of the last instance
    388         if ($i == $_keyPos) { $keyToSave =  $_key; }
     422        if ($i == $_keyPos) {
     423            $keyToSave = $_key;
     424        }
    389425        $i++;
    390        
    391         if (!empty($m_instance['div_name']) )
    392             if ($m_instance['div_name'] == (int) $_POST["AWM_menu_id_".$awm_t]) {
     426
     427        if ( ! empty($m_instance['div_name'])) {
     428            if ($m_instance['div_name'] == (int)$_POST["AWM_menu_id_" . $awm_t]) {
    393429                //if it's already defined set the flag to false
    394430                $notSet = false;
     
    396432                break;
    397433            }
    398     }
    399     if (count($a) == 1) { $keyToSave = 1; }
    400     if ($notSet && $keyToSave!=-1) {
     434        }
     435    }
     436    if (count($a) == 1) {
     437        $keyToSave = 1;
     438    }
     439    if ($notSet && $keyToSave != -1) {
    401440        //create the new instace
    402         $a2[ $keyToSave + 1 ] = array ('div_name' => (int) $_POST["AWM_menu_id_".$awm_t] );
    403         ksort($a2 , SORT_STRING);
    404         update_option('widget_widget_allwebmenus',$a2);
     441        $a2[$keyToSave + 1] = array('div_name' => (int)$_POST["AWM_menu_id_" . $awm_t]);
     442        ksort($a2, SORT_STRING);
     443        update_option('widget_widget_allwebmenus', $a2);
    405444        //adds the new instance to inactive widgets
    406445        $sidebar_widgets = (get_option('sidebars_widgets'));
    407         $sidebar_widgets['wp_inactive_widgets'][count($sidebar_widgets['wp_inactive_widgets'])] = 'widget_allwebmenus-'.($keyToSave + 1);
     446        $sidebar_widgets['wp_inactive_widgets'][count($sidebar_widgets['wp_inactive_widgets'])] = 'widget_allwebmenus-' . ($keyToSave + 1);
    408447        update_option('sidebars_widgets', $sidebar_widgets);
    409448    }
     
    434473    */
    435474}
     475
    436476/*
    437477 * Helper function that deletes a widget instance
    438478 */
    439 function awm_delete_widget_instance($awm_t, $isId = false) {
     479function awm_delete_widget_instance($awm_t, $isId = false)
     480{
    440481    //if not an awm_widget we should check if this menu
    441482    //widget instance exists so to remove it from the instances and sidebars
    442483    $id = -1;
    443     if ($isId) $id = $awm_t;
    444     else $id = (int) $_POST["AWM_menu_id_".$awm_t];
    445    
    446     $notSet = TRUE;
    447     $notSet2 = TRUE;
     484    if ($isId) {
     485        $id = $awm_t;
     486    } else {
     487        $id = (int)$_POST["AWM_menu_id_" . $awm_t];
     488    }
     489
     490    $notSet = true;
     491    $notSet2 = true;
    448492    $a = get_option('widget_widget_allwebmenus');
    449     $a2 = $a = (array) $a;
     493    $a2 = $a = (array)$a;
    450494    //array to hold keys to remove in case we find one or more instances
    451495    $keysToRemove = array();
    452    
    453     foreach ( $a as $_key=>$m_instance) {
    454         if (!empty($m_instance['div_name']) )
     496
     497    foreach ($a as $_key => $m_instance) {
     498        if ( ! empty($m_instance['div_name'])) {
    455499            if ($m_instance['div_name'] == $id) {
    456500                $notSet = false;
    457                 unset ($a2[$_key])  ;
    458                 $keysToRemove[] = $_key ;
    459             }
    460     }
    461     if (!$notSet) {
    462         ksort($a2 , SORT_STRING);
    463         update_option('widget_widget_allwebmenus',$a2);
     501                unset ($a2[$_key]);
     502                $keysToRemove[] = $_key;
     503            }
     504        }
     505    }
     506    if ( ! $notSet) {
     507        ksort($a2, SORT_STRING);
     508        update_option('widget_widget_allwebmenus', $a2);
    464509        //retrieve the sidebars
    465510        $sidebar_widgets = (get_option('sidebars_widgets'));
    466511        $sidebar_widgets2 = $sidebar_widgets = (array)$sidebar_widgets;
    467512        //loop through sidebats to find instances of the widghet
    468         foreach ($sidebar_widgets as $name_of_sidebar=>$sidebar) {
    469             foreach ((array)$sidebar as $sidebar_i=>$widget_instance_name) {
    470                 foreach ($keysToRemove as $keyToRemove)
    471                     if ($widget_instance_name == 'widget_allwebmenus-'.$keyToRemove) {
     513        foreach ($sidebar_widgets as $name_of_sidebar => $sidebar) {
     514            foreach ((array)$sidebar as $sidebar_i => $widget_instance_name) {
     515                foreach ($keysToRemove as $keyToRemove) {
     516                    if ($widget_instance_name == 'widget_allwebmenus-' . $keyToRemove) {
    472517                        unset($sidebar_widgets2[$name_of_sidebar][$sidebar_i]);
    473518                        $notSet2 = false;
    474519                    }
    475             }
    476         }
    477         if (!$notSet2) {
     520                }
     521            }
     522        }
     523        if ( ! $notSet2) {
    478524            ksort($sidebar_widgets2, SORT_STRING);
    479525            update_option('sidebars_widgets', $sidebar_widgets2);
     
    483529
    484530/* The function that uploads the zip file */
    485 function awm_update_zip() {
    486     global $awm_table_name,$wpdb;
     531function awm_update_zip()
     532{
     533    global $awm_table_name, $wpdb;
    487534    global $awm_total_tabs;
    488    
     535
    489536    add_filter('upload_mimes', 'addUploadMimes');
    490     function addUploadMimes($mimes) {
     537    function addUploadMimes($mimes)
     538    {
    491539        $mimes = array_merge($mimes, array(
    492540            'zip' => 'application/zip'
     
    495543    }
    496544
    497     update_option('AWM_selected_tab', (string) $_POST["AWM_selected_tab_c"]);
    498     foreach ( $_FILES as $src ) {
     545    update_option('AWM_selected_tab', (string)$_POST["AWM_selected_tab_c"]);
     546    foreach ($_FILES as $src) {
    499547        if ($src['size']) {
    500             $folder = get_option( 'AWM_menu_path' );
    501             $or_name = $wpdb->get_var("SELECT name from $awm_table_name where id = ".(int) $_POST["AWM_menu_id"]);
    502             $or_name_full = "awm".$or_name.".zip";
    503             if ($src['name'] != $or_name_full) return "Error: Wrong filename (".$src['name']."). It should be: '".$or_name_full."'.";
    504             if (file_exists (ABSPATH.$folder.$src['name'])) unlink ( ABSPATH.$folder.$src['name'] );
    505             if (!file_exists(ABSPATH.$folder)) {
    506                 if (!mkdir(ABSPATH.$folder))
    507                     return "Error: The folder '".$folder."' does not exist and could not be automatically created. <br>You should create it by yourself and make sure that it has '757' permissions.";
     548            $folder = get_option('AWM_menu_path');
     549            $or_name = $wpdb->get_var("SELECT name from $awm_table_name where id = " . (int)$_POST["AWM_menu_id"]);
     550            $or_name_full = "awm" . $or_name . ".zip";
     551            if ($src['name'] != $or_name_full) {
     552                return "Error: Wrong filename (" . $src['name'] . "). It should be: '" . $or_name_full . "'.";
     553            }
     554            if (file_exists(ABSPATH . $folder . $src['name'])) {
     555                unlink(ABSPATH . $folder . $src['name']);
     556            }
     557            if ( ! file_exists(ABSPATH . $folder)) {
     558                if ( ! mkdir(ABSPATH . $folder)) {
     559                    return "Error: The folder '" . $folder . "' does not exist and could not be automatically created. <br>You should create it by yourself and make sure that it has '757' permissions.";
     560                }
    508561            }
    509562            $wantedPerms = octdec("0755");
    510             $actualPerms = octdec(substr(sprintf("%o",fileperms(ABSPATH.$folder)),-4));
    511             if($actualPerms < $wantedPerms) {
    512                 if (!chmod ( ABSPATH.$folder , $wantedPerms )) {
    513                     return "Error: Cannnot extract files to folder: '".$folder."'. Please make sure that this folder has '757' permissions";
     563            $actualPerms = octdec(substr(sprintf("%o", fileperms(ABSPATH . $folder)), -4));
     564            if ($actualPerms < $wantedPerms) {
     565                if ( ! chmod(ABSPATH . $folder, $wantedPerms)) {
     566                    return "Error: Cannnot extract files to folder: '" . $folder . "'. Please make sure that this folder has '757' permissions";
    514567                }
    515568            }
    516569            define('UPLOADS', $folder);
    517             $overrides = array( 'test_form' => false);
    518             if ($uploads_use_yearmonth_folders = get_option( 'uploads_use_yearmonth_folders' ))
     570            $overrides = array('test_form' => false);
     571            if ($uploads_use_yearmonth_folders = get_option('uploads_use_yearmonth_folders')) {
    519572                update_option('uploads_use_yearmonth_folders', 0);
     573            }
    520574            define('FS_METHOD', 'direct');
    521575            WP_Filesystem();
    522             $file = wp_handle_upload( $src, $overrides );
    523             if ($uploads_use_yearmonth_folders == 1)
     576            $file = wp_handle_upload($src, $overrides);
     577            if ($uploads_use_yearmonth_folders == 1) {
    524578                update_option('uploads_use_yearmonth_folders', 1);
     579            }
    525580            if (function_exists(unzip_file)) {
    526                 $result = unzip_file($file['file'], ABSPATH.$folder );
    527                 if (is_wp_error($result)){
     581                $result = unzip_file($file['file'], ABSPATH . $folder);
     582                if (is_wp_error($result)) {
    528583                    @unlink($file['file']);
    529                     if ($actualPerms < $wantedPerms) @chmod ( ABSPATH.$folder , $actualPerms );
     584                    if ($actualPerms < $wantedPerms) {
     585                        @chmod(ABSPATH . $folder, $actualPerms);
     586                    }
    530587                    return "Error: Unzipping file failed.";
    531588                }
     
    534591                $revs = "1";
    535592                // if the zip contains the "info.txt" then read-in the genre, else set as "JS"
    536                 if (file_exists (ABSPATH.$folder."info.txt")) {
    537                     if ($awm_menuinfofile = fopen(ABSPATH.$folder."info.txt", 'r')) {
    538                         while($tmp = fgets($awm_menuinfofile, filesize(ABSPATH.$folder."info.txt"))) {
    539                             if (substr($tmp,0,7)=="Genre: ") $gen = substr($tmp,7);
    540                             if (trim($tmp)=="***Start Structure Code***") while (trim($tmp=fgets($awm_menuinfofile, filesize(ABSPATH.$folder."info.txt")))!="***End Structure Code***") $struct .= $tmp;
    541                             if (substr($tmp,0,12)=="Responsive: ") $revs = substr($tmp,12);
     593                if (file_exists(ABSPATH . $folder . "info.txt")) {
     594                    if ($awm_menuinfofile = fopen(ABSPATH . $folder . "info.txt", 'r')) {
     595                        while ($tmp = fgets($awm_menuinfofile, filesize(ABSPATH . $folder . "info.txt"))) {
     596                            if (substr($tmp, 0, 7) == "Genre: ") {
     597                                $gen = substr($tmp, 7);
     598                            }
     599                            if (trim($tmp) == "***Start Structure Code***") {
     600                                while (trim($tmp = fgets($awm_menuinfofile,
     601                                        filesize(ABSPATH . $folder . "info.txt"))) != "***End Structure Code***") {
     602                                    $struct .= $tmp;
     603                                }
     604                            }
     605                            if (substr($tmp, 0, 12) == "Responsive: ") {
     606                                $revs = substr($tmp, 12);
     607                            }
    542608                        }
    543609                    }
     
    547613            } else {
    548614                @unlink($file['file']);
    549                 if ($actualPerms < $wantedPerms) @chmod ( ABSPATH.$folder , $actualPerms );
     615                if ($actualPerms < $wantedPerms) {
     616                    @chmod(ABSPATH . $folder, $actualPerms);
     617                }
    550618                return "ZIP upload requires WordPress version 2.5 or greater.";
    551619            }
    552620            @unlink($file['file']);
    553             if ($actualPerms < $wantedPerms) @chmod ( ABSPATH.$folder , $actualPerms );
     621            if ($actualPerms < $wantedPerms) {
     622                @chmod(ABSPATH . $folder, $actualPerms);
     623            }
    554624            return "Menu files successfully uploaded.";
    555625        }
    556626    }
    557     update_option('AWM_selected_tab', (string) $_POST["AWM_selected_tab_c"]);
     627    update_option('AWM_selected_tab', (string)$_POST["AWM_selected_tab_c"]);
    558628}
    559629
    560630/* This code corrects the menu name if it has paths or extension */
    561 function awm_fix_menu_name($awm_m) {
     631function awm_fix_menu_name($awm_m)
     632{
    562633    $awm_name = $awm_m;
    563     if (strpos($awm_name,"/")>-1 || strpos($awm_name,".js")>-1 ) {
     634    if (strpos($awm_name, "/") > -1 || strpos($awm_name, ".js") > -1) {
    564635        $awm_nm = explode("/", $awm_name);
    565636        $awm_name = $awm_nm[1];
     
    575646    global $awm_url, $awm_total_tabs, $wpdb, $awm_table_name;
    576647    $awm_the_msg = array();
    577     $awm_realpath = ABSPATH. get_option('AWM_menu_path');
     648    $awm_realpath = ABSPATH . get_option('AWM_menu_path');
    578649    $awm_path = site_url() . get_option('AWM_menu_path');
    579    
     650
    580651    error_reporting(0);
    581     $myrows = $wpdb->get_results( "SELECT * FROM $awm_table_name ORDER BY id ASC" );
    582     for ($awm_t=0; $awm_t<$awm_total_tabs; $awm_t++) {
     652    $myrows = $wpdb->get_results("SELECT * FROM $awm_table_name ORDER BY id ASC");
     653    for ($awm_t = 0; $awm_t < $awm_total_tabs; $awm_t++) {
    583654        $awm_the_msg[$awm_t] = "";
    584         if (!$myrows[$awm_t]->active) continue;
    585         $awm_name = trim($myrows[$awm_t]->name).".js";
    586        
    587         if (! ($awm_menufile = fopen($awm_realpath . $awm_name, 'r'))) {
    588             $awm_the_msg[$awm_t] = "Menu ".$myrows[$awm_t]->name." was not found at: ". $awm_path . $awm_name;
     655        if ( ! $myrows[$awm_t]->active) {
    589656            continue;
    590         } elseif (! ($awm_mfile = fread($awm_menufile, filesize($awm_realpath . $awm_name)))) {
    591             $awm_the_msg[$awm_t] = "Could not read menu at: ". $awm_path . $awm_name;
     657        }
     658        $awm_name = trim($myrows[$awm_t]->name) . ".js";
     659
     660        if ( ! ($awm_menufile = fopen($awm_realpath . $awm_name, 'r'))) {
     661            $awm_the_msg[$awm_t] = "Menu " . $myrows[$awm_t]->name . " was not found at: " . $awm_path . $awm_name;
    592662            continue;
     663        } elseif ( ! ($awm_mfile = fread($awm_menufile, filesize($awm_realpath . $awm_name)))) {
     664            $awm_the_msg[$awm_t] = "Could not read menu at: " . $awm_path . $awm_name;
     665            continue;
    593666        }
    594667        $awm_bNo = explode('awmLibraryBuild=', $awm_mfile);
    595         if ($awm_bNo[1]==null) {
    596             $awm_the_msg[$awm_t] = "Could not read menu at: ". $awm_path . $awm_name;
     668        if ($awm_bNo[1] == null) {
     669            $awm_the_msg[$awm_t] = "Could not read menu at: " . $awm_path . $awm_name;
    597670            continue;
    598671        }
     
    600673        $awm_buildNo = $awm_bNo[0];
    601674        $awm_hNo = explode('awmHash=\'', $awm_mfile);
    602         if ($awm_hNo[1]==null) {
    603             $awm_the_msg[$awm_t] = "Could not read menu at: ". $awm_path . $awm_name;
     675        if ($awm_hNo[1] == null) {
     676            $awm_the_msg[$awm_t] = "Could not read menu at: " . $awm_path . $awm_name;
    604677            continue;
    605678        }
    606679        $awm_hNo = explode('\'', $awm_hNo[1]);
    607680        $awm_HashNo = $awm_hNo[0];
    608        
    609         $awm_params = "plugin=wordpress&build=$awm_buildNo&hash=$awm_HashNo&rand=". rand(1,10000) ."&domain=". site_url();
    610        
     681
     682        $awm_params = "plugin=wordpress&build=$awm_buildNo&hash=$awm_HashNo&rand=" . rand(1, 10000) . "&domain=" . site_url();
     683
    611684        if (function_exists('curl_init')) {
    612             if (! ($awm_tmp = awm_geturl($awm_params))) {
    613                 $awm_the_msg[$awm_t] = "Could not retrieve version information for ".$myrows[$awm_t]->name.". Please <a href='mailto:[email protected]?subject=WordPress: Error while retrieving version info'>contact Likno</a> for more information.";
     685            if ( ! ($awm_tmp = awm_geturl($awm_params))) {
     686                $awm_the_msg[$awm_t] = "Could not retrieve version information for " . $myrows[$awm_t]->name . ". Please <a href='mailto:[email protected]?subject=WordPress: Error while retrieving version info'>contact Likno</a> for more information.";
    614687            } else {
    615688                $awm_the_msg[$awm_t] = $awm_tmp;
     
    617690            continue;
    618691        } else {
    619             $awm_the_msg[$awm_t] = '<iframe src='. $awm_url .'?'. $awm_params .' width="600px" height="80px"></iframe>';
    620         }
    621     }
    622    
     692            $awm_the_msg[$awm_t] = '<iframe src=' . $awm_url . '?' . $awm_params . ' width="600px" height="80px"></iframe>';
     693        }
     694    }
     695
    623696    $awm_has_msg = false;
    624     for ($awm_t=0; $awm_t<$awm_total_tabs; $awm_t++) { if ($awm_the_msg[$awm_t] != "") {$awm_has_msg = true; break;} }
    625    
     697    for ($awm_t = 0; $awm_t < $awm_total_tabs; $awm_t++) {
     698        if ($awm_the_msg[$awm_t] != "") {
     699            $awm_has_msg = true;
     700            break;
     701        }
     702    }
     703
    626704    $awm_the_full_msg = "";
    627705    if ($awm_has_msg) {
    628706        $awm_the_full_msg = "<div class='updated fade'>";
    629         for ($awm_t=0; $awm_t<$awm_total_tabs; $awm_t++) if ($awm_the_msg[$awm_t] != "") $awm_the_full_msg .= "<br><strong>Note about ".$myrows[$awm_t]->name.": </strong><br>".$awm_the_msg[$awm_t]."<br>";
     707        for ($awm_t = 0; $awm_t < $awm_total_tabs; $awm_t++) {
     708            if ($awm_the_msg[$awm_t] != "") {
     709                $awm_the_full_msg .= "<br><strong>Note about " . $myrows[$awm_t]->name . ": </strong><br>" . $awm_the_msg[$awm_t] . "<br>";
     710            }
     711        }
    630712        $awm_the_full_msg .= "<br><input type='button' value='Hide Notifications' onclick='theform.theaction.value=\"hide_msg\"; theform.submit();'/><br>&nbsp;</div>";
    631713    }
    632    
    633     update_option('AWM_Checked', TRUE);
     714
     715    update_option('AWM_Checked', true);
    634716    update_option('AWM_Checked_Date', date(d));
    635    
     717
    636718    error_reporting(1);
    637    
     719
    638720    return $awm_the_full_msg;
    639721}
     
    641723/* Helper code for above function */
    642724global $awm_url;
    643 $awm_url ="http://www.likno.com/addins/plugin-check.php";
     725$awm_url = "https://www.likno.com/addins/plugin-check.php";
    644726function awm_geturl($awm_params)
    645727{
    646     global $awm_url;
    647     $awm_ch = curl_init();
    648     curl_setopt ($awm_ch, CURLOPT_URL,$awm_url);
     728    global $awm_url;
     729    $awm_ch = curl_init();
     730    curl_setopt($awm_ch, CURLOPT_URL, $awm_url);
    649731    curl_setopt($awm_ch, CURLOPT_POST, 1);
    650     curl_setopt($awm_ch, CURLOPT_POSTFIELDS, $awm_params);
    651    
    652     curl_setopt($awm_ch, CURLOPT_RETURNTRANSFER, 1);
    653     $awm_postResult = curl_exec($awm_ch);
    654 
    655     return $awm_postResult;
     732    curl_setopt($awm_ch, CURLOPT_POSTFIELDS, $awm_params);
     733
     734    curl_setopt($awm_ch, CURLOPT_RETURNTRANSFER, 1);
     735    $awm_postResult = curl_exec($awm_ch);
     736
     737    return $awm_postResult;
    656738}
    657739
  • allwebmenus-wordpress-menu-plugin/trunk/menu_helper.php

    r1165178 r2008056  
    55
    66
    7 function AWM_create_dynamic_menu($awm_t, $awm_is_sub, $ext) {
     7function AWM_create_dynamic_menu($awm_t, $awm_is_sub, $ext)
     8{
    89    $awm_ic = 1000;
    9     $awm_m =$awm_t->name.$ext;
     10    $awm_m = $awm_t->name . $ext;
    1011    if ($awm_is_sub) {
    11         $awm_parentgroup = "wpgroup".$ext;
     12        $awm_parentgroup = "wpgroup" . $ext;
    1213    } else {
    1314        $awm_parentgroup = $awm_m;
     
    1819    } else { // else use the other options
    1920        if ($awm_t->include_home) { // include home
    20             echo $awm_parentgroup.".newItem('style=".$awm_m."_'+(wplevel==0?'main_item_style':'sub_item_style')+';itemid=".($awm_ic++).";text0=Home;".(site_url()!=""?"url=".site_url():"")."');\n";
    21         }
    22        
     21            echo $awm_parentgroup . ".newItem('style=" . $awm_m . "_'+(wplevel==0?'main_item_style':'sub_item_style')+';itemid=" . ($awm_ic++) . ";text0=Home;" . (site_url() != "" ? "url=" . site_url() : "") . "');\n";
     22        }
     23
    2324        if ($awm_t->pages) {
    2425            $awm_ic = AWM_create_dynamic_menu__pages($awm_t, $awm_parentgroup, $awm_ic, false, false, $ext);
    2526        }
    26        
     27
    2728        if ($awm_t->posts) {
    2829            $awm_ic = AWM_create_dynamic_menu__posts($awm_t, $awm_parentgroup, $awm_ic, false, false, $ext);
    2930        }
    30        
     31
    3132        if ($awm_t->categories) {
    3233            $awm_ic = AWM_create_dynamic_menu__categories($awm_t, $awm_parentgroup, $awm_ic, false, false, $ext);
     
    3637
    3738
    38 function AWM_create_menu_structure($awm_t, $ext) {
    39     $awm_ic = 1000;
    40     $awm_xml_out = "<?xml version='1.0' encoding='UTF-8'?><mainmenu>";
    41     $awm_xml_out .="<menutype>".$awm_t->type."</menutype>";
    42     $awm_xml_out .="<menuname>".$awm_t->name."</menuname>";
    43     $awm_xml_out .="<menupositioning>";
    44     if ($awm_t->position == "0") { // if user wants custom positioning
    45         $awm_xml_out .=  "custom";
    46     } else { $awm_xml_out .=  "element"; }
    47     $awm_xml_out .="</menupositioning>";
    48 
    49 if ($awm_t->custom_menu) { // if user wants a custom menu
    50         $awm_xml_out .=  AWM_create_existing_dynamic_menu($awm_t, "", $awm_ic, true, false, $ext);
     39function AWM_create_menu_structure($awm_t, $ext)
     40{
     41    $awm_ic = 1000;
     42    $awm_xml_out = "<?xml version='1.0' encoding='UTF-8'?><mainmenu>";
     43    $awm_xml_out .= "<menutype>" . $awm_t->type . "</menutype>";
     44    $awm_xml_out .= "<menuname>" . $awm_t->name . "</menuname>";
     45    $awm_xml_out .= "<menupositioning>";
     46    if ($awm_t->position == "0") { // if user wants custom positioning
     47        $awm_xml_out .= "custom";
     48    } else {
     49        $awm_xml_out .= "element";
     50    }
     51    $awm_xml_out .= "</menupositioning>";
     52
     53    if ($awm_t->custom_menu) { // if user wants a custom menu
     54        $awm_xml_out .= AWM_create_existing_dynamic_menu($awm_t, "", $awm_ic, true, false, $ext);
    5155    } else { // else use the other options
    5256        if ($awm_t->include_home) { // include home
    53             $awm_xml_out .= "<item><id>home0</id><name>Home</name><link>".site_url()."</link><submenu></submenu></item>";
    54         }
    55        
     57            $awm_xml_out .= "<item><id>home0</id><name>Home</name><link>" . site_url() . "</link><submenu></submenu></item>";
     58        }
     59
    5660        if ($awm_t->pages) {
    5761            $awm_xml_out .= AWM_create_dynamic_menu__pages($awm_t, "", $awm_ic, true, false, $ext);
    5862        }
    59        
     63
    6064        if ($awm_t->posts) {
    6165            $awm_xml_out .= AWM_create_dynamic_menu__posts($awm_t, "", $awm_ic, true, false, $ext);
    6266        }
    63        
     67
    6468        if ($awm_t->categories) {
    6569            $awm_xml_out .= AWM_create_dynamic_menu__categories($awm_t, "", $awm_ic, true, false, $ext);
     
    6771    }
    6872    $awm_xml_out .= "</mainmenu>";
    69     $awm_xml_out = str_replace("<","&lt;",$awm_xml_out);
    70     $awm_xml_out = str_replace(">","&gt;",$awm_xml_out);
    71    
     73    $awm_xml_out = str_replace("<", "&lt;", $awm_xml_out);
     74    $awm_xml_out = str_replace(">", "&gt;", $awm_xml_out);
     75
    7276    return $awm_xml_out;
    7377}
    7478
    7579
    76 function AWM_create_ULLI_dynamic_menu($awm_t, $ext) {
     80function AWM_create_ULLI_dynamic_menu($awm_t, $ext)
     81{
    7782    $awm_ic = 1000;
    7883    $awm_xml_out = "";
    79     if ($awm_t->custom_menu==1) { // if user wants a custom menu
    80         $awm_xml_out .=  AWM_create_existing_dynamic_menu($awm_t, "", $awm_ic, false, true, $ext);
     84    if ($awm_t->custom_menu == 1) { // if user wants a custom menu
     85        $awm_xml_out .= AWM_create_existing_dynamic_menu($awm_t, "", $awm_ic, false, true, $ext);
    8186    } else { // else use the other options
    8287        if ($awm_t->include_home) { // include home
    83             $awm_xml_out .= "\t<li>\n\t\t<a href=\"".site_url()."\">Home</a>\n\t</li>\n";
    84         }
    85        
     88            $awm_xml_out .= "\t<li>\n\t\t<a href=\"" . site_url() . "\">Home</a>\n\t</li>\n";
     89        }
     90
    8691        if ($awm_t->pages) {
    8792            $awm_xml_out .= AWM_create_dynamic_menu__pages($awm_t, "", $awm_ic, false, true, $ext);
    8893        }
    89        
     94
    9095        if ($awm_t->posts) {
    9196            $awm_xml_out .= AWM_create_dynamic_menu__posts($awm_t, "", $awm_ic, false, true, $ext);
    9297        }
    93        
     98
    9499        if ($awm_t->categories) {
    95100            $awm_xml_out .= AWM_create_dynamic_menu__categories($awm_t, "", $awm_ic, false, true, $ext);
    96101        }
    97102    }
    98    
     103
    99104    return $awm_xml_out;
    100105}
     
    104109 * Create the categories menu
    105110 */
    106 function AWM_create_dynamic_menu__categories($awm_t, $awm_parentgroup, $awm_ic, $awm_isXML, $awm_isUL, $ext) {
     111function AWM_create_dynamic_menu__categories($awm_t, $awm_parentgroup, $awm_ic, $awm_isXML, $awm_isUL, $ext)
     112{
    107113    global $wpdb;
    108114    $awm_depth = 0;
    109     $awm_m =$awm_t->name.$ext;
     115    $awm_m = $awm_t->name . $ext;
    110116    $awm_xml_out = "";
    111117    $awm_isNew = ($wpdb->get_results("show tables like '{$wpdb->prefix}term_taxonomy'")) > 0;
    112    
     118
    113119    $awm_post_res = AWM_get_post_restrictions($awm_t);
    114    
     120
    115121    $awm_cats_to_avoid = "";
    116     if ($awm_t->excluded_cats!='') {
     122    if ($awm_t->excluded_cats != '') {
    117123        $awm_cats_ids = $awm_t->excluded_cats;
    118124        $awm_cats_ids = str_replace(' ', '', $awm_cats_ids);
    119125        $awm_cats_ids = (array)explode(',', $awm_cats_ids);
    120         for ($awm_i=0; $awm_i<sizeof($awm_cats_ids); $awm_i++) $awm_cats_to_avoid .= ",".$awm_cats_ids[$awm_i];
    121         $awm_cats_to_avoid = "AND tt.term_id NOT IN (".substr($awm_cats_to_avoid,1).") AND tt.parent NOT IN (".substr($awm_cats_to_avoid,1).")";
    122     }
    123    
     126        for ($awm_i = 0; $awm_i < sizeof($awm_cats_ids); $awm_i++) {
     127            $awm_cats_to_avoid .= "," . $awm_cats_ids[$awm_i];
     128        }
     129        $awm_cats_to_avoid = "AND tt.term_id NOT IN (" . substr($awm_cats_to_avoid,
     130                1) . ") AND tt.parent NOT IN (" . substr($awm_cats_to_avoid, 1) . ")";
     131    }
     132
    124133    if ($awm_isNew) {
    125134        $awm_cats = (array)$wpdb->get_results("
     
    145154        $awm_recent = array();
    146155    }
    147    
     156
    148157    if ($awm_isXML) {
    149         if ($awm_t->categories_ms=='sub') $awm_xml_out .= "<item><id>categories</id><name>".$awm_t->categories_name."</name><link></link><submenu>";
    150         $awm_xml_out .= AWM_create_dynamic_menu__categories_step($awm_t,$awm_ic,$awm_parentgroup,$awm_cats,$awm_depth,0,$awm_recent,$awm_isXML,$awm_isUL, $ext);
    151         if ($awm_t->categories_ms=='sub') $awm_xml_out .= "</submenu></item>";
     158        if ($awm_t->categories_ms == 'sub') {
     159            $awm_xml_out .= "<item><id>categories</id><name>" . $awm_t->categories_name . "</name><link></link><submenu>";
     160        }
     161        $awm_xml_out .= AWM_create_dynamic_menu__categories_step($awm_t, $awm_ic, $awm_parentgroup, $awm_cats, $awm_depth, 0, $awm_recent,
     162            $awm_isXML, $awm_isUL, $ext);
     163        if ($awm_t->categories_ms == 'sub') {
     164            $awm_xml_out .= "</submenu></item>";
     165        }
    152166        return $awm_xml_out;
    153167    } elseif ($awm_isUL) {
    154         if ($awm_isUL) {
    155             $tabs = ""; for ($i=0; $i<$awm_depth; $i++) $tabs .= "\t\t";
    156         }
    157         if ($awm_t->categories_ms=='sub') $awm_xml_out .= "$tabs\t<li>\n$tabs\t\t<a href=\"javascript:void(0);\">".$awm_t->categories_name."</a>\n$tabs\t\t<ul>\n";
    158         $awm_xml_out .= AWM_create_dynamic_menu__categories_step($awm_t,$awm_ic,$awm_parentgroup,$awm_cats,$awm_depth+1,0,$awm_recent,$awm_isXML,$awm_isUL, $ext);
    159         if ($awm_t->categories_ms=='sub') $awm_xml_out .= "$tabs\t\t</ul>\n$tabs\t</li>\n";
    160         return $awm_xml_out;
    161     } else {
    162         if ($awm_t->categories_ms=='sub') {
    163             echo "item0=".$awm_parentgroup.".newItem('style=".$awm_m."_'+(wplevel==0?'main_item_style':'sub_item_style')+';itemid=".($awm_ic++).";text0=".str_replace("'","\'",$awm_t->categories_name)."');\n";
    164             echo "wpsubMenu0=item0.newGroup('style=".$awm_m."_'+(wplevel==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_".$awm_m.")=='object')?((wplevel)==0?wphf_".$awm_m."[0]:wphf_".$awm_m."[1]):''));\n";
     168        if ($awm_isUL) {
     169            $tabs = "";
     170            for ($i = 0; $i < $awm_depth; $i++) {
     171                $tabs .= "\t\t";
     172            }
     173        }
     174        if ($awm_t->categories_ms == 'sub') {
     175            $awm_xml_out .= "$tabs\t<li>\n$tabs\t\t<a href=\"javascript:void(0);\">" . $awm_t->categories_name . "</a>\n$tabs\t\t<ul>\n";
     176        }
     177        $awm_xml_out .= AWM_create_dynamic_menu__categories_step($awm_t, $awm_ic, $awm_parentgroup, $awm_cats, $awm_depth + 1, 0,
     178            $awm_recent, $awm_isXML, $awm_isUL, $ext);
     179        if ($awm_t->categories_ms == 'sub') {
     180            $awm_xml_out .= "$tabs\t\t</ul>\n$tabs\t</li>\n";
     181        }
     182        return $awm_xml_out;
     183    } else {
     184        if ($awm_t->categories_ms == 'sub') {
     185            echo "item0=" . $awm_parentgroup . ".newItem('style=" . $awm_m . "_'+(wplevel==0?'main_item_style':'sub_item_style')+';itemid=" . ($awm_ic++) . ";text0=" . str_replace("'",
     186                    "\'", $awm_t->categories_name) . "');\n";
     187            echo "wpsubMenu0=item0.newGroup('style=" . $awm_m . "_'+(wplevel==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_" . $awm_m . ")=='object')?((wplevel)==0?wphf_" . $awm_m . "[0]:wphf_" . $awm_m . "[1]):''));\n";
    165188            $awm_depth++;
    166189            $awm_parentgroup = "wpsubMenu0";
    167190        }
    168         return AWM_create_dynamic_menu__categories_step($awm_t,$awm_ic,$awm_parentgroup,$awm_cats,$awm_depth,0,$awm_recent,$awm_isXML,$awm_isUL, $ext);
    169     }
    170 }
    171 
    172 function AWM_cat_has_kids($awm_id, $awm_cats) {
    173     for ($awm_i=0; $awm_i<count($awm_cats); $awm_i++) { if ($awm_cats[$awm_i]->category_parent==$awm_id) return true; }
     191        return AWM_create_dynamic_menu__categories_step($awm_t, $awm_ic, $awm_parentgroup, $awm_cats, $awm_depth, 0, $awm_recent,
     192            $awm_isXML, $awm_isUL, $ext);
     193    }
     194}
     195
     196function AWM_cat_has_kids($awm_id, $awm_cats)
     197{
     198    for ($awm_i = 0; $awm_i < count($awm_cats); $awm_i++) {
     199        if ($awm_cats[$awm_i]->category_parent == $awm_id) {
     200            return true;
     201        }
     202    }
    174203    return false;
    175204}
    176205
    177 function AWM_create_dynamic_menu__categories_step($awm_t, $awm_ic, $awm_parentgroup, $awm_cats, $awm_depth, $awm_group, $awm_recent, $awm_isXML, $awm_isUL, $ext) {
    178     $awm_m =$awm_t->name.$ext;
    179     $awm_xml_out = "";
    180     if ($awm_isUL) {
    181         $tabs = ""; for ($i=0; $i<$awm_depth; $i++) $tabs .= "\t\t";
    182     }
    183     for ($awm_i=0; $awm_i<count($awm_cats); $awm_i++) {
    184         if ($awm_cats[$awm_i]->category_parent==$awm_group) {
     206function AWM_create_dynamic_menu__categories_step(
     207    $awm_t,
     208    $awm_ic,
     209    $awm_parentgroup,
     210    $awm_cats,
     211    $awm_depth,
     212    $awm_group,
     213    $awm_recent,
     214    $awm_isXML,
     215    $awm_isUL,
     216    $ext
     217) {
     218    $awm_m = $awm_t->name . $ext;
     219    $awm_xml_out = "";
     220    if ($awm_isUL) {
     221        $tabs = "";
     222        for ($i = 0; $i < $awm_depth; $i++) {
     223            $tabs .= "\t\t";
     224        }
     225    }
     226    for ($awm_i = 0; $awm_i < count($awm_cats); $awm_i++) {
     227        if ($awm_cats[$awm_i]->category_parent == $awm_group) {
    185228            if ($awm_isXML) {
    186                 $awm_xml_out .= "<item><id>cat_".$awm_cats[$awm_i]->category_ID."</id><name>".$awm_cats[$awm_i]->cat_name."</name><link>".get_category_link($awm_cats[$awm_i]->category_ID)."</link><submenu>";
     229                $awm_xml_out .= "<item><id>cat_" . $awm_cats[$awm_i]->category_ID . "</id><name>" . $awm_cats[$awm_i]->cat_name . "</name><link>" . get_category_link($awm_cats[$awm_i]->category_ID) . "</link><submenu>";
    187230            } elseif ($awm_isUL) {
    188                 $awm_xml_out .= "$tabs\t<li>\n$tabs\t\t<a href=\"".get_category_link($awm_cats[$awm_i]->category_ID)."\">".$awm_cats[$awm_i]->cat_name."</a>\n";
     231                $awm_xml_out .= "$tabs\t<li>\n$tabs\t\t<a href=\"" . get_category_link($awm_cats[$awm_i]->category_ID) . "\">" . $awm_cats[$awm_i]->cat_name . "</a>\n";
    189232            } else {
    190                 echo "item".$awm_depth."=".$awm_parentgroup.".newItem('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'main_item_style':((wplevel+$awm_depth)==1?'sub_item_style':'sub_item_plus_style'))+';itemid=".($awm_ic++).";text0=".str_replace("'","\'",$awm_cats[$awm_i]->cat_name).";".(get_category_link($awm_cats[$awm_i]->category_ID)!=""?"url=".get_category_link($awm_cats[$awm_i]->category_ID):"")."');\n";
     233                echo "item" . $awm_depth . "=" . $awm_parentgroup . ".newItem('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'main_item_style':((wplevel+$awm_depth)==1?'sub_item_style':'sub_item_plus_style'))+';itemid=" . ($awm_ic++) . ";text0=" . str_replace("'",
     234                        "\'",
     235                        $awm_cats[$awm_i]->cat_name) . ";" . (get_category_link($awm_cats[$awm_i]->category_ID) != "" ? "url=" . get_category_link($awm_cats[$awm_i]->category_ID) : "") . "');\n";
    191236            }
    192237            if (AWM_cat_has_kids($awm_cats[$awm_i]->category_ID, $awm_cats)) {
    193238                if ($awm_isXML || $awm_isUL) {
    194                     $awm_xml_out .= AWM_create_dynamic_menu__categories_step($awm_t, $awm_ic, "wpsubMenu".$awm_depth, $awm_cats, $awm_depth+1, $awm_cats[$awm_i]->category_ID, $awm_recent, $awm_isXML, $awm_isUL, $ext);
     239                    $awm_xml_out .= AWM_create_dynamic_menu__categories_step($awm_t, $awm_ic, "wpsubMenu" . $awm_depth, $awm_cats,
     240                        $awm_depth + 1, $awm_cats[$awm_i]->category_ID, $awm_recent, $awm_isXML, $awm_isUL, $ext);
    195241                } else {
    196                     echo "wpsubMenu".$awm_depth."=item".$awm_depth.".newGroup('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_".$awm_m.")=='object')?((wplevel+$awm_depth)==0?wphf_".$awm_m."[0]:wphf_".$awm_m."[1]):''));\n";
    197                     $awm_ic = AWM_create_dynamic_menu__categories_step($awm_t, $awm_ic, "wpsubMenu".$awm_depth, $awm_cats, $awm_depth+1, $awm_cats[$awm_i]->category_ID, $awm_recent, $awm_isXML, $awm_isUL, $ext);
     242                    echo "wpsubMenu" . $awm_depth . "=item" . $awm_depth . ".newGroup('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_" . $awm_m . ")=='object')?((wplevel+$awm_depth)==0?wphf_" . $awm_m . "[0]:wphf_" . $awm_m . "[1]):''));\n";
     243                    $awm_ic = AWM_create_dynamic_menu__categories_step($awm_t, $awm_ic, "wpsubMenu" . $awm_depth, $awm_cats, $awm_depth + 1,
     244                        $awm_cats[$awm_i]->category_ID, $awm_recent, $awm_isXML, $awm_isUL, $ext);
    198245                }
    199246            } elseif ($awm_t->categories_subitems) {
    200                 $awm_j=$awm_counter=0;
    201                 if (count($awm_recent)){
    202                     if ($awm_isUL) $awm_xml_out .= "$tabs\t\t<ul>\n";
    203                     while ($awm_j<count($awm_recent) && $awm_recent[$awm_j]->term_id!=$awm_cats[$awm_i]->category_ID) $awm_j++;
    204                     if ($awm_recent[$awm_j]->term_id==$awm_cats[$awm_i]->category_ID) {
    205                         if (!$awm_isXML && !$awm_isUL) echo "wpsubMenuRec=item".$awm_depth.".newGroup('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_".$awm_m.")=='object')?((wplevel+$awm_depth)==0?wphf_".$awm_m."[0]:wphf_".$awm_m."[1]):''));\n";
    206                         while ($awm_j<count($awm_recent) && $awm_recent[$awm_j]->term_id==$awm_cats[$awm_i]->category_ID && $awm_counter++<$awm_t->categories_subitems_no) {
     247                $awm_j = $awm_counter = 0;
     248                if (count($awm_recent)) {
     249                    if ($awm_isUL) {
     250                        $awm_xml_out .= "$tabs\t\t<ul>\n";
     251                    }
     252                    while ($awm_j < count($awm_recent) && $awm_recent[$awm_j]->term_id != $awm_cats[$awm_i]->category_ID) {
     253                        $awm_j++;
     254                    }
     255                    if ($awm_recent[$awm_j]->term_id == $awm_cats[$awm_i]->category_ID) {
     256                        if ( ! $awm_isXML && ! $awm_isUL) {
     257                            echo "wpsubMenuRec=item" . $awm_depth . ".newGroup('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_" . $awm_m . ")=='object')?((wplevel+$awm_depth)==0?wphf_" . $awm_m . "[0]:wphf_" . $awm_m . "[1]):''));\n";
     258                        }
     259                        while ($awm_j < count($awm_recent) && $awm_recent[$awm_j]->term_id == $awm_cats[$awm_i]->category_ID && $awm_counter++ < $awm_t->categories_subitems_no) {
    207260                            if ($awm_isXML) {
    208                                 $awm_xml_out .= "<item><id>cat_".$awm_cats[$awm_i]->category_ID."_it".$awm_recent[$awm_j]->ID."</id><name>".$awm_recent[$awm_j]->post_title."</name><link>".get_permalink($awm_recent[$awm_j]->ID)."</link><submenu></submenu></item>";
     261                                $awm_xml_out .= "<item><id>cat_" . $awm_cats[$awm_i]->category_ID . "_it" . $awm_recent[$awm_j]->ID . "</id><name>" . $awm_recent[$awm_j]->post_title . "</name><link>" . get_permalink($awm_recent[$awm_j]->ID) . "</link><submenu></submenu></item>";
    209262                            } elseif ($awm_isUL) {
    210                                 $awm_xml_out .= "$tabs\t\t\t<li>\n$tabs\t\t\t\t<a href=\"".get_permalink($awm_recent[$awm_j]->ID)."\">".$awm_recent[$awm_j]->post_title."</a>\n$tabs\t\t\t</li>\n";
     263                                $awm_xml_out .= "$tabs\t\t\t<li>\n$tabs\t\t\t\t<a href=\"" . get_permalink($awm_recent[$awm_j]->ID) . "\">" . $awm_recent[$awm_j]->post_title . "</a>\n$tabs\t\t\t</li>\n";
    211264                            } else {
    212                                 echo "item".($awm_depth+1)."=wpsubMenuRec.newItem('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'sub_item_style':'sub_item_plus_style')+';itemid=".($awm_ic++).";text0=".str_replace("'","\'",$awm_recent[$awm_j]->post_title).";".(get_permalink($awm_recent[$awm_j]->ID)!=""?"url=".get_permalink($awm_recent[$awm_j]->ID):"")."');\n";
     265                                echo "item" . ($awm_depth + 1) . "=wpsubMenuRec.newItem('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'sub_item_style':'sub_item_plus_style')+';itemid=" . ($awm_ic++) . ";text0=" . str_replace("'",
     266                                        "\'",
     267                                        $awm_recent[$awm_j]->post_title) . ";" . (get_permalink($awm_recent[$awm_j]->ID) != "" ? "url=" . get_permalink($awm_recent[$awm_j]->ID) : "") . "');\n";
    213268                            }
    214269                            $awm_j++;
    215270                        }
    216271                    }
    217                     if ($awm_isUL) $awm_xml_out .= "$tabs\t\t</ul>\n";
     272                    if ($awm_isUL) {
     273                        $awm_xml_out .= "$tabs\t\t</ul>\n";
     274                    }
    218275                }
    219276            }
    220             if ($awm_isXML) $awm_xml_out .= "</submenu></item>";
    221             if ($awm_isUL) $awm_xml_out .= "$tabs\t</li>\n";
    222         }
    223     }
    224     if ($awm_isXML || $awm_isUL) return $awm_xml_out;
    225     else return $awm_ic;
    226 }
    227 
    228 
    229 
    230 /*
     277            if ($awm_isXML) {
     278                $awm_xml_out .= "</submenu></item>";
     279            }
     280            if ($awm_isUL) {
     281                $awm_xml_out .= "$tabs\t</li>\n";
     282            }
     283        }
     284    }
     285    if ($awm_isXML || $awm_isUL) {
     286        return $awm_xml_out;
     287    } else {
     288        return $awm_ic;
     289    }
     290}
     291
     292
     293/*
    231294 * Create the menu from existing
    232295 */
    233 function AWM_create_existing_dynamic_menu($awm_t, $awm_parentgroup, $awm_ic, $awm_isXML, $awm_isUL, $ext) {
     296function AWM_create_existing_dynamic_menu($awm_t, $awm_parentgroup, $awm_ic, $awm_isXML, $awm_isUL, $ext)
     297{
    234298    $awm_depth = 0;
    235     $awm_m = $awm_t->name.$ext;
     299    $awm_m = $awm_t->name . $ext;
    236300    $awm_term_id = $awm_t->custom_menu_id;
    237301    $awm_xml_out = "";
    238302    $awm_recent = array();
    239     $menu_items = wp_get_nav_menu_items( $awm_term_id );
    240     $menu_items=AWM_apply_custom_menu_restrictions($menu_items,$awm_t);
     303    $menu_items = wp_get_nav_menu_items($awm_term_id);
     304    $menu_items = AWM_apply_custom_menu_restrictions($menu_items, $awm_t);
    241305    //print_r($menu_items);
    242     if ($awm_term_id==-1) {return ($awm_isXML || $awm_isUL)?"":$awm_ic;}
    243     else return AWM_create_existing_dynamic_menu__step($awm_t, $awm_ic, $awm_parentgroup, $menu_items, $awm_depth, 0, $awm_recent, $awm_isXML, $awm_isUL, $ext);
    244 }
    245 
    246 function AWM_existing_has_kids($awm_id, $menu_items) {
    247     for ($awm_i=0; $awm_i<count($menu_items); $awm_i++) { if ($menu_items[$awm_i]->menu_item_parent==$awm_id) return true; }
     306    if ($awm_term_id == -1) {
     307        return ($awm_isXML || $awm_isUL) ? "" : $awm_ic;
     308    } else {
     309        return AWM_create_existing_dynamic_menu__step($awm_t, $awm_ic, $awm_parentgroup, $menu_items, $awm_depth, 0, $awm_recent,
     310            $awm_isXML, $awm_isUL, $ext);
     311    }
     312}
     313
     314function AWM_existing_has_kids($awm_id, $menu_items)
     315{
     316    for ($awm_i = 0; $awm_i < count($menu_items); $awm_i++) {
     317        if ($menu_items[$awm_i]->menu_item_parent == $awm_id) {
     318            return true;
     319        }
     320    }
    248321    return false;
    249322}
    250323
    251324
    252 function AWM_create_existing_dynamic_menu__step($awm_t, $awm_ic, $awm_parentgroup, $menu_items, $awm_depth, $awm_group, $awm_recent, $awm_isXML, $awm_isUL, $ext) {
    253     $awm_m = $awm_t->name.$ext;
    254     $awm_xml_out = "";
    255     if ($awm_isUL) {
    256         $tabs = ""; for ($i=0; $i<$awm_depth; $i++) $tabs .= "\t\t";
    257     }
    258     for ($awm_i=0; $awm_i<count($menu_items); $awm_i++) {
    259         if ($menu_items[$awm_i]->menu_item_parent==$awm_group) {
     325function AWM_create_existing_dynamic_menu__step(
     326    $awm_t,
     327    $awm_ic,
     328    $awm_parentgroup,
     329    $menu_items,
     330    $awm_depth,
     331    $awm_group,
     332    $awm_recent,
     333    $awm_isXML,
     334    $awm_isUL,
     335    $ext
     336) {
     337    $awm_m = $awm_t->name . $ext;
     338    $awm_xml_out = "";
     339    if ($awm_isUL) {
     340        $tabs = "";
     341        for ($i = 0; $i < $awm_depth; $i++) {
     342            $tabs .= "\t\t";
     343        }
     344    }
     345    for ($awm_i = 0; $awm_i < count($menu_items); $awm_i++) {
     346        if ($menu_items[$awm_i]->menu_item_parent == $awm_group) {
    260347            if ($awm_isXML) {
    261                 $awm_xml_out .= "<item><id>page_".$menu_items[$awm_i]->ID."</id><name>".$menu_items[$awm_i]->title."</name><link>".$menu_items[$awm_i]->url."</link><submenu>";
     348                $awm_xml_out .= "<item><id>page_" . $menu_items[$awm_i]->ID . "</id><name>" . $menu_items[$awm_i]->title . "</name><link>" . $menu_items[$awm_i]->url . "</link><submenu>";
    262349            } elseif ($awm_isUL) {
    263                 $awm_xml_out .= "$tabs\t<li>\n$tabs\t\t<a href=\"".$menu_items[$awm_i]->url."\">".$menu_items[$awm_i]->title."</a>\n";
     350                $awm_xml_out .= "$tabs\t<li>\n$tabs\t\t<a href=\"" . $menu_items[$awm_i]->url . "\">" . $menu_items[$awm_i]->title . "</a>\n";
    264351            } else {
    265                 echo "item".$awm_depth."=".$awm_parentgroup.".newItem('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'main_item_style':((wplevel+$awm_depth)==1?'sub_item_style':'sub_item_plus_style'))+';itemid=".($awm_ic++).";text0=".str_replace("'","\'",$menu_items[$awm_i]->title).";".($menu_items[$awm_i]->url!=""?"url=".$menu_items[$awm_i]->url:"").($menu_items[$awm_i]->targetframe!=""?";targetframe=".$menu_items[$awm_i]->target:"")."');\n";
     352                echo "item" . $awm_depth . "=" . $awm_parentgroup . ".newItem('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'main_item_style':((wplevel+$awm_depth)==1?'sub_item_style':'sub_item_plus_style'))+';itemid=" . ($awm_ic++) . ";text0=" . str_replace("'",
     353                        "\'",
     354                        $menu_items[$awm_i]->title) . ";" . ($menu_items[$awm_i]->url != "" ? "url=" . $menu_items[$awm_i]->url : "") . ($menu_items[$awm_i]->targetframe != "" ? ";targetframe=" . $menu_items[$awm_i]->target : "") . "');\n";
    266355            }
    267356            if (AWM_existing_has_kids($menu_items[$awm_i]->ID, $menu_items)) {
    268357                if ($awm_isXML || $awm_isUL) {
    269                     if ($awm_isUL) $awm_xml_out .= "$tabs\t\t<ul>\n";
    270                     $awm_xml_out .= AWM_create_existing_dynamic_menu__step($awm_t, $awm_ic, "wpsubMenu".$awm_depth, $menu_items, $awm_depth+1, $menu_items[$awm_i]->ID, $awm_recent, $awm_isXML, $awm_isUL, $ext);
    271                     if ($awm_isUL) $awm_xml_out .= "$tabs\t\t</ul>\n";
     358                    if ($awm_isUL) {
     359                        $awm_xml_out .= "$tabs\t\t<ul>\n";
     360                    }
     361                    $awm_xml_out .= AWM_create_existing_dynamic_menu__step($awm_t, $awm_ic, "wpsubMenu" . $awm_depth, $menu_items,
     362                        $awm_depth + 1, $menu_items[$awm_i]->ID, $awm_recent, $awm_isXML, $awm_isUL, $ext);
     363                    if ($awm_isUL) {
     364                        $awm_xml_out .= "$tabs\t\t</ul>\n";
     365                    }
    272366                } else {
    273                     echo "wpsubMenu".$awm_depth."=item".$awm_depth.".newGroup('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_".$awm_m.")=='object')?((wplevel+$awm_depth)==0?wphf_".$awm_m."[0]:wphf_".$awm_m."[1]):''));\n";
    274                     $awm_ic = AWM_create_existing_dynamic_menu__step($awm_t, $awm_ic, "wpsubMenu".$awm_depth, $menu_items, $awm_depth+1, $menu_items[$awm_i]->ID, $awm_recent, $awm_isXML, $awm_isUL, $ext);
     367                    echo "wpsubMenu" . $awm_depth . "=item" . $awm_depth . ".newGroup('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_" . $awm_m . ")=='object')?((wplevel+$awm_depth)==0?wphf_" . $awm_m . "[0]:wphf_" . $awm_m . "[1]):''));\n";
     368                    $awm_ic = AWM_create_existing_dynamic_menu__step($awm_t, $awm_ic, "wpsubMenu" . $awm_depth, $menu_items, $awm_depth + 1,
     369                        $menu_items[$awm_i]->ID, $awm_recent, $awm_isXML, $awm_isUL, $ext);
    275370                }
    276371            }
    277             if ($awm_isXML) $awm_xml_out .= "</submenu></item>";
    278             elseif ($awm_isUL) $awm_xml_out .= "$tabs\t</li>\n";
    279         }
    280     }
    281     if ($awm_isXML || $awm_isUL) return $awm_xml_out;
    282     else return $awm_ic;
    283 }
    284 
    285    
     372            if ($awm_isXML) {
     373                $awm_xml_out .= "</submenu></item>";
     374            } elseif ($awm_isUL) {
     375                $awm_xml_out .= "$tabs\t</li>\n";
     376            }
     377        }
     378    }
     379    if ($awm_isXML || $awm_isUL) {
     380        return $awm_xml_out;
     381    } else {
     382        return $awm_ic;
     383    }
     384}
     385
     386
    286387/*
    287388 * Create the posts menu
    288389 */
    289 function AWM_create_dynamic_menu__posts($awm_t, $awm_parentgroup, $awm_ic, $awm_isXML, $awm_isUL, $ext) {
     390function AWM_create_dynamic_menu__posts($awm_t, $awm_parentgroup, $awm_ic, $awm_isXML, $awm_isUL, $ext)
     391{
    290392    $awm_depth = 0;
    291     $awm_m = $awm_t->name.$ext;
     393    $awm_m = $awm_t->name . $ext;
    292394    $awm_xml_out = "";
    293395    global $wpdb;
    294    
    295     if ( $awm_t->posts_ids=="") return ($awm_isXML || $awm_isUL)?"":$awm_ic;
     396
     397    if ($awm_t->posts_ids == "") {
     398        return ($awm_isXML || $awm_isUL) ? "" : $awm_ic;
     399    }
    296400    $awm_post_res = AWM_get_post_restrictions($awm_t);
    297    
     401
    298402    $awm_posts_to_display = "";
    299403    $awm_posts_ids = $awm_t->posts_ids;
    300404    $awm_posts_ids = str_replace(' ', '', $awm_posts_ids);
    301405    $awm_posts_ids = (array)explode(',', $awm_posts_ids);
    302     for ($awm_i=0; $awm_i<sizeof($awm_posts_ids); $awm_i++) $awm_posts_to_display .= " OR ID='".$awm_posts_ids[$awm_i]."'";
    303     $awm_posts_to_display = "AND (".substr($awm_posts_to_display,4).")";
    304    
     406    for ($awm_i = 0; $awm_i < sizeof($awm_posts_ids); $awm_i++) {
     407        $awm_posts_to_display .= " OR ID='" . $awm_posts_ids[$awm_i] . "'";
     408    }
     409    $awm_posts_to_display = "AND (" . substr($awm_posts_to_display, 4) . ")";
     410
    305411    $awm_posts = (array)$wpdb->get_results("
    306412        SELECT ID, post_title
     
    310416        ORDER BY post_date DESC
    311417    ");
    312    
    313     if (count($awm_posts)>0) {
    314         if ($awm_isUL) {
    315             $tabs = ""; for ($i=0; $i<$awm_depth; $i++) $tabs .= "\t\t";
     418
     419    if (count($awm_posts) > 0) {
     420        if ($awm_isUL) {
     421            $tabs = "";
     422            for ($i = 0; $i < $awm_depth; $i++) {
     423                $tabs .= "\t\t";
     424            }
    316425        }
    317426        if ($awm_isXML) {
    318             if ($awm_t->posts_ms=='sub') $awm_xml_out .= "<item><id>posts</id><name>".$awm_t->posts_name."</name><link></link><submenu>";
    319             for ($awm_i=0; $awm_i<count($awm_posts); $awm_i++) $awm_xml_out .= "<item><id>post_".$awm_posts[$awm_i]->ID."</id><name>".$awm_posts[$awm_i]->post_title."</name><link>".get_permalink($awm_posts[$awm_i]->ID)."</link><submenu></submenu></item>";
    320             if ($awm_t->posts_ms=='sub') $awm_xml_out .= "</submenu></item>";
     427            if ($awm_t->posts_ms == 'sub') {
     428                $awm_xml_out .= "<item><id>posts</id><name>" . $awm_t->posts_name . "</name><link></link><submenu>";
     429            }
     430            for ($awm_i = 0; $awm_i < count($awm_posts); $awm_i++) {
     431                $awm_xml_out .= "<item><id>post_" . $awm_posts[$awm_i]->ID . "</id><name>" . $awm_posts[$awm_i]->post_title . "</name><link>" . get_permalink($awm_posts[$awm_i]->ID) . "</link><submenu></submenu></item>";
     432            }
     433            if ($awm_t->posts_ms == 'sub') {
     434                $awm_xml_out .= "</submenu></item>";
     435            }
    321436        } elseif ($awm_isUL) {
    322             if ($awm_t->posts_ms=='sub') $awm_xml_out .= "$tabs\t<li>$tabs\t\t<a href=\"javascript:void(0);\">".$awm_t->posts_name."</a>\n$tabs\t\t<ul>\n";
    323             for ($awm_i=0; $awm_i<count($awm_posts); $awm_i++) $awm_xml_out .= "$tabs\t\t\t<li>$tabs\t\t\t\t<a href=\"".get_permalink($awm_posts[$awm_i]->ID)."\">".$awm_posts[$awm_i]->post_title."</a>\n$tabs\t\t\t</li>\n";
    324             if ($awm_t->posts_ms=='sub') $awm_xml_out .= "$tabs\t\t</ul>\n$tabs\t</li>\n";
     437            if ($awm_t->posts_ms == 'sub') {
     438                $awm_xml_out .= "$tabs\t<li>$tabs\t\t<a href=\"javascript:void(0);\">" . $awm_t->posts_name . "</a>\n$tabs\t\t<ul>\n";
     439            }
     440            for ($awm_i = 0; $awm_i < count($awm_posts); $awm_i++) {
     441                $awm_xml_out .= "$tabs\t\t\t<li>$tabs\t\t\t\t<a href=\"" . get_permalink($awm_posts[$awm_i]->ID) . "\">" . $awm_posts[$awm_i]->post_title . "</a>\n$tabs\t\t\t</li>\n";
     442            }
     443            if ($awm_t->posts_ms == 'sub') {
     444                $awm_xml_out .= "$tabs\t\t</ul>\n$tabs\t</li>\n";
     445            }
    325446        } else {
    326             if ($awm_t->posts_ms=='sub') {
    327                 echo "item0=".$awm_parentgroup.".newItem('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'main_item_style':((wplevel+$awm_depth)==1?'sub_item_style':'sub_item_plus_style'))+';itemid=".($awm_ic++).";text0=".str_replace("'","\'",$awm_t->posts_name)."');\n";
    328                 echo "wpsubMenu0=item0.newGroup('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_".$awm_m.")=='object')?((wplevel+$awm_depth)==0?wphf_".$awm_m."[0]:wphf_".$awm_m."[1]):''));\n";
     447            if ($awm_t->posts_ms == 'sub') {
     448                echo "item0=" . $awm_parentgroup . ".newItem('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'main_item_style':((wplevel+$awm_depth)==1?'sub_item_style':'sub_item_plus_style'))+';itemid=" . ($awm_ic++) . ";text0=" . str_replace("'",
     449                        "\'", $awm_t->posts_name) . "');\n";
     450                echo "wpsubMenu0=item0.newGroup('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_" . $awm_m . ")=='object')?((wplevel+$awm_depth)==0?wphf_" . $awm_m . "[0]:wphf_" . $awm_m . "[1]):''));\n";
    329451                $awm_depth++;
    330452                $awm_parentgroup = "wpsubMenu0";
    331453            }
    332             for ($awm_i=0; $awm_i<count($awm_posts); $awm_i++) echo "item0=".$awm_parentgroup.".newItem('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'main_item_style':((wplevel+$awm_depth)==1?'sub_item_style':'sub_item_plus_style'))+';itemid=".($awm_ic++).";text0=".str_replace("'","\'",$awm_posts[$awm_i]->post_title).";".(get_permalink($awm_posts[$awm_i]->ID)!=""?"url=".get_permalink($awm_posts[$awm_i]->ID):"")."');\n";
    333         }
    334     }
    335    
    336     if ($awm_isXML || $awm_isUL) return $awm_xml_out;
    337     else return $awm_ic;
    338 }
    339 
    340 function AWM_create_dynamic_menu__pages($awm_t, $awm_parentgroup, $awm_ic, $awm_isXML, $awm_isUL, $ext) {
     454            for ($awm_i = 0; $awm_i < count($awm_posts); $awm_i++) {
     455                echo "item0=" . $awm_parentgroup . ".newItem('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'main_item_style':((wplevel+$awm_depth)==1?'sub_item_style':'sub_item_plus_style'))+';itemid=" . ($awm_ic++) . ";text0=" . str_replace("'",
     456                        "\'",
     457                        $awm_posts[$awm_i]->post_title) . ";" . (get_permalink($awm_posts[$awm_i]->ID) != "" ? "url=" . get_permalink($awm_posts[$awm_i]->ID) : "") . "');\n";
     458            }
     459        }
     460    }
     461
     462    if ($awm_isXML || $awm_isUL) {
     463        return $awm_xml_out;
     464    } else {
     465        return $awm_ic;
     466    }
     467}
     468
     469function AWM_create_dynamic_menu__pages($awm_t, $awm_parentgroup, $awm_ic, $awm_isXML, $awm_isUL, $ext)
     470{
    341471    $awm_depth = 0;
    342     $awm_m = $awm_t->name.$ext;
     472    $awm_m = $awm_t->name . $ext;
    343473    $awm_xml_out = "";
    344474    global $wpdb;
    345         $awm_recent = array();
     475    $awm_recent = array();
    346476    $awm_post_res = AWM_get_post_restrictions($awm_t);
    347477    $awm_pages_to_avoid = "";
    348     if ($awm_t->excluded_pages!='') {
     478    if ($awm_t->excluded_pages != '') {
    349479        $awm_posts_ids = $awm_t->excluded_pages;
    350480        $awm_posts_ids = str_replace(' ', '', $awm_posts_ids);
    351481        $awm_posts_ids = (array)explode(',', $awm_posts_ids);
    352         for ($awm_i=0; $awm_i<sizeof($awm_posts_ids); $awm_i++) $awm_pages_to_avoid .= ",".$awm_posts_ids[$awm_i];
    353         $awm_pages_to_avoid = "AND p.ID NOT IN (".substr($awm_pages_to_avoid,1).") AND p.post_parent NOT IN (".substr($awm_pages_to_avoid,1).")";
    354     }
    355    
     482        for ($awm_i = 0; $awm_i < sizeof($awm_posts_ids); $awm_i++) {
     483            $awm_pages_to_avoid .= "," . $awm_posts_ids[$awm_i];
     484        }
     485        $awm_pages_to_avoid = "AND p.ID NOT IN (" . substr($awm_pages_to_avoid,
     486                1) . ") AND p.post_parent NOT IN (" . substr($awm_pages_to_avoid, 1) . ")";
     487    }
     488
    356489    $awm_pages = (array)$wpdb->get_results("
    357490        SELECT post_title, ID, post_parent
     
    362495        ORDER BY post_parent, post_date ASC
    363496    ");
    364    
     497
    365498    if ($awm_isXML) {
    366         if ($awm_t->pages_ms == 'sub') $awm_xml_out .= "<item><id>pages</id><name>".$awm_t->pages_name."</name><link></link><submenu>";
    367         $awm_xml_out .= AWM_create_dynamic_menu__pages_step($awm_t, $awm_ic, $awm_parentgroup, $awm_pages, $awm_depth, 0, $awm_recent, $awm_isXML, $awm_isUL, $ext);
    368         if ($awm_t->pages_ms == 'sub') $awm_xml_out .= "</submenu></item>";
     499        if ($awm_t->pages_ms == 'sub') {
     500            $awm_xml_out .= "<item><id>pages</id><name>" . $awm_t->pages_name . "</name><link></link><submenu>";
     501        }
     502        $awm_xml_out .= AWM_create_dynamic_menu__pages_step($awm_t, $awm_ic, $awm_parentgroup, $awm_pages, $awm_depth, 0, $awm_recent,
     503            $awm_isXML, $awm_isUL, $ext);
     504        if ($awm_t->pages_ms == 'sub') {
     505            $awm_xml_out .= "</submenu></item>";
     506        }
    369507        return $awm_xml_out;
    370508    } elseif ($awm_isUL) {
    371         if ($awm_t->pages_ms == 'sub') $awm_xml_out .= "\t<li>\n\t\t<a href=\"javascript:void(0);\">".$awm_t->pages_name."</a>\n";
    372         $awm_xml_out .= AWM_create_dynamic_menu__pages_step($awm_t, $awm_ic, $awm_parentgroup, $awm_pages, $awm_depth, 0, $awm_recent, $awm_isXML, $awm_isUL, $ext);
    373         if ($awm_t->pages_ms == 'sub') $awm_xml_out .= "\t</li>\n";
    374         return $awm_xml_out;
    375     } else {
    376         if ($awm_t->pages_ms=='sub') {
    377             echo "item0=".$awm_m.".newItem('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'main_item_style':((wplevel+$awm_depth)==1?'sub_item_style':'sub_item_plus_style'))+';itemid=".($awm_ic++).";text0=".str_replace("'","\'",$awm_t->pages_name)."');\n";
    378             echo "wpsubMenu0=item0.newGroup('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_".$awm_m.")=='object')?((wplevel+$awm_depth)==0?wphf_".$awm_m."[0]:wphf_".$awm_m."[1]):''));\n";
     509        if ($awm_t->pages_ms == 'sub') {
     510            $awm_xml_out .= "\t<li>\n\t\t<a href=\"javascript:void(0);\">" . $awm_t->pages_name . "</a>\n";
     511        }
     512        $awm_xml_out .= AWM_create_dynamic_menu__pages_step($awm_t, $awm_ic, $awm_parentgroup, $awm_pages, $awm_depth, 0, $awm_recent,
     513            $awm_isXML, $awm_isUL, $ext);
     514        if ($awm_t->pages_ms == 'sub') {
     515            $awm_xml_out .= "\t</li>\n";
     516        }
     517        return $awm_xml_out;
     518    } else {
     519        if ($awm_t->pages_ms == 'sub') {
     520            echo "item0=" . $awm_m . ".newItem('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'main_item_style':((wplevel+$awm_depth)==1?'sub_item_style':'sub_item_plus_style'))+';itemid=" . ($awm_ic++) . ";text0=" . str_replace("'",
     521                    "\'", $awm_t->pages_name) . "');\n";
     522            echo "wpsubMenu0=item0.newGroup('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_" . $awm_m . ")=='object')?((wplevel+$awm_depth)==0?wphf_" . $awm_m . "[0]:wphf_" . $awm_m . "[1]):''));\n";
    379523            $awm_depth++;
    380524            $awm_parentgroup = "wpsubMenu0";
    381525        }
    382         return AWM_create_dynamic_menu__pages_step($awm_t, $awm_ic, $awm_parentgroup, $awm_pages, $awm_depth, 0, $awm_recent, $awm_isXML, $awm_isUL, $ext);
    383     }
    384 }
    385 
    386 function AWM_page_has_kids($awm_id, $awm_pages) {
    387     for ($awm_i=0; $awm_i<count($awm_pages); $awm_i++) if ($awm_pages[$awm_i]->post_parent==$awm_id) return true;
     526        return AWM_create_dynamic_menu__pages_step($awm_t, $awm_ic, $awm_parentgroup, $awm_pages, $awm_depth, 0, $awm_recent, $awm_isXML,
     527            $awm_isUL, $ext);
     528    }
     529}
     530
     531function AWM_page_has_kids($awm_id, $awm_pages)
     532{
     533    for ($awm_i = 0; $awm_i < count($awm_pages); $awm_i++) {
     534        if ($awm_pages[$awm_i]->post_parent == $awm_id) {
     535            return true;
     536        }
     537    }
    388538    return false;
    389539}
    390540
    391541
    392 function AWM_create_dynamic_menu__pages_step($awm_t, $awm_ic, $awm_parentgroup, $awm_pages, $awm_depth, $awm_group, $awm_recent, $awm_isXML, $awm_isUL, $ext) {
    393     $awm_m = $awm_t->name.$ext;
    394     $awm_xml_out = "";
    395     if ($awm_isUL) {
    396         $tabs = ""; for ($i=0; $i<$awm_depth; $i++) $tabs .= "\t\t";
    397     }
    398     for ($awm_i=0; $awm_i<count($awm_pages); $awm_i++) {
    399         if ($awm_pages[$awm_i]->post_parent==$awm_group) {
     542function AWM_create_dynamic_menu__pages_step(
     543    $awm_t,
     544    $awm_ic,
     545    $awm_parentgroup,
     546    $awm_pages,
     547    $awm_depth,
     548    $awm_group,
     549    $awm_recent,
     550    $awm_isXML,
     551    $awm_isUL,
     552    $ext
     553) {
     554    $awm_m = $awm_t->name . $ext;
     555    $awm_xml_out = "";
     556    if ($awm_isUL) {
     557        $tabs = "";
     558        for ($i = 0; $i < $awm_depth; $i++) {
     559            $tabs .= "\t\t";
     560        }
     561    }
     562    for ($awm_i = 0; $awm_i < count($awm_pages); $awm_i++) {
     563        if ($awm_pages[$awm_i]->post_parent == $awm_group) {
    400564            if ($awm_isXML) {
    401                 $awm_xml_out .= "<item><id>page_".$awm_pages[$awm_i]->ID."</id><name>".$awm_pages[$awm_i]->post_title."</name><link>".get_permalink($awm_pages[$awm_i]->ID)."</link><submenu>";
     565                $awm_xml_out .= "<item><id>page_" . $awm_pages[$awm_i]->ID . "</id><name>" . $awm_pages[$awm_i]->post_title . "</name><link>" . get_permalink($awm_pages[$awm_i]->ID) . "</link><submenu>";
    402566            } elseif ($awm_isUL) {
    403                 $awm_xml_out .= "$tabs\t<li>\n$tabs\t\t<a href=\"".get_permalink($awm_pages[$awm_i]->ID)."\">".$awm_pages[$awm_i]->post_title."</a>\n";
     567                $awm_xml_out .= "$tabs\t<li>\n$tabs\t\t<a href=\"" . get_permalink($awm_pages[$awm_i]->ID) . "\">" . $awm_pages[$awm_i]->post_title . "</a>\n";
    404568            } else {
    405                 echo "item".$awm_depth."=".$awm_parentgroup.".newItem('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'main_item_style':((wplevel+$awm_depth)==1?'sub_item_style':'sub_item_plus_style'))+';itemid=".($awm_ic++).";text0=".str_replace("'","\'",$awm_pages[$awm_i]->post_title).";".(get_permalink($awm_pages[$awm_i]->ID)!=""?"url=".get_permalink($awm_pages[$awm_i]->ID):"")."');\n";
     569                echo "item" . $awm_depth . "=" . $awm_parentgroup . ".newItem('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'main_item_style':((wplevel+$awm_depth)==1?'sub_item_style':'sub_item_plus_style'))+';itemid=" . ($awm_ic++) . ";text0=" . str_replace("'",
     570                        "\'",
     571                        $awm_pages[$awm_i]->post_title) . ";" . (get_permalink($awm_pages[$awm_i]->ID) != "" ? "url=" . get_permalink($awm_pages[$awm_i]->ID) : "") . "');\n";
    406572            }
    407573            if (AWM_page_has_kids($awm_pages[$awm_i]->ID, $awm_pages)) {
    408574                if ($awm_isXML || $awm_isUL) {
    409                     if ($awm_isUL) $awm_xml_out .= "$tabs\t\t<ul>\n";
    410                     $awm_xml_out .= AWM_create_dynamic_menu__pages_step($awm_t, $awm_ic, "wpsubMenu".$awm_depth, $awm_pages, $awm_depth+1, $awm_pages[$awm_i]->ID, $awm_recent, $awm_isXML, $awm_isUL, $ext);
    411                     if ($awm_isUL) $awm_xml_out .= "$tabs\t\t</ul>\n";
     575                    if ($awm_isUL) {
     576                        $awm_xml_out .= "$tabs\t\t<ul>\n";
     577                    }
     578                    $awm_xml_out .= AWM_create_dynamic_menu__pages_step($awm_t, $awm_ic, "wpsubMenu" . $awm_depth, $awm_pages,
     579                        $awm_depth + 1, $awm_pages[$awm_i]->ID, $awm_recent, $awm_isXML, $awm_isUL, $ext);
     580                    if ($awm_isUL) {
     581                        $awm_xml_out .= "$tabs\t\t</ul>\n";
     582                    }
    412583                } else {
    413                     echo "\n\nwpsubMenu".$awm_depth."=item".$awm_depth.".newGroup('style=".$awm_m."_'+((wplevel+$awm_depth)==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_".$awm_m.")=='object')?((wplevel+$awm_depth)==0?wphf_".$awm_m."[0]:wphf_".$awm_m."[1]):''));\n\n\n";
    414                     $awm_ic = AWM_create_dynamic_menu__pages_step($awm_t, $awm_ic, "wpsubMenu".$awm_depth, $awm_pages, $awm_depth+1, $awm_pages[$awm_i]->ID, $awm_recent, $awm_isXML, $awm_isUL, $ext);
     584                    echo "\n\nwpsubMenu" . $awm_depth . "=item" . $awm_depth . ".newGroup('style=" . $awm_m . "_'+((wplevel+$awm_depth)==0?'sub_group_style':'sub_group_plus_style')+((typeof(wphf_" . $awm_m . ")=='object')?((wplevel+$awm_depth)==0?wphf_" . $awm_m . "[0]:wphf_" . $awm_m . "[1]):''));\n\n\n";
     585                    $awm_ic = AWM_create_dynamic_menu__pages_step($awm_t, $awm_ic, "wpsubMenu" . $awm_depth, $awm_pages, $awm_depth + 1,
     586                        $awm_pages[$awm_i]->ID, $awm_recent, $awm_isXML, $awm_isUL, $ext);
    415587                }
    416588            }
    417             if ($awm_isXML) $awm_xml_out .= "</submenu></item>";
    418             if ($awm_isUL) $awm_xml_out .= "$tabs\t</li>\n";
    419         }
    420     }
    421     if ($awm_isXML || $awm_isUL) return $awm_xml_out;
    422     else return $awm_ic;
    423 }
    424 
    425 function AWM_get_post_restrictions($awm_t) {
     589            if ($awm_isXML) {
     590                $awm_xml_out .= "</submenu></item>";
     591            }
     592            if ($awm_isUL) {
     593                $awm_xml_out .= "$tabs\t</li>\n";
     594            }
     595        }
     596    }
     597    if ($awm_isXML || $awm_isUL) {
     598        return $awm_xml_out;
     599    } else {
     600        return $awm_ic;
     601    }
     602}
     603
     604function AWM_get_post_restrictions($awm_t)
     605{
    426606    $awm_pass_check = '';
    427607    if ($awm_t->hide_protected) {
    428608        $awm_pass_check = " AND p.post_password = '' ";
    429609    }
    430    
     610
    431611    $awm_future_check = '';
    432612    if ($awm_t->hide_future) {
    433613        $awm_future_check = " AND p.post_status != 'future' ";
    434614    }
    435         $awm_private_check = '';
     615    $awm_private_check = '';
    436616    if ($awm_t->hide_private) {
    437617        $awm_private_check = " AND p.post_status != 'private' ";
    438618    }
    439     return $awm_pass_check.$awm_future_check.$awm_private_check;
    440 }
    441 function AWM_apply_custom_menu_restrictions($menu_items,$awm_t) {
    442         global $wpdb;
    443     $menu_items2= array();
    444         foreach ($menu_items as $item){
    445         if ($item->type == "post_type"){
    446         $post = get_post( $item->id);
    447        
    448     if ($awm_t->hide_protected) {
    449            
    450             if (!empty($post->post_password))
    451                     continue;}
    452 
    453             if ($awm_t->hide_future) {
    454         if ($post->post_status=="future")
    455                     continue;
    456     }
    457         if ($awm_t->hide_private) {
    458         if ($post->post_status=="private")
    459                     continue;
    460     }
    461         }
    462     $menu_items2[] =$item;
    463 
    464 
    465         }
     619    return $awm_pass_check . $awm_future_check . $awm_private_check;
     620}
     621
     622function AWM_apply_custom_menu_restrictions($menu_items, $awm_t)
     623{
     624    global $wpdb;
     625    $menu_items2 = array();
     626    foreach ($menu_items as $item) {
     627        if ($item->type == "post_type") {
     628            $post = get_post($item->id);
     629
     630            if ($awm_t->hide_protected) {
     631
     632                if ( ! empty($post->post_password)) {
     633                    continue;
     634                }
     635            }
     636
     637            if ($awm_t->hide_future) {
     638                if ($post->post_status == "future") {
     639                    continue;
     640                }
     641            }
     642            if ($awm_t->hide_private) {
     643                if ($post->post_status == "private") {
     644                    continue;
     645                }
     646            }
     647        }
     648        $menu_items2[] = $item;
     649
     650
     651    }
    466652    return $menu_items2;
    467653}
  • allwebmenus-wordpress-menu-plugin/trunk/readme.txt

    r1165177 r2008056  
    22Contributors: Likno Software
    33Author: Likno Software
    4 Author URI: http://www.likno.com
    5 Plugin URI: http://www.likno.com/addins/wordpress-menu.html
     4Author URI: https://www.likno.com
     5Plugin URI: https://www.likno.com/addins/wordpress-menu.html
    66Tags: web menu, allwebmenus, drop down menu, javascript menu, dhtml menu, menu builder, navigation menu, css menu, ajax menu, responsive menu
    7 Stable Tag: 1.1.23
    8 Requires at least: 2.3
    9 Tested up to: 4.2.2
     7Stable Tag: 1.1.24
     8Requires at least: 3.0
     9Tested up to: 5.0.2
    1010
    1111
     
    1515== Description ==
    1616
    17 **Important Clarification Note:** AllWebMenus Pro is a **commercial** application (not free) and is required for this plugin. Click here for the [AllWebMenus Pro Order Page](http://www.likno.com/awmregister.php "AllWebMenus Pro Order Page").
     17**Important Clarification Note:** AllWebMenus Pro is a **commercial** application (not free) and is required for this plugin. Click here for the [AllWebMenus Pro Order Page](https://www.likno.com/awmregister.php "AllWebMenus Pro Order Page").
    1818
    1919The **AllWebMenus WordPress Menu add-in & plugin** combination is designed to retrieve information from your blog (such as posts, pages, etc.) and import it into the AllWebMenus application to create stylish, feature-rich navigation menus, and not only! Apart from creating menu items derived from your blog's structure, fully customize your menus adding your own non-wordpress menu items with external or internal links, html-rich content, colors, borders, effects, designs of your choice and many more!
    2020
    21 View [examples of menus created with AllWebMenus](http://www.likno.com/examples.html "examples of menus created with AllWebMenus").
     21View [examples of menus created with AllWebMenus](https://www.likno.com/examples.html "examples of menus created with AllWebMenus").
    2222
    2323**AllWebMenus** is a web menu builder that requires absolutely no DHTML or Javascript experience from you. It creates cross-browser navigation menus that work alike in all browsers supporting DHTML. A DHTML menu / JavaScript menu can be designed with a simple, tree-like approach. You can then fully customize it by applying a vast available number of features through the Properties Pane or by choosing a predefined appearance from the Theme Gallery.
    2424
    25 For documentation, examples and screenshots, please refer to the official plugin page for [AllWebMenus WordPress Menu](http://www.likno.com/addins/wordpress-menu.html "AllWebMenus WordPress Menu").
     25For documentation, examples and screenshots, please refer to the official plugin page for [AllWebMenus WordPress Menu](https://www.likno.com/addins/wordpress-menu.html "AllWebMenus WordPress Menu").
    2626
    2727
     
    5858   
    5959    ...and many more!
    60     For more detailed features list visit the [AllWebMenus PRO Features Page](http://www.likno.com/allwebmenusinfo.html "AllWebMenus PRO Features Page") in the Likno Web Site.
     60    For more detailed features list visit the [AllWebMenus PRO Features Page](https://www.likno.com/allwebmenusinfo.html "AllWebMenus PRO Features Page") in the Likno Web Site.
    6161
    6262== Installation ==
     
    6464- Upload files to your `/wp-content/plugins/` directory (preserve sub-directory structure)
    6565- Activate the plugin through the 'Plugins' menu in WordPress
    66 - Refer to the [official plugin page](http://www.likno.com/addins/wordpress-menu.html "official plugin page") for documentation, usage and tips
     66- Refer to the [official plugin page](https://www.likno.com/addins/wordpress-menu.html "official plugin page") for documentation, usage and tips
    6767
    6868
    6969== Changelog ==
     70= 1.1.24 (requires AllWebMenus Build #926 or above) =
     71* Supports WordPress v5 (i.e. from v3 up to v5)
    7072= 1.1.23 (requires AllWebMenus Build #926 or above) =
    7173* Supports WordPress v4.2.2 (fixes some errors due to changes in WordPress)
     
    171173
    172174This feature is build on Yet Another Related Posts Plugin by mitcho (Michael Yoshitaka Erlewine).
    173 Visit the [YARPP plugin's site](http://mitcho.com/code/yarpp/ "YARPP plugin's site").
     175Visit the [YARPP plugin's site](https://mitcho.com/code/yarpp/ "YARPP plugin's site").
  • allwebmenus-wordpress-menu-plugin/trunk/script.js

    r1165187 r2008056  
    11 /*
    22Plugin Name: AllWebMenus WordPress Menu Plugin
    3 Plugin URI: http://www.likno.com/addins/wordpress-menu.html
     3Plugin URI: https://www.likno.com/addins/wordpress-menu.html
    44Description: WordPress plugin for the AllWebMenus PRO Javascript Menu Maker - Create stylish drop-down menus or sliding menus for your blogs!
    55Version: 1.1.17
    66Author: Likno Software
    7 Author URI: http://www.likno.com/
     7Author URI: https://www.likno.com/
    88*/
    99
  • allwebmenus-wordpress-menu-plugin/trunk/widgetClass.php

    r1165182 r2008056  
    11<?php
     2
    23/*
    34 * This is the class of the allwebmenus widget.
    45 */
    5 class Widget_AllWebMenus extends WP_Widget {
    66
    7     function Widget_AllWebMenus() {
    8         $widget_ops = array( 'description' => __( "Do not use the drag and drop feature here. Please choose one of the menu widgets found at the “Inactive Widgets” section at the bottom of this page. Also remember that you should also have the “Widget” option selected at the “Menu Positioning Method” property of the AllWebMenus plugin settings page. ") );
     7class Widget_AllWebMenus extends WP_Widget
     8{
     9
     10    function Widget_AllWebMenus()
     11    {
     12        $widget_ops = array('description' => __("Do not use the drag and drop feature here. Please choose one of the menu widgets found at the “Inactive Widgets” section at the bottom of this page. Also remember that you should also have the “Widget” option selected at the “Menu Positioning Method” property of the AllWebMenus plugin settings page. "));
    913        $this->WP_Widget('Widget_AllWebMenus', __('AllWebMenus'), $widget_ops);
    1014    }
    11        
    12     function widget( $args, $instance ) {
    13                 global $wpdb,$awm_table_name;
     15
     16    function widget($args, $instance)
     17    {
     18        global $wpdb, $awm_table_name;
    1419        extract($args, EXTR_SKIP);
    15                 if (isset($instance['div_name']))
    16                     $awmName = $wpdb->get_var('SELECT name from '.$awm_table_name.' where position LIKE "awm_widget" && id = '.(int)$instance['div_name']);
    17                 else
    18                     $awmName = '';
    19                
     20        if (isset($instance['div_name'])) {
     21            $awmName = $wpdb->get_var('SELECT name from ' . $awm_table_name . ' where position LIKE "awm_widget" && id = ' . (int)$instance['div_name']);
     22        } else {
     23            $awmName = '';
     24        }
    2025
    21                 if (!empty($awmName))
    22               {
    23                     echo $before_widget;
    24                     $div_name = "awmAnchor-".$awmName;
    25                     echo "<div id='$div_name'>&nbsp;</div>";
    26                     echo $after_widget;
    27                 }
     26
     27        if ( ! empty($awmName)) {
     28            echo $before_widget;
     29            $div_name = "awmAnchor-" . $awmName;
     30            echo "<div id='$div_name'>&nbsp;</div>";
     31            echo $after_widget;
     32        }
    2833
    2934    }
    3035
    31     function update( $new_instance, $old_instance ) {
    32        
    33                 return false;
     36    function update($new_instance, $old_instance)
     37    {
     38
     39        return false;
    3440    }
    3541
    36     function form( $instance ) {
    37                 global $wpdb, $awm_table_name;
     42    function form($instance)
     43    {
     44        global $wpdb, $awm_table_name;
    3845
    3946
    40                ?>
     47        ?>
    4148
    42        
    43                     <?php
    44                     if (isset($instance['div_name']))
    45                         $menuName = $wpdb->get_var( "SELECT name FROM $awm_table_name where id = " .(int) $instance['div_name']);
    46                     else
    47                         $menuName = '';
    4849
    49                     ?>
    50                     <?php if (!empty($menuName)):
    51                         ?>
    52                     <p>
    53                         <input type="hidden" id="awm-widget-title" value="<?php echo $menuName?>"/>
    54                     <span><?php _e('This is the widget for menu: '); ?><strong><?php echo $menuName;?></strong></span>
    55                                  
    56                 </p>
    57                 <?php else:?>
    58                  <p><strong style="color: red">Warning!!!</strong><br />It seems that you chose the AllWebMenus menu widget from the <em>'Available Widgets'</em> panel. Instead, you should drag and drop the related AllWebMenus menu widget from the <em>'Inactive Widgets'</em> panel. If you cannot find the widget that you want, go to <a href="<?php echo admin_url('options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php')?>">AllWebMenus settings</a>, select the tab of the menu that you want and choose the "Widget" value in the "Menu Positioning Method" property.</p>
    59                 <?php endif;?>
    60 <?php
     50        <?php
     51        if (isset($instance['div_name'])) {
     52            $menuName = $wpdb->get_var("SELECT name FROM $awm_table_name where id = " . (int)$instance['div_name']);
     53        } else {
     54            $menuName = '';
     55        }
     56
     57        ?>
     58        <?php if ( ! empty($menuName)):
     59        ?>
     60        <p>
     61            <input type="hidden" id="awm-widget-title" value="<?php echo $menuName ?>"/>
     62            <span><?php _e('This is the widget for menu: '); ?><strong><?php echo $menuName; ?></strong></span>
     63
     64        </p>
     65    <?php else: ?>
     66        <p><strong style="color: red">Warning!!!</strong><br/>It seems that you chose the AllWebMenus menu widget from the <em>'Available
     67                Widgets'</em> panel. Instead, you should drag and drop the related AllWebMenus menu widget from the <em>'Inactive
     68                Widgets'</em> panel. If you cannot find the widget that you want, go to <a
     69                href="<?php echo admin_url('options-general.php?page=allwebmenus-wordpress-menu-plugin/allwebmenus-wordpress-menu.php') ?>">AllWebMenus
     70                settings</a>, select the tab of the menu that you want and choose the "Widget" value in the "Menu Positioning Method"
     71            property.</p>
     72    <?php endif; ?>
     73        <?php
    6174    }
    6275}
     76
    6377?>
Note: See TracChangeset for help on using the changeset viewer.