/** * Creates the main admin page and saves the data if submitted * * @return null * @added 1.0 */ static function adminPage() { if (RM_Input::post('RMExport')) { RM_Export::export(); } if (RM_Input::post('RMSubmit') || RM_Input::post('RMImport') || RM_Input::post('RMReset')) { $data = RM_Input::post('RMImport') ? RM_Import::getData(RM_Input::file('RMImportFile')) : RM_Input::post(); /* Reset to defaults */ if (RM_Input::post('RMReset')) { $data = RM_Registry::get('defaults'); $data['RMArShpA'] = json_decode($data['RMArShpA']); $data['RMArShpI'] = json_decode($data['RMArShpI']); } RM_AdminModel::save($data); if (ResponsiveMenu::getOption('RMExternal')) { RM_FolderModel::create(); $js = RM_JSModel::getJs(ResponsiveMenu::getOptions()); $js = ResponsiveMenu::getOption('RMMinify') == 'minify' ? RM_JSModel::Minify($js) : ($js = $js); RM_JSModel::createJSFile($js); $css = RM_CSSModel::getCSS(ResponsiveMenu::getOptions()); $css = ResponsiveMenu::getOption('RMMinify') == 'minify' ? RM_JSModel::Minify($css) : ($css = $css); RM_CSSModel::createCSSFile($css); } } RM_View::make('admin.page', ResponsiveMenu::getOptions()); }
/** * Function to return individual options throughout the site, it * automatically returns the default option if a current value * doesn't exist in the current version * * @return array * @added 2.1 */ static function getOption($option) { $options = self::getOptions(); if (isset($options[$option])) { return $options[$option]; } return RM_Registry::get('defaults', $option); }
/** * Function to create the file to hold the CSS file * * @param string $css * @return file * @added 1.6 */ static function createCSSFile($css) { $file = fopen(RM_Registry::get('config', 'plugin_data_dir') . '/css/responsive-menu-' . get_current_blog_id() . '.css', 'w'); $cssFile = fwrite($file, $css); fclose($file); if (!$file) { RM_Status::set('error', __('Unable to create CSS file', 'responsive-menu')); } return $cssFile; }
/** * Function to create export XML file * * @return file xml * @added 2.2 */ static function export() { if (!is_admin()) { exit; } $fileName = RM_Registry::get('config', 'plugin_base_dir') . '/public/export/export.xml'; $file = fopen($fileName, 'w+'); if (!$file) { return RM_Status::set('error', __('Could not create export file, please check plugin folder permissions', 'responsive-menu')); } $xml = '<?xml version="1.0" encoding="UTF-8"?>'; $xml .= '<RMOptions>'; foreach (ResponsiveMenu::getOptions() as $option_key => $option_val) { $xml .= '<' . $option_key . '>' . $option_val . '</' . $option_key . '>'; } $xml .= '</RMOptions>'; fwrite($file, $xml); fclose($file); $link = RM_Registry::get('config', 'plugin_base_uri') . 'public/export/export.xml'; RM_Status::set('updated', '<a href="' . $link . '">' . __('You can download your exported file by clicking here', 'responsive-menu') . '</a>'); }
/** * Function to create the data folders * * @return null * @added 1.6 */ static function create() { $mainFolder = RM_Registry::get('config', 'plugin_data_dir'); $cssFolder = RM_Registry::get('config', 'plugin_data_dir') . '/css'; $jsFolder = RM_Registry::get('config', 'plugin_data_dir') . '/js'; if (!file_exists($mainFolder)) { mkdir($mainFolder, 0777); } if (!file_exists($cssFolder)) { mkdir($cssFolder, 0777); } if (!file_exists($jsFolder)) { mkdir($jsFolder, 0777); } if (!file_exists($mainFolder)) { RM_Status::set('error', __('Unable to create data folders', 'responsive-menu')); } if (!file_exists($cssFolder)) { RM_Status::set('error', __('Unable to create CSS folders', 'responsive-menu')); } if (!file_exists($cssFolder)) { RM_Status::set('error', __('Unable to create JS folders', 'responsive-menu')); } }
/** * Sets our initial default options when menu * is first installed * * @return null * @added 1.0 */ static function install() { add_option('RMVer', RM_Registry::get('config', 'current_version')); add_option('RMOptions', RM_Registry::get('defaults')); }
|-------------------------------------------------------------------------- | Save Config to the Registry |-------------------------------------------------------------------------- | | Again, some people don't like Registry's in PHP Applications, but here we | have one and it is very useful for retrieving our settings throughout the app | */ RM_Registry::set('config', $config); /* |-------------------------------------------------------------------------- | Responsive Menu Defaults |-------------------------------------------------------------------------- | | Another configuration array of type, this time we hold all the application | default options. | */ $defaults = array('RM' => '', 'RMBreak' => 800, 'RMDepth' => 2, 'RMTop' => 10, 'RMRight' => 5, 'RMCss' => '', 'RMTitle' => __('Menu Title', 'responsive-menu'), 'RMLineCol' => '#FFFFFF', 'RMClickBkg' => '#000000', 'RMClickTitle' => '', 'RMBkgTran' => false, 'RMFont' => '', 'RMPos' => '', 'RMImage' => '', 'RMWidth' => '75', 'RMBkg' => '#43494C', 'RMBkgHov' => '#3C3C3C', 'RMTitleCol' => '#FFFFFF', 'RMTextCol' => '#FFFFFF', 'RMBorCol' => '#3C3C3C', 'RMTextColHov' => '#FFFFFF', 'RMTitleColHov' => '#FFFFFF', 'RMAnim' => 'overlay', 'RMPushCSS' => '', 'RMTitleBkg' => '#43494C', 'RMFontSize' => 13, 'RMTitleSize' => 14, 'RMBtnSize' => 13, 'RMCurBkg' => '#43494C', 'RMCurCol' => '#FFFFFF', 'RMAnimSpd' => 0.5, 'RMTranSpd' => 1, 'RMTxtAlign' => 'left', 'RMSearch' => false, 'RMExpand' => false, 'RMLinkHeight' => 20, 'RMExternal' => false, 'RMSide' => 'left', 'RMFooter' => true, 'RMClickImg' => false, 'RMMinify' => true, 'RMClickClose' => false, 'RMRemImp' => false, 'RMX' => false, 'RMMinWidth' => null, 'RMMaxWidth' => null, 'RMExpandPar' => true, 'RMIgnParCli' => false, 'RMCliToClo' => false, 'RMSearchPos' => 'below', 'RMTitleLink' => null, 'RMTitleLoc' => '_self', 'RMHtml' => null, 'RMHtmlLoc' => 'bottom', 'RMShortcode' => false, 'RMLineHeight' => 5, 'RMLineWidth' => 33, 'RMLineMargin' => 6, 'RMClickImgClicked' => null, 'RMAccordion' => false, 'RMArShpA' => json_encode('▲'), 'RMArShpI' => json_encode('▼'), 'RMArImgA' => false, 'RMArImgI' => false, 'RMTrigger' => '#click-menu', 'RMPushBtn' => false, 'RMCurBkgHov' => '#43494C', 'RMCurColHov' => '#FFFFFF', 'RMWalker' => null, 'RMUseTran' => null, 'RMLoc' => 'right', 'RMThemeLocation' => null); /* |-------------------------------------------------------------------------- | Save Defaults to the Registry |-------------------------------------------------------------------------- | | Again, some people don't like Registry's in PHP Applications, but here we | have it again and it is very useful for retrieving our default values | throughout the app | */ RM_Registry::set('defaults', $defaults);
/** * Create a new view for display throughout the application * Users .phtml files found in the app/views folder * * @param string $page * @param mixed $data * @return null * @added 2.0 */ static function make($page, $data) { require RM_Registry::get('config', 'plugin_base_dir') . '/app/views/' . str_replace('.', '/', $page) . '.phtml'; }
/** * Function to format, create and get the JS itself * * @param array $options * @return string * @added 1.0 */ static function getJS($options) { $setHeight = $options['RMPos'] == 'fixed' ? '' : " \$RMjQuery( '#responsive-menu' ).css( 'height', \$RMjQuery( document ).height() ); "; $breakpoint = empty($options['RMBreak']) ? "600" : $options['RMBreak']; $RMPushCSS = empty($options['RMPushCSS']) ? "" : $options['RMPushCSS']; $slideOpen = $options['RMAnim'] == 'push' && !empty($options['RMPushCSS']) ? " \$RMjQuery( 'body' ).addClass( 'RMPushOpen' ); " : ''; $slideRemove = $options['RMAnim'] == 'push' && !empty($options['RMPushCSS']) ? " \$RMjQuery( 'body' ).removeClass( 'RMPushOpen' ); " : ''; /* Added 1.8 */ switch ($options['RMSide']) { case 'left': $side = 'left'; break; case 'right': $side = 'right'; break; case 'top': $side = 'top'; break; case 'bottom': $side = 'top'; break; default: $side = 'left'; break; } /* Added 2.0 */ switch ($options['RMSide']) { case 'left': $width = $options['RMWidth']; $neg = '-'; break; case 'right': $width = $options['RMWidth']; $neg = '-'; break; case 'top': $width = '100'; $neg = '-'; break; case 'bottom': $width = '100'; $neg = ''; break; default: $width = '75'; break; } switch ($options['RMSide']) { case 'left': $pushSide = 'left'; $pos = ''; break; case 'right': $pushSide = 'left'; $pos = '-'; break; case 'top': $pushSide = 'marginTop'; $pos = ''; break; case 'bottom': $pushSide = 'marginTop'; $pos = '-'; break; } $sideSlideOpen = $side == 'right' && empty($slideOpen) ? " \$RMjQuery( 'body' ).addClass( 'RMPushOpen' ); " : ''; $sideSlideRemove = $side == 'right' && empty($slideRemove) ? " \$RMjQuery( 'body' ).removeClass( 'RMPushOpen' ); " : ''; /* Added 2.3 */ $trigger = isset($options['RMTrigger']) ? $options['RMTrigger'] : RM_Registry::get('defaults', 'RMTrigger'); $speed = $options['RMAnimSpd'] * 1000; /* Added 2.5 */ $location = $options['RMLoc']; /* |-------------------------------------------------------------------------- | Slide Push Animation |-------------------------------------------------------------------------- | | This is where we deal with the JavaScript needed to change the main lines | to an X if this option has been set | */ $slideOver = null; if ($options['RMAnim'] == 'push') { if ($options['RMSide'] == 'top' || $options['RMSide'] == 'bottom') { $slideOver = "\r\n\r\n var MenuHeight = \$RMjQuery( '#responsive-menu' ).css( 'height' );\r\n\r\n \$RMjQuery( '{$RMPushCSS}' ).animate( { {$pushSide}: \"{$pos}\" + MenuHeight }, {$speed}, 'linear' );\r\n\r\n\r\n "; if ($options['RMPushBtn']) { $slideOver .= "\r\n\r\n \$RMjQuery( '#click-menu' ).animate( { {$pushSide}: \"{$pos}\" + MenuHeight }, {$speed}, 'linear' );\r\n \$RMjQuery( '#click-menu' ).css( '{$location}', 'auto' );\r\n\r\n "; } } else { $slideOver = "\r\n\r\n \$RMjQuery( '{$RMPushCSS}' ).animate( { {$pushSide}: \"{$pos}{$width}%\" }, {$speed}, 'linear' );\r\n\r\n\r\n "; if ($options['RMPushBtn']) { $slideOver .= "\r\n\r\n \$RMjQuery( '#click-menu' ).animate( { {$pushSide}: \"{$pos}{$width}%\" }, {$speed}, 'linear' );\r\n \$RMjQuery( '#click-menu' ).css( '{$location}', 'auto' );\r\n\r\n "; } } } $slideOverCss = $options['RMAnim'] == 'push' && !empty($options['RMPushCSS']) ? " \$RMjQuery( '{$RMPushCSS}' ).addClass( 'RMPushSlide' ); " : ''; $slideBack = $options['RMAnim'] == 'push' && !empty($options['RMPushCSS']) ? " \$RMjQuery( '{$RMPushCSS}' ).animate( { {$pushSide}: \"0\" }, {$speed}, 'linear' ); " : ''; if ($options['RMPushBtn'] && $options['RMAnim'] == 'push') { $slideBack .= "\r\n\r\n \$RMjQuery( '#click-menu' ).animate( { {$pushSide}: \"{$options['RMRight']}\" }, {$speed}, 'linear', function() {\r\n\r\n \$RMjQuery( '#click-menu' ).removeAttr( 'style' );\r\n\r\n });\r\n\r\n "; } $slideOverCssRemove = $options['RMAnim'] == 'push' && !empty($options['RMPushCSS']) ? " \$RMjQuery( '{$RMPushCSS}' ).removeClass( 'RMPushSlide' ); " : ''; /* |-------------------------------------------------------------------------- | Change to X or Clicked Menu Image Option |-------------------------------------------------------------------------- | | This is where we deal with the JavaScript needed to change the main lines | to an X or click image if this option has been set | */ if ($options['RMX'] || $options['RMClickImgClicked']) { $closeX = " \$RMjQuery( '#click-menu #RMX' ).css( 'display', 'none' );\r\n \$RMjQuery( '#click-menu #RM3Lines' ).css( 'display', 'block' ); "; $showX = " \$RMjQuery( '#click-menu #RM3Lines' ).css( 'display', 'none' );\r\n \$RMjQuery( '#click-menu #RMX' ).css( 'display', 'block' ); "; } else { $closeX = ""; $showX = ""; } /* |-------------------------------------------------------------------------- | Menu Expansion Options |-------------------------------------------------------------------------- | | This is where we deal with the array of expansion options, the current | combinations are: | | - Auto Expand Current Parent Items ['RMExpandPar'] | - Auto Expand Current Parent Items + Auto Expand Sub-Menus ['RMExpandPar'] && ['RMExpand'] | - Auto Expand Sub-Menus ['RMExpand'] | - None !['RMExpandPar'] && !['RMExpand'] | */ $activeArrow = $options['RMArImgA'] ? '<img src="' . $options['RMArImgA'] . '" />' : json_decode($options['RMArShpA']); $inactiveArrow = $options['RMArImgI'] ? '<img src="' . $options['RMArImgI'] . '" />' : json_decode($options['RMArShpI']); if (!$options['RMExpand']) { $clickedLink = '<span class=\\"appendLink rm-append-inactive\\">' . $inactiveArrow . '</span>'; $clickLink = '<span class=\\"appendLink rm-append-inactive\\">' . $inactiveArrow . '</span>'; } else { $clickedLink = '<span class=\\"appendLink rm-append-active\\">' . $activeArrow . '</span>'; $clickLink = '<span class=\\"appendLink rm-append-active\\">' . $activeArrow . '</span>'; } if ($options['RMExpandPar']) { $clickedLink = '<span class=\\"appendLink rm-append-active\\">' . $activeArrow . '</span>'; $clickLink = '<span class=\\"appendLink rm-append-inactive\\">' . $inactiveArrow . '</span>'; } if ($options['RMExpandPar'] && $options['RMExpand']) { $clickedLink = '<span class=\\"appendLink rm-append-active\\">' . $activeArrow . '</span>'; $clickLink = '<span class=\\"appendLink rm-append-active\\">' . $activeArrow . '</span>'; } /* |-------------------------------------------------------------------------- | Initialise Output |-------------------------------------------------------------------------- | | Initialise the JavaScript output variable ready for appending | */ $js = null; /* |-------------------------------------------------------------------------- | Strip Tags If Needed |-------------------------------------------------------------------------- | | Determine whether to use the <script> tags (when using internal scripts) | */ $js .= $options['RMExternal'] ? '' : '<script>'; /* |-------------------------------------------------------------------------- | Initial Setup |-------------------------------------------------------------------------- | | Setup the initial noConflict and document ready checks | */ $js .= "\r\n\r\n var \$RMjQuery = jQuery.noConflict();\r\n\r\n \$RMjQuery( document ).ready( function() {\r\n\r\n "; /* |-------------------------------------------------------------------------- | Stop Main Parent Item Clicks |-------------------------------------------------------------------------- | | Stop clicks on the main parent items if option selected | Added 2.0 */ if ($options['RMIgnParCli']) { $js .= "\r\n\r\n \$RMjQuery( '#responsive-menu ul > li.menu-item-has-children' ).children( 'a' ).addClass( 'rm-click-disabled' );\r\n\r\n \$RMjQuery( '#responsive-menu ul > li.menu-item-has-children' ).children( 'a' ).on( 'click', function( e ) {\r\n\r\n e.preventDefault();\r\n\r\n });\r\n\r\n \$RMjQuery( '#responsive-menu ul > li.page_item_has_children' ).children( 'a' ).addClass( 'rm-click-disabled' );\r\n\r\n \$RMjQuery( '#responsive-menu ul > li.page_item_has_children' ).children( 'a' ).on( 'click', function( e ) {\r\n\r\n e.preventDefault();\r\n\r\n });\r\n\r\n "; } /* |-------------------------------------------------------------------------- | Closes the menu on page clicks |-------------------------------------------------------------------------- | | Close menu on page clicks if required | Added 2.0 */ if ($options['RMCliToClo']) { $js .= "\r\n\r\n \$RMjQuery( document ).on( 'click tap', function( e ) { \r\n\r\n if( !\$RMjQuery( e.target ).closest( '#responsive-menu, {$trigger}' ).length ) { \r\n\r\n closeRM(); \r\n\r\n } \r\n\r\n });\r\n\r\n "; } /* |-------------------------------------------------------------------------- | Click Menu Function |-------------------------------------------------------------------------- | | This is our Click Handler to determine whether or not to open or close | the menu when the click menu button has been clicked. | */ $js .= "\r\n\r\n var isOpen = false;\r\n\r\n \$RMjQuery( document ).on( 'click', '{$trigger}', function() {\r\n\r\n {$setHeight}\r\n\r\n !isOpen ? openRM() : closeRM();\r\n\r\n });\r\n\r\n "; /* |-------------------------------------------------------------------------- | Menu Open Function |-------------------------------------------------------------------------- | | This is the main function that deals with opening the menu and then sets | its state to open | */ $js .= "\r\n\r\n function openRM() {\r\n\r\n {$slideOpen} \r\n {$sideSlideOpen}\r\n {$slideOverCss}\r\n {$slideOver}\r\n {$showX}\r\n\r\n \$RMjQuery( '#responsive-menu' ).css( 'display', 'block' ); \r\n \$RMjQuery( '#responsive-menu' ).addClass( 'RMOpened' ); \r\n \$RMjQuery( '#click-menu' ).addClass( 'click-menu-active' ); \r\n\r\n \$RMjQuery( '#responsive-menu' ).stop().animate( { {$side}: \"0\" }, {$speed}, 'linear', function() { \r\n\r\n {$setHeight}\r\n\r\n isOpen = true;\r\n\r\n } ); \r\n\r\n }\r\n\r\n "; /* |-------------------------------------------------------------------------- | Menu Close Function |-------------------------------------------------------------------------- | | This is the main function that deals with Closing the Menu and then sets | its state to closed | | Added by Bhupender | Modified negative width to take directly width of menu instead of '%', | this works for condition where animation is push and max width of menu is less then % | */ $js .= "\r\n\r\n function closeRM() {\r\n\r\n {$slideBack}\r\n\r\n \$RMjQuery( '#responsive-menu' ).animate( { {$side}: {$neg}\$RMjQuery( '#responsive-menu' ).width() }, {$speed}, 'linear', function() {\r\n\r\n {$slideRemove}\r\n {$sideSlideRemove}\r\n {$slideOverCssRemove}\r\n {$closeX}\r\n \$RMjQuery( '#responsive-menu' ).css( 'display', 'none' ); \r\n \$RMjQuery( '#responsive-menu' ).removeClass( 'RMOpened' ); \r\n \$RMjQuery( '#click-menu' ).removeClass( 'click-menu-active' ); \r\n\r\n isOpen = false;\r\n\r\n } );\r\n\r\n }\r\n\r\n "; /* |-------------------------------------------------------------------------- | Menu Resize Function |-------------------------------------------------------------------------- | | This is the main function that deals with resizing the page and is used | to judge whether the menu needs closing once the screen is resized | | | Added by Bhupender | - Modified negative width to take directly width of menu instead of '%', | this works for condition where animation is push and max width of menu is less then % */ $js .= "\r\n\r\n \$RMjQuery( window ).resize( function() { \r\n\r\n {$setHeight}\r\n\r\n if( \$RMjQuery( window ).width() > {$breakpoint} ) { \r\n\r\n if( \$RMjQuery( '#responsive-menu' ).css( '{$side}' ) != -\$RMjQuery( '#responsive-menu' ).width() ) {\r\n\r\n closeRM();\r\n\r\n }\r\n\r\n }\r\n\r\n });\r\n\r\n "; /* |-------------------------------------------------------------------------- | Expand children links of parents |-------------------------------------------------------------------------- | | Section to automatically expand children links of parents if necessary | Added 2.0 | */ if ($options['RMExpandPar']) { $js .= "\r\n\r\n \$RMjQuery( '#responsive-menu ul ul' ).css( 'display', 'none' );\r\n\r\n \$RMjQuery( '#responsive-menu .current_page_ancestor.menu-item-has-children' ).children( 'ul' ).css( 'display', 'block' );\r\n \$RMjQuery( '#responsive-menu .current-menu-ancestor.menu-item-has-children' ).children( 'ul' ).css( 'display', 'block' );\r\n \$RMjQuery( '#responsive-menu .current-menu-item.menu-item-has-children' ).children( 'ul' ).css( 'display', 'block' );\r\n\r\n \$RMjQuery( '#responsive-menu .current_page_ancestor.page_item_has_children' ).children( 'ul' ).css( 'display', 'block' );\r\n \$RMjQuery( '#responsive-menu .current-menu-ancestor.page_item_has_children' ).children( 'ul' ).css( 'display', 'block' );\r\n \$RMjQuery( '#responsive-menu .current-menu-item.page_item_has_children' ).children( 'ul' ).css( 'display', 'block' );\r\n\r\n "; } /* |-------------------------------------------------------------------------- | Add Toggle Buttons |-------------------------------------------------------------------------- | | This is the main section that deals with Adding the correct Toggle buttons | when needed to the links | */ if ($options['RMExpand']) { $js .= " \$RMjQuery( '#responsive-menu ul ul' ).css( 'display', 'block' ); "; } $js .= " \r\n\r\n var clickLink = '{$clickLink}';\r\n var clickedLink = '{$clickedLink}';\r\n\r\n \$RMjQuery( '#responsive-menu .responsive-menu li' ).each( function() {\r\n\r\n if( \$RMjQuery( this ).children( 'ul' ).length > 0 ) {\r\n\r\n if( \$RMjQuery( this ).find( '> ul' ).css( 'display' ) == 'none' ) {\r\n\r\n \$RMjQuery( this ).prepend( clickLink ); \r\n\r\n } else {\r\n\r\n \$RMjQuery( this ).prepend( clickedLink ); \r\n\r\n }\r\n\r\n }\r\n\r\n });\r\n\r\n "; /* |-------------------------------------------------------------------------- | Accordion Animation |-------------------------------------------------------------------------- | | This is the part that deals with the accordion animation | */ if ($options['RMAccordion'] && $options['RMAccordion'] == 'accordion') { $accordion = " \r\n\r\n if( \$RMjQuery( this ).closest( 'ul' ).is( '.responsive-menu' ) ) {\r\n\r\n \$RMjQuery( '.accordion-open' ).removeClass( 'accordion-open' );\r\n\r\n \$RMjQuery( this ).parent( 'li' ).addClass( 'accordion-open' );\r\n\r\n \$RMjQuery( '.responsive-menu li:not( .accordion-open ) > ul' ).slideUp();\r\n\r\n\r\n }\r\n\r\n "; } else { $accordion = null; } /* |-------------------------------------------------------------------------- | Toggle Buttons Function |-------------------------------------------------------------------------- | | This is the function that deals with toggling the toggle buttons | */ $js .= " \r\n\r\n \$RMjQuery( '.appendLink' ).on( 'click', function() { \r\n\r\n {$accordion}\r\n\r\n \$RMjQuery( this ).nextAll( '#responsive-menu ul ul' ).slideToggle(); \r\n\r\n \$RMjQuery( this ).html( \$RMjQuery( this ).hasClass( 'rm-append-active' ) ? '{$inactiveArrow}' : '{$activeArrow}' );\r\n \$RMjQuery( this ).toggleClass( 'rm-append-active rm-append-inactive' );\r\n\r\n {$setHeight}\r\n\r\n });\r\n\r\n \$RMjQuery( '.rm-click-disabled' ).on( 'click', function() { \r\n\r\n {$accordion}\r\n\r\n \$RMjQuery( this ).nextAll( '#responsive-menu ul ul' ).slideToggle(); \r\n\r\n \$RMjQuery( this ).siblings( '.appendLink' ).html( \$RMjQuery( this ).hasClass( 'rm-append-active' ) ? '{$inactiveArrow}' : '{$activeArrow}' );\r\n \$RMjQuery( this ).toggleClass( 'rm-append-active rm-append-inactive' );\r\n\r\n {$setHeight}\r\n\r\n }); \r\n\r\n "; /* |-------------------------------------------------------------------------- | Finally Hide Appropriate Hidden Objects |-------------------------------------------------------------------------- | | This is the function that deals with toggling the toggle buttons | */ $js .= " \r\n\r\n \$RMjQuery( '.rm-append-inactive' ).siblings( 'ul' ).css( 'display', 'none' );\r\n\r\n "; /* |-------------------------------------------------------------------------- | Menu Closing Options |-------------------------------------------------------------------------- | | This is where we set the menu to retract if a link is clicked | Added 1.9 | */ if (isset($options['RMClickClose']) && $options['RMClickClose'] == 'close') { $js .= " \r\n \$RMjQuery( '#responsive-menu ul li a' ).on( 'click', function() { \r\n\r\n closeRM();\r\n\r\n } );"; } /* |-------------------------------------------------------------------------- | Close Tags |-------------------------------------------------------------------------- | | This closes the initial document ready call | */ $js .= '}); '; /* |-------------------------------------------------------------------------- | Strip Tags If Needed |-------------------------------------------------------------------------- | | Determine whether to use the <script> tags (when using internal scripts) | */ $js .= $options['RMExternal'] ? '' : '</script>'; /* |-------------------------------------------------------------------------- | Return Finished Script |-------------------------------------------------------------------------- | | Finally we return the final script back | */ return $js; }
/** * Determines whether or not the site needs upgrading * * @return boolean * @added 2.0 */ static function needsUpgrade() { return version_compare(get_option('RMVer'), RM_Registry::get('config', 'current_version'), '<'); }
/** * Saves all the data from the admin page to the database * * @param array $data * @return null * @added 1.0 */ public static function save($data) { // Initialise Variables Correctly $RM = isset($data['RM']) ? $data['RM'] : RM_Registry::get('defaults', 'RM'); $RMTitle = isset($data['RMTitle']) ? $data['RMTitle'] : RM_Registry::get('defaults', 'RMTitle'); $RMBreak = $data['RMBreak'] ? $data['RMBreak'] : RM_Registry::get('defaults', 'RMBreak'); $RMDepth = isset($data['RMDepth']) ? $data['RMDepth'] : RM_Registry::get('defaults', 'RMDepth'); $RMTop = isset($data['RMTop']) ? $data['RMTop'] : RM_Registry::get('defaults', 'RMTop'); $RMRight = isset($data['RMRight']) ? $data['RMRight'] : RM_Registry::get('defaults', 'RMRight'); $RMCss = isset($data['RMCss']) ? $data['RMCss'] : RM_Registry::get('defaults', 'RMCss'); $RMLineCol = !empty($data['RMLineCol']) ? $data['RMLineCol'] : RM_Registry::get('defaults', 'RMLineCol'); $RMClickBkg = !empty($data['RMClickBkg']) ? $data['RMClickBkg'] : RM_Registry::get('defaults', 'RMClickBkg'); $RMClickTitle = isset($data['RMClickTitle']) ? $data['RMClickTitle'] : RM_Registry::get('defaults', 'RMClickTitle'); $RMBkgTran = isset($data['RMBkgTran']) ? $data['RMBkgTran'] : false; $RMPos = isset($data['RMPos']) ? $data['RMPos'] : RM_Registry::get('defaults', 'RMPos'); $RMImage = isset($data['RMImage']) ? $data['RMImage'] : RM_Registry::get('defaults', 'RMImage'); $RMWidth = $data['RMWidth'] ? $data['RMWidth'] : RM_Registry::get('defaults', 'RMWidth'); $RMBkg = !empty($data['RMBkg']) ? $data['RMBkg'] : RM_Registry::get('defaults', 'RMBkg'); $RMBkgHov = !empty($data['RMBkgHov']) ? $data['RMBkgHov'] : RM_Registry::get('defaults', 'RMBkgHov'); $RMTitleCol = !empty($data['RMTitleCol']) ? $data['RMTitleCol'] : RM_Registry::get('defaults', 'RMTitleCol'); $RMTextCol = !empty($data['RMTextCol']) ? $data['RMTextCol'] : RM_Registry::get('defaults', 'RMTextCol'); $RMBorCol = !empty($data['RMBorCol']) ? $data['RMBorCol'] : RM_Registry::get('defaults', 'RMBorCol'); $RMTextColHov = !empty($data['RMTextColHov']) ? $data['RMTextColHov'] : RM_Registry::get('defaults', 'RMTextColHov'); $RMTitleColHov = !empty($data['RMTitleColHov']) ? $data['RMTitleColHov'] : RM_Registry::get('defaults', 'RMTitleColHov'); /* Added in 1.6 */ $RMAnim = isset($data['RMAnim']) ? $data['RMAnim'] : RM_Registry::get('defaults', 'RMAnim'); $RMPushCSS = isset($data['RMPushCSS']) ? $data['RMPushCSS'] : RM_Registry::get('defaults', 'RMPushCSS'); $RMTitleBkg = !empty($data['RMTitleBkg']) ? $data['RMTitleBkg'] : RM_Registry::get('defaults', 'RMTitleBkg'); $RMFont = isset($data['RMFont']) ? $data['RMFont'] : RM_Registry::get('defaults', 'RMFont'); $RMFontSize = $data['RMFontSize'] ? $data['RMFontSize'] : RM_Registry::get('defaults', 'RMFontSize'); $RMTitleSize = $data['RMTitleSize'] ? $data['RMTitleSize'] : RM_Registry::get('defaults', 'RMTitleSize'); $RMBtnSize = $data['RMBtnSize'] ? $data['RMBtnSize'] : RM_Registry::get('defaults', 'RMBtnSize'); $RMCurBkg = !empty($data['RMCurBkg']) ? $data['RMCurBkg'] : RM_Registry::get('defaults', 'RMCurBkg'); $RMCurCol = !empty($data['RMCurCol']) ? $data['RMCurCol'] : RM_Registry::get('defaults', 'RMCurCol'); $RMAnimSpd = $data['RMAnimSpd'] !== false ? $data['RMAnimSpd'] : RM_Registry::get('defaults', 'RMAnimSpd'); /* Added in 1.7 */ $RMTranSpd = $data['RMTranSpd'] ? $data['RMTranSpd'] : RM_Registry::get('defaults', 'RMTranSpd'); $RMTxtAlign = isset($data['RMTxtAlign']) ? $data['RMTxtAlign'] : RM_Registry::get('defaults', 'RMTxtAlign'); $RMSearch = isset($data['RMSearch']) ? $data['RMSearch'] : RM_Registry::get('defaults', 'RMSearch'); $RMExpand = isset($data['RMExpand']) ? $data['RMExpand'] : RM_Registry::get('defaults', 'RMExpand'); $RMLinkHeight = $data['RMLinkHeight'] ? $data['RMLinkHeight'] : RM_Registry::get('defaults', 'RMLinkHeight'); /* Added in 1.8 */ $RMExternal = isset($data['RMExternal']) ? $data['RMExternal'] : RM_Registry::get('defaults', 'RMExternal'); $RMSide = isset($data['RMSide']) ? $data['RMSide'] : RM_Registry::get('defaults', 'RMSide'); /* Added in 1.9 */ $RMFooter = isset($data['RMFooter']) ? $data['RMFooter'] : RM_Registry::get('defaults', 'RMFooter'); $RMClickImg = isset($data['RMClickImg']) ? $data['RMClickImg'] : RM_Registry::get('defaults', 'RMClickImg'); $RMMinify = isset($data['RMMinify']) ? $data['RMMinify'] : RM_Registry::get('defaults', 'RMMinify'); $RMClickClose = isset($data['RMClickClose']) ? $data['RMClickClose'] : RM_Registry::get('defaults', 'RMClickClose'); $RMRemImp = isset($data['RMRemImp']) ? $data['RMRemImp'] : RM_Registry::get('defaults', 'RMRemImp'); $RMX = isset($data['RMX']) ? $data['RMX'] : RM_Registry::get('defaults', 'RMX'); $RMMinWidth = isset($data['RMMinWidth']) ? $data['RMMinWidth'] : RM_Registry::get('defaults', 'RMMinWidth'); /* Added in 2.0 */ $RMMaxWidth = isset($data['RMMaxWidth']) ? $data['RMMaxWidth'] : RM_Registry::get('defaults', 'RMMaxWidth'); $RMExpandPar = isset($data['RMExpandPar']) ? $data['RMExpandPar'] : false; $RMIgnParCli = isset($data['RMIgnParCli']) ? $data['RMIgnParCli'] : RM_Registry::get('defaults', 'RMIgnParCli'); $RMCliToClo = isset($data['RMCliToClo']) ? $data['RMCliToClo'] : RM_Registry::get('defaults', 'RMCliToClo'); $RMSearchPos = isset($data['RMSearchPos']) ? $data['RMSearchPos'] : RM_Registry::get('defaults', 'RMSearchPos'); $RMTitleLink = isset($data['RMTitleLink']) ? $data['RMTitleLink'] : RM_Registry::get('defaults', 'RMTitleLink'); $RMTitleLoc = isset($data['RMTitleLoc']) ? $data['RMTitleLoc'] : RM_Registry::get('defaults', 'RMTitleLoc'); $RMHtml = isset($data['RMHtml']) ? $data['RMHtml'] : RM_Registry::get('defaults', 'RMHtml'); $RMHtmlLoc = isset($data['RMHtmlLoc']) ? $data['RMHtmlLoc'] : RM_Registry::get('defaults', 'RMHtmlLoc'); /* Added in 2.1 */ $RMShortcode = isset($data['RMShortcode']) ? $data['RMShortcode'] : RM_Registry::get('defaults', 'RMShortcode'); /* Added in 2.2 */ $RMLineHeight = isset($data['RMLineHeight']) ? $data['RMLineHeight'] : RM_Registry::get('defaults', 'RMLineHeight'); $RMLineWidth = isset($data['RMLineWidth']) ? $data['RMLineWidth'] : RM_Registry::get('defaults', 'RMLineWidth'); $RMLineMargin = isset($data['RMLineMargin']) ? $data['RMLineMargin'] : RM_Registry::get('defaults', 'RMLineMargin'); $RMClickImgClicked = isset($data['RMClickImgClicked']) ? $data['RMClickImgClicked'] : RM_Registry::get('defaults', 'RMClickImgClicked'); $RMAccordion = isset($data['RMAccordion']) ? $data['RMAccordion'] : RM_Registry::get('defaults', 'RMAccordion'); $RMArShpA = isset($data['RMArShpA']) ? $data['RMArShpA'] : RM_Registry::get('defaults', 'RMArShpA'); $RMArShpI = isset($data['RMArShpI']) ? $data['RMArShpI'] : RM_Registry::get('defaults', 'RMArShpI'); $RMArImgA = isset($data['RMArImgA']) ? $data['RMArImgA'] : RM_Registry::get('defaults', 'RMArImgA'); $RMArImgI = isset($data['RMArImgI']) ? $data['RMArImgI'] : RM_Registry::get('defaults', 'RMArImgI'); /* Added in 2.3 */ $RMTrigger = isset($data['RMTrigger']) && !empty($data['RMTrigger']) ? $data['RMTrigger'] : RM_Registry::get('defaults', 'RMTrigger'); $RMPushBtn = isset($data['RMPushBtn']) ? $data['RMPushBtn'] : RM_Registry::get('defaults', 'RMPushBtn'); $RMCurBkgHov = !empty($data['RMCurBkgHov']) ? $data['RMCurBkgHov'] : RM_Registry::get('defaults', 'RMCurBkgHov'); $RMCurColHov = !empty($data['RMCurColHov']) ? $data['RMCurColHov'] : RM_Registry::get('defaults', 'RMCurColHov'); /* Add by MKDGS */ $RMWalker = isset($data['RMWalker']) ? $data['RMWalker'] : RM_Registry::get('defaults', 'RMWalker'); /* Added in 2.4 */ $RMUseTran = isset($data['RMUseTran']) ? $data['RMUseTran'] : RM_Registry::get('defaults', 'RMUseTran'); $RMLoc = isset($data['RMLoc']) ? $data['RMLoc'] : RM_Registry::get('defaults', 'RMLoc'); /* Added in 2.6 Mkdgs */ $RMThemeLocation = isset($data['RMThemeLocation']) ? $data['RMThemeLocation'] : RM_Registry::get('defaults', 'RMThemeLocation'); $optionsArray = array('RM' => self::Filter($RM), 'RMBreak' => intval($RMBreak), 'RMDepth' => intval($RMDepth), 'RMTop' => intval($RMTop), 'RMRight' => intval($RMRight), 'RMCss' => self::Filter($RMCss), 'RMTitle' => self::Filter($RMTitle), 'RMLineCol' => self::Filter($RMLineCol), 'RMClickBkg' => self::Filter($RMClickBkg), 'RMClickTitle' => self::Filter($RMClickTitle), 'RMBkgTran' => self::Filter($RMBkgTran), 'RMFont' => self::Filter($RMFont), 'RMPos' => self::Filter($RMPos), 'RMImage' => self::Filter($RMImage), 'RMWidth' => intval($RMWidth), 'RMBkg' => self::Filter($RMBkg), 'RMBkgHov' => self::Filter($RMBkgHov), 'RMTitleCol' => self::Filter($RMTitleCol), 'RMTextCol' => self::Filter($RMTextCol), 'RMBorCol' => self::Filter($RMBorCol), 'RMTextColHov' => self::Filter($RMTextColHov), 'RMTitleColHov' => self::Filter($RMTitleColHov), 'RMAnim' => self::Filter($RMAnim), 'RMPushCSS' => self::Filter($RMPushCSS), 'RMTitleBkg' => self::Filter($RMTitleBkg), 'RMFontSize' => intval($RMFontSize), 'RMTitleSize' => intval($RMTitleSize), 'RMBtnSize' => intval($RMBtnSize), 'RMCurBkg' => self::Filter($RMCurBkg), 'RMCurCol' => self::Filter($RMCurCol), 'RMAnimSpd' => floatval($RMAnimSpd), 'RMTranSpd' => floatval($RMTranSpd), 'RMTxtAlign' => self::Filter($RMTxtAlign), 'RMSearch' => self::Filter($RMSearch), 'RMExpand' => self::Filter($RMExpand), 'RMLinkHeight' => intval($RMLinkHeight), 'RMExternal' => self::Filter($RMExternal), 'RMSide' => self::Filter($RMSide), 'RMFooter' => self::Filter($RMFooter), 'RMClickImg' => self::Filter($RMClickImg), 'RMMinify' => self::Filter($RMMinify), 'RMClickClose' => self::Filter($RMClickClose), 'RMRemImp' => self::Filter($RMRemImp), 'RMX' => self::Filter($RMX), 'RMMinWidth' => intval($RMMinWidth), 'RMMaxWidth' => intval($RMMaxWidth), 'RMExpandPar' => self::Filter($RMExpandPar), 'RMIgnParCli' => self::Filter($RMIgnParCli), 'RMCliToClo' => self::Filter($RMCliToClo), 'RMSearchPos' => self::Filter($RMSearchPos), 'RMTitleLink' => self::Filter($RMTitleLink), 'RMTitleLoc' => self::Filter($RMTitleLoc), 'RMHtml' => self::FilterHtml($RMHtml), 'RMHtmlLoc' => self::Filter($RMHtmlLoc), 'RMShortcode' => self::Filter($RMShortcode), 'RMLineHeight' => intval($RMLineHeight), 'RMLineWidth' => intval($RMLineWidth), 'RMLineMargin' => intval($RMLineMargin), 'RMClickImgClicked' => self::Filter($RMClickImgClicked), 'RMAccordion' => self::Filter($RMAccordion), 'RMArShpA' => json_encode($RMArShpA), 'RMArShpI' => json_encode($RMArShpI), 'RMArImgA' => self::Filter($RMArImgA), 'RMArImgI' => self::Filter($RMArImgI), 'RMTrigger' => self::Filter($RMTrigger), 'RMPushBtn' => self::Filter($RMPushBtn), 'RMCurBkgHov' => self::Filter($RMCurBkgHov), 'RMCurColHov' => self::Filter($RMCurColHov), 'RMWalker' => class_exists($RMWalker) ? $RMWalker : '', 'RMUseTran' => self::Filter($RMUseTran), 'RMLoc' => self::Filter($RMLoc), 'RMThemeLocation' => self::Filter($RMThemeLocation)); // Update Submitted Options update_option('RMOptions', $optionsArray); // Clear Transient Menus RM_Transient::clearTransientMenus(); // And save the status RM_Status::set('updated', __('You have successfully updated the Responsive Menu options', 'responsive-menu')); }
/** * Makes sure jQuery Mobile is added to all front pages if the specific option is selected * as it is needed for some of the functions to work * * @return null * @added 2.0 */ static function jQueryMobile() { wp_register_script('touch', RM_Registry::get('config', 'plugin_base_uri') . 'public/js/touch.js', 'jquery', '', false); wp_enqueue_script('touch'); }
/** * Create our admin menus. * * @return null * @added 1.0 */ static function addMenus() { add_menu_page(__('Responsive Menu', 'responsive-menu'), __('Responsive Menu', 'responsive-menu'), 'manage_options', 'responsive-menu', array('RM_AdminController', 'adminPage'), RM_Registry::get('config', 'plugins_base_uri') . 'public/imgs/icon.png'); }
/** * Adds the external scripts to the site if required * * @return null * @added 1.4 */ static function addExternal() { wp_enqueue_script('responsive-menu', RM_Registry::get('config', 'plugin_data_uri') . 'js/responsive-menu-' . get_current_blog_id() . '.js', 'jquery.mobile', '1.0', self::inFooter()); }
/** * Determines whether or not the site needs upgrading * * @return boolean * @added 2.0 */ static function needsUpgrade() { return get_option('RMVer') != RM_Registry::get('config', 'current_version') ? true : false; }
/** * Adds External Styles to Header * * @return null * @added 2.0 */ static function addExternal() { wp_enqueue_style('responsive-menu', RM_Registry::get('config', 'plugin_data_uri') . 'css/responsive-menu-' . get_current_blog_id() . '.css', array(), '1.0', 'all'); }