settings.class.php 193 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. exit; // disable direct access
  4. }
  5. if ( ! class_exists( 'Mega_Menu_Settings' ) ) :
  6. /**
  7. * Handles all admin related functionality.
  8. */
  9. class Mega_Menu_Settings {
  10. /**
  11. * All themes (default and custom)
  12. */
  13. var $themes = array();
  14. /**
  15. * Active theme
  16. */
  17. var $active_theme = array();
  18. /**
  19. * Active theme ID
  20. */
  21. var $id = "";
  22. /**
  23. * Constructor
  24. *
  25. * @since 1.0
  26. */
  27. public function __construct() {
  28. add_action( 'wp_ajax_megamenu_save_theme', array( $this, 'ajax_save_theme' ) );
  29. add_action( 'admin_post_megamenu_save_theme', array( $this, 'save_theme') );
  30. add_action( 'admin_post_megamenu_add_theme', array( $this, 'create_theme') );
  31. add_action( 'admin_post_megamenu_delete_theme', array( $this, 'delete_theme') );
  32. add_action( 'admin_post_megamenu_revert_theme', array( $this, 'revert_theme') );
  33. add_action( 'admin_post_megamenu_import_theme', array( $this, 'import_theme') );
  34. add_action( 'admin_post_megamenu_duplicate_theme', array( $this, 'duplicate_theme') );
  35. add_action( 'admin_post_megamenu_add_menu_location', array( $this, 'add_menu_location') );
  36. add_action( 'admin_post_megamenu_delete_menu_location', array( $this, 'delete_menu_location') );
  37. add_action( 'admin_post_megamenu_save_settings', array( $this, 'save_settings') );
  38. add_action( 'admin_post_megamenu_clear_css_cache', array( $this, 'tools_clear_css_cache') );
  39. add_action( 'admin_post_megamenu_delete_data', array( $this, 'delete_data') );
  40. add_action( 'megamenu_page_theme_editor', array( $this, 'theme_editor_page'));
  41. add_action( 'megamenu_page_tools', array( $this, 'tools_page'));
  42. add_action( 'megamenu_page_general_settings', array( $this, 'general_settings_page'));
  43. add_action( 'megamenu_page_menu_locations', array( $this, 'menu_locations_page'));
  44. add_action( 'admin_menu', array( $this, 'megamenu_themes_page') );
  45. add_action( 'megamenu_admin_scripts', array( $this, 'enqueue_scripts' ) );
  46. }
  47. /**
  48. *
  49. * @since 1.4
  50. */
  51. public function init() {
  52. if ( class_exists( "Mega_Menu_Style_Manager" ) ) {
  53. $style_manager = new Mega_Menu_Style_Manager();
  54. $this->themes = $style_manager->get_themes();
  55. $last_updated = max_mega_menu_get_last_updated_theme();
  56. $preselected_theme = isset( $this->themes[ $last_updated ] ) ? $last_updated : 'default';
  57. $theme_id = isset( $_GET['theme'] ) ? sanitize_text_field( $_GET['theme'] ) : $preselected_theme;
  58. if ( isset( $this->themes[ $theme_id ] ) ) {
  59. $this->id = $theme_id;
  60. } else {
  61. $this->id = $preselected_theme;
  62. }
  63. $this->active_theme = $this->themes[$this->id];
  64. }
  65. }
  66. /**
  67. *
  68. * @since 2.4.1
  69. */
  70. public function ajax_save_theme() {
  71. check_ajax_referer( 'megamenu_save_theme' );
  72. $style_manager = new Mega_Menu_Style_Manager();
  73. $test = $style_manager->test_theme_compilation( $this->get_prepared_theme_for_saving() );
  74. if ( is_wp_error( $test ) ) {
  75. wp_send_json_error( $test->get_error_message() );
  76. } else {
  77. $this->save_theme(true);
  78. wp_send_json_success( "Saved" );
  79. }
  80. wp_die();
  81. }
  82. /**
  83. *
  84. * @since 2.4.1
  85. */
  86. public function get_prepared_theme_for_saving() {
  87. $submitted_settings = $_POST['settings'];
  88. if ( isset( $_POST['checkboxes'] ) ) {
  89. foreach ( $_POST['checkboxes'] as $checkbox => $value ) {
  90. if ( isset( $submitted_settings[ $checkbox ] ) ) {
  91. $submitted_settings[ $checkbox ] = 'on';
  92. } else {
  93. $submitted_settings[ $checkbox ] = 'off';
  94. }
  95. }
  96. }
  97. if ( is_numeric( $submitted_settings['responsive_breakpoint'] ) ) {
  98. $submitted_settings['responsive_breakpoint'] = $submitted_settings['responsive_breakpoint'] . "px";
  99. }
  100. if ( isset( $submitted_settings['toggle_blocks'] ) ) {
  101. unset( $submitted_settings['toggle_blocks'] );
  102. }
  103. $theme = array_map( 'esc_attr', $submitted_settings );
  104. return $theme;
  105. }
  106. /**
  107. * Save changes to an exiting theme.
  108. *
  109. * @since 1.0
  110. */
  111. public function save_theme($is_ajax = false) {
  112. check_admin_referer( 'megamenu_save_theme' );
  113. $theme = esc_attr( $_POST['theme_id'] );
  114. $saved_themes = max_mega_menu_get_themes();
  115. if ( isset( $saved_themes[ $theme ] ) ) {
  116. unset( $saved_themes[ $theme ] );
  117. }
  118. $prepared_theme = $this->get_prepared_theme_for_saving();
  119. $saved_themes[ $theme ] = $prepared_theme;
  120. max_mega_menu_save_themes( $saved_themes );
  121. max_mega_menu_save_last_updated_theme( $theme );
  122. do_action("megamenu_after_theme_save");
  123. do_action("megamenu_delete_cache");
  124. if ( ! $is_ajax ) {
  125. $this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme={$theme}&saved=true" ) );
  126. return;
  127. }
  128. return $prepared_theme;
  129. }
  130. /**
  131. * Add a new menu location.
  132. *
  133. * @since 1.8
  134. */
  135. public function add_menu_location() {
  136. check_admin_referer( 'megamenu_add_menu_location' );
  137. $locations = get_option( 'megamenu_locations' );
  138. $next_id = $this->get_next_menu_location_id();
  139. $new_menu_location_id = "max_mega_menu_" . $next_id;
  140. $locations[$new_menu_location_id] = "Max Mega Menu Location " . $next_id;
  141. update_option( 'megamenu_locations', $locations );
  142. do_action("megamenu_after_add_menu_location");
  143. $this->redirect( admin_url( 'admin.php?page=maxmegamenu_menu_locations&add_location=true' ) );
  144. }
  145. /**
  146. * Delete a menu location.
  147. *
  148. * @since 1.8
  149. */
  150. public function delete_menu_location() {
  151. check_admin_referer( 'megamenu_delete_menu_location' );
  152. $locations = get_option( 'megamenu_locations' );
  153. $location_to_delete = esc_attr( $_GET['location'] );
  154. if ( isset( $locations[ $location_to_delete ] ) ) {
  155. unset( $locations[ $location_to_delete ] );
  156. update_option( 'megamenu_locations', $locations );
  157. }
  158. do_action("megamenu_after_delete_menu_location");
  159. do_action("megamenu_delete_cache");
  160. $this->redirect( admin_url( 'admin.php?page=maxmegamenu_menu_locations&delete_location=true' ) );
  161. }
  162. /**
  163. * Clear the CSS cache.
  164. *
  165. * @since 1.5
  166. */
  167. public function tools_clear_css_cache() {
  168. check_admin_referer( 'megamenu_clear_css_cache' );
  169. do_action( 'megamenu_delete_cache' );
  170. $this->redirect( admin_url( 'admin.php?page=maxmegamenu_tools&clear_css_cache=true' ) );
  171. }
  172. /**
  173. * Deletes all Max Mega Menu data from the database
  174. *
  175. * @since 1.5
  176. */
  177. public function delete_data() {
  178. check_admin_referer( 'megamenu_delete_data' );
  179. do_action("megamenu_delete_cache");
  180. // delete options
  181. delete_option("megamenu_settings");
  182. delete_option("megamenu_locations");
  183. delete_option("megamenu_toggle_blocks");
  184. delete_option("megamenu_version");
  185. delete_option("megamenu_initial_version");
  186. delete_option("megamenu_themes_last_updated");
  187. delete_option("megamenu_multisite_share_themes");
  188. // delete all widgets assigned to menus
  189. $widget_manager = new Mega_Menu_Widget_Manager();
  190. if ( $mega_menu_widgets = $widget_manager->get_mega_menu_sidebar_widgets() ) {
  191. foreach ( $mega_menu_widgets as $widget_id ) {
  192. $widget_manager->delete_widget( $widget_id );
  193. }
  194. }
  195. // delete all mega menu metadata stored against menu items
  196. delete_metadata( 'post', 0, '_megamenu', '', true );
  197. // clear cache
  198. delete_transient( "megamenu_css" );
  199. // delete custom themes
  200. max_mega_menu_delete_themes();
  201. $this->redirect( admin_url( "admin.php?page=maxmegamenu_tools&delete_data=true" ) );
  202. }
  203. /**
  204. * Save menu general settings.
  205. *
  206. * @since 1.0
  207. */
  208. public function save_settings() {
  209. check_admin_referer( 'megamenu_save_settings' );
  210. if ( isset( $_POST['settings'] ) && is_array( $_POST['settings'] ) ) {
  211. $submitted_settings = apply_filters( "megamenu_submitted_settings", $_POST['settings'] );
  212. $existing_settings = get_option( 'megamenu_settings' );
  213. $new_settings = array_merge( (array)$existing_settings, $submitted_settings );
  214. update_option( 'megamenu_settings', $new_settings );
  215. }
  216. // update location description
  217. if ( isset( $_POST['location'] ) && is_array( $_POST['location'] ) ) {
  218. $locations = get_option('megamenu_locations');
  219. $new_locations = array_merge( (array)$locations, $_POST['location'] );
  220. update_option( 'megamenu_locations', $new_locations );
  221. }
  222. delete_transient('megamenu_failed_to_write_css_to_filesystem');
  223. do_action("megamenu_after_save_general_settings");
  224. do_action("megamenu_delete_cache");
  225. $url = isset( $_POST['_wp_http_referer'] ) ? $_POST['_wp_http_referer'] : admin_url( "admin.php?page=maxmegamenu&saved=true" );
  226. $this->redirect( $url );
  227. }
  228. /**
  229. * Duplicate an existing theme.
  230. *
  231. * @since 1.8
  232. */
  233. public function import_theme() {
  234. check_admin_referer( 'megamenu_import_theme' );
  235. $this->init();
  236. $import = json_decode( stripslashes( $_POST['data'] ), true );
  237. if ( is_array( $import ) ) {
  238. $saved_themes = max_mega_menu_get_themes();
  239. $next_id = $this->get_next_theme_id();
  240. $import['title'] = $import['title'] . " " . __(' - Imported', 'megamenu');
  241. $new_theme_id = "custom_theme_" . $next_id;
  242. $saved_themes[ $new_theme_id ] = $import;
  243. max_mega_menu_save_themes( $saved_themes );
  244. do_action("megamenu_after_theme_import");
  245. $this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme=" . $new_theme_id . "&created=true" ) );
  246. } else {
  247. $this->redirect( admin_url( "admin.php?page=maxmegamenu_tools&theme_imported=false") );
  248. }
  249. }
  250. /**
  251. * Duplicate an existing theme.
  252. *
  253. * @since 1.0
  254. */
  255. public function duplicate_theme() {
  256. check_admin_referer( 'megamenu_duplicate_theme' );
  257. $this->init();
  258. $theme = esc_attr( $_GET['theme_id'] );
  259. $copy = $this->themes[$theme];
  260. $saved_themes = max_mega_menu_get_themes();
  261. $next_id = $this->get_next_theme_id();
  262. $copy['title'] = $copy['title'] . " " . __('Copy', 'megamenu');
  263. $new_theme_id = "custom_theme_" . $next_id;
  264. $saved_themes[ $new_theme_id ] = $copy;
  265. max_mega_menu_save_themes( $saved_themes );
  266. do_action("megamenu_after_theme_duplicate");
  267. $this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme={$new_theme_id}&duplicated=true") );
  268. }
  269. /**
  270. * Delete a theme
  271. *
  272. * @since 1.0
  273. */
  274. public function delete_theme() {
  275. check_admin_referer( 'megamenu_delete_theme' );
  276. $theme = esc_attr( $_GET['theme_id'] );
  277. if ( $this->theme_is_being_used_by_location( $theme ) ) {
  278. $this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme={$theme}&deleted=false") );
  279. return;
  280. }
  281. $saved_themes = max_mega_menu_get_themes();
  282. if ( isset( $saved_themes[$theme] ) ) {
  283. unset( $saved_themes[$theme] );
  284. }
  285. max_mega_menu_save_themes( $saved_themes );
  286. do_action("megamenu_after_theme_delete");
  287. do_action("megamenu_delete_cache");
  288. $this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme=default&deleted=true") );
  289. }
  290. /**
  291. * Revert a theme (only available for default themes, you can't revert a custom theme)
  292. *
  293. * @since 1.0
  294. */
  295. public function revert_theme() {
  296. check_admin_referer( 'megamenu_revert_theme' );
  297. $theme = esc_attr( $_GET['theme_id'] );
  298. $saved_themes = max_mega_menu_get_themes();
  299. if ( isset( $saved_themes[$theme] ) ) {
  300. unset( $saved_themes[$theme] );
  301. }
  302. max_mega_menu_save_themes( $saved_themes );
  303. do_action("megamenu_after_theme_revert");
  304. do_action("megamenu_delete_cache");
  305. $this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme={$theme}&reverted=true") );
  306. }
  307. /**
  308. * Create a new custom theme
  309. *
  310. * @since 1.0
  311. */
  312. public function create_theme() {
  313. check_admin_referer( 'megamenu_create_theme' );
  314. $this->init();
  315. $saved_themes = max_mega_menu_get_themes();
  316. $next_id = $this->get_next_theme_id();
  317. $new_theme_id = "custom_theme_" . $next_id;
  318. $style_manager = new Mega_Menu_Style_Manager();
  319. $new_theme = $style_manager->get_default_theme();
  320. $new_theme['title'] = "Custom {$next_id}";
  321. $saved_themes[$new_theme_id] = $new_theme;
  322. max_mega_menu_save_themes( $saved_themes );
  323. do_action("megamenu_after_theme_create");
  324. $this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme={$new_theme_id}&created=true") );
  325. }
  326. /**
  327. * Redirect and exit
  328. *
  329. * @since 1.8
  330. */
  331. public function redirect( $url ) {
  332. wp_redirect( $url );
  333. exit;
  334. }
  335. /**
  336. * Returns the next available menu location ID
  337. *
  338. * @since 1.0
  339. */
  340. public function get_next_menu_location_id() {
  341. $last_id = 0;
  342. if ( $locations = get_option( "megamenu_locations" ) ) {
  343. foreach ( $locations as $key => $value ) {
  344. if ( strpos( $key, 'max_mega_menu_' ) !== FALSE ) {
  345. $parts = explode( "_", $key );
  346. $menu_id = end( $parts );
  347. if ($menu_id > $last_id) {
  348. $last_id = $menu_id;
  349. }
  350. }
  351. }
  352. }
  353. $next_id = $last_id + 1;
  354. return $next_id;
  355. }
  356. /**
  357. * Returns the next available custom theme ID
  358. *
  359. * @since 1.0
  360. */
  361. public function get_next_theme_id() {
  362. $last_id = 0;
  363. if ( $saved_themes = max_mega_menu_get_themes() ) {
  364. foreach ( $saved_themes as $key => $value ) {
  365. if ( strpos( $key, 'custom_theme' ) !== FALSE ) {
  366. $parts = explode( "_", $key );
  367. $theme_id = end( $parts );
  368. if ($theme_id > $last_id) {
  369. $last_id = $theme_id;
  370. }
  371. }
  372. }
  373. }
  374. $next_id = $last_id + 1;
  375. return $next_id;
  376. }
  377. /**
  378. * Checks to see if a certain theme is in use.
  379. *
  380. * @since 1.0
  381. * @param string $theme
  382. */
  383. public function theme_is_being_used_by_location( $theme ) {
  384. $settings = get_option( "megamenu_settings" );
  385. if ( ! $settings ) {
  386. return false;
  387. }
  388. $locations = get_nav_menu_locations();
  389. $menus = get_registered_nav_menus();
  390. $theme_in_use_locations = array();
  391. if ( count( $locations ) ) {
  392. foreach ( $locations as $location => $menu_id ) {
  393. if ( has_nav_menu( $location ) && max_mega_menu_is_enabled( $location ) && isset( $settings[ $location ]['theme'] ) && $settings[ $location ]['theme'] == $theme ) {
  394. $theme_in_use_locations[] = isset( $menus[ $location ] ) ? $menus[ $location ] : $location;
  395. }
  396. }
  397. if ( count( $theme_in_use_locations ) ) {
  398. return $theme_in_use_locations;
  399. }
  400. }
  401. return false;
  402. }
  403. /**
  404. * Adds the "Menu Themes" menu item and page.
  405. *
  406. * @since 1.0
  407. */
  408. public function megamenu_themes_page() {
  409. $page = add_menu_page( __('Max Mega Menu', 'megamenu'), __('Mega Menu', 'megamenu'), 'edit_theme_options', 'maxmegamenu', array($this, 'page') );
  410. $tabs = apply_filters("megamenu_menu_tabs", array(
  411. 'general_settings' => __("General Settings", "megamenu"),
  412. 'theme_editor' => __("Menu Themes", "megamenu"),
  413. 'menu_locations' => __("Menu Locations", "megamenu"),
  414. 'tools' => __("Tools", "megamenu")
  415. ));
  416. foreach ( $tabs as $key => $title ) {
  417. if ( $key == 'general_settings') {
  418. add_submenu_page( 'maxmegamenu', __('Max Mega Menu', 'megamenu') . ' - ' . $title, $title, 'edit_theme_options', 'maxmegamenu', array($this, 'page') );
  419. } else {
  420. add_submenu_page( 'maxmegamenu', __('Max Mega Menu', 'megamenu') . ' - ' . $title, $title, 'edit_theme_options', 'maxmegamenu_' . $key, array($this, 'page') );
  421. }
  422. }
  423. }
  424. /**
  425. * Content for 'Settings' tab
  426. *
  427. * @since 1.4
  428. */
  429. public function general_settings_page( $saved_settings ) {
  430. $css = isset( $saved_settings['css'] ) ? $saved_settings['css'] : 'fs';
  431. $mobile_second_click = isset( $saved_settings['second_click'] ) ? $saved_settings['second_click'] : 'close';
  432. $mobile_behaviour = isset( $saved_settings['mobile_behaviour'] ) ? $saved_settings['mobile_behaviour'] : 'standard';
  433. $descriptions = isset( $saved_settings['descriptions'] ) ? $saved_settings['descriptions'] : 'disabled';
  434. $unbind = isset( $saved_settings['unbind'] ) ? $saved_settings['unbind'] : 'enabled';
  435. $prefix = isset( $saved_settings['prefix'] ) ? $saved_settings['prefix'] : 'enabled';
  436. $locations = get_registered_nav_menus();
  437. ?>
  438. <div class='menu_settings menu_settings_general_settings'>
  439. <form action="<?php echo admin_url('admin-post.php'); ?>" method="post">
  440. <input type="hidden" name="action" value="megamenu_save_settings" />
  441. <?php wp_nonce_field( 'megamenu_save_settings' ); ?>
  442. <h3 class='first'><?php _e("General Settings", "megamenu"); ?></h3>
  443. <table>
  444. <tr>
  445. <td class='mega-name'>
  446. <?php _e("Click Event Behaviour", "megamenu"); ?>
  447. <div class='mega-description'>
  448. <?php _e("Define what should happen when the event is set to 'click'. This also applies to mobiles.", "megamenu"); ?>
  449. </div>
  450. </td>
  451. <td class='mega-value'>
  452. <select name='settings[second_click]'>
  453. <option value='close' <?php echo selected( $mobile_second_click == 'close'); ?>><?php _e("First click will open a sub menu, second click will close the sub menu.", "megamenu"); ?></option>
  454. <option value='go' <?php echo selected( $mobile_second_click == 'go'); ?>><?php _e("First click will open a sub menu, second click will follow the link.", "megamenu"); ?></option>
  455. <select>
  456. <div class='mega-description'>
  457. </div>
  458. </td>
  459. </tr>
  460. <tr>
  461. <td class='mega-name'>
  462. <?php _e("Mobile Menu Behaviour", "megamenu"); ?>
  463. <div class='mega-description'>
  464. <?php _e("Define the sub menu toggle behaviour for the mobile menu.", "megamenu"); ?>
  465. </div>
  466. </td>
  467. <td class='mega-value'>
  468. <select name='settings[mobile_behaviour]'>
  469. <option value='standard' <?php echo selected( $mobile_behaviour == 'standard'); ?>><?php _e("Standard - Open sub menus will remain open until closed by the user.", "megamenu"); ?></option>
  470. <option value='accordion' <?php echo selected( $mobile_behaviour == 'accordion'); ?>><?php _e("Accordion - Open sub menus will automatically close when another one is opened.", "megamenu"); ?></option>
  471. <select>
  472. <div class='mega-description'>
  473. </div>
  474. </td>
  475. </tr>
  476. <tr>
  477. <td class='mega-name'>
  478. <?php _e("CSS Output", "megamenu"); ?>
  479. <div class='mega-description'>
  480. </div>
  481. </td>
  482. <td class='mega-value'>
  483. <select name='settings[css]' id='mega_css'>
  484. <option value='fs' <?php echo selected( $css == 'fs'); ?>><?php _e("Save to filesystem", "megamenu"); ?>
  485. <?php
  486. if ( get_transient('megamenu_failed_to_write_css_to_filesystem') ) {
  487. echo " " . __("(Action required: Check upload folder permissions)", "megamenu");
  488. }
  489. ?>
  490. </option>
  491. <option value='head' <?php echo selected( $css == 'head'); ?>><?php _e("Output in &lt;head&gt;", "megamenu"); ?></option>
  492. <option value='disabled' <?php echo selected( $css == 'disabled'); ?>><?php _e("Don't output CSS", "megamenu"); ?></option>
  493. <select>
  494. <div class='mega-description'>
  495. <div class='fs' style='display: <?php echo $css == 'fs' ? 'block' : 'none' ?>'><?php _e("CSS will be saved to wp-content/uploads/maxmegamenu/style.css and enqueued from there.", "megamenu"); ?></div>
  496. <div class='head' style='display: <?php echo $css == 'head' ? 'block' : 'none' ?>'><?php _e("CSS will be loaded from the cache in a &lt;style&gt; tag in the &lt;head&gt; of the page.", "megamenu"); ?></div>
  497. <div class='disabled' style='display: <?php echo $css == 'disabled' ? 'block' : 'none' ?>'>
  498. <?php _e("CSS will not be output, you must enqueue the CSS for the menu manually.", "megamenu"); ?>
  499. <div class='fail'><?php _e("Selecting this option will effectively disable the theme editor and many of the features available in Max Mega Menu and Max Mega Menu Pro. Only enable this option if you fully understand the consequences.", "megamenu"); ?>
  500. </div>
  501. </div>
  502. </td>
  503. </tr>
  504. <tr>
  505. <td class='mega-name'>
  506. <?php _e("Menu Item Descriptions", "megamenu"); ?>
  507. <div class='mega-description'>
  508. <?php _e("Enable output of menu item descriptions", "megamenu"); ?>
  509. </div>
  510. </td>
  511. <td class='mega-value'>
  512. <select name='settings[descriptions]'>
  513. <option value='disabled' <?php echo selected( $descriptions == 'disabled'); ?>><?php _e("Disabled", "megamenu"); ?></option>
  514. <option value='enabled' <?php echo selected( $descriptions == 'enabled'); ?>><?php _e("Enabled", "megamenu"); ?></option>
  515. <select>
  516. <div class='mega-description'>
  517. </div>
  518. </td>
  519. </tr>
  520. <tr>
  521. <td class='mega-name'>
  522. <?php _e("Unbind JavaScript Events", "megamenu"); ?>
  523. <div class='mega-description'>
  524. <?php _e("To avoid conflicts with theme menu systems, JavaScript events which have been added to menu items will be removed by default.", "megamenu"); ?>
  525. </div>
  526. </td>
  527. <td class='mega-value'>
  528. <select name='settings[unbind]'>
  529. <option value='disabled' <?php echo selected( $unbind == 'disabled'); ?>><?php _e("No", "megamenu"); ?></option>
  530. <option value='enabled' <?php echo selected( $unbind == 'enabled'); ?>><?php _e("Yes", "megamenu"); ?></option>
  531. <select>
  532. <div class='mega-description'>
  533. </div>
  534. </td>
  535. </tr>
  536. <tr>
  537. <td class='mega-name'>
  538. <?php _e("Prefix Menu Item Classes", "megamenu"); ?>
  539. <div class='mega-description'>
  540. <?php _e("Prefix custom menu item classes with 'mega-'?", "megamenu"); ?>
  541. </div>
  542. </td>
  543. <td class='mega-value'>
  544. <select name='settings[prefix]'>
  545. <option value='disabled' <?php echo selected( $prefix == 'disabled'); ?>><?php _e("No", "megamenu"); ?></option>
  546. <option value='enabled' <?php echo selected( $prefix == 'enabled'); ?>><?php _e("Yes", "megamenu"); ?></option>
  547. <select>
  548. <div class='mega-description'>
  549. </div>
  550. </td>
  551. </tr>
  552. <tr>
  553. <td class='mega-name'>
  554. <?php _e("Active Menu Instances", "megamenu"); ?>
  555. <div class='mega-description'>
  556. <?php _e("Some themes will output a menu location multiple times on the same page. For example, your theme may output a menu location once for the main menu, then again for the mobile menu. This setting can be used to make sure Max Mega Menu is only applied to one of those instances.", "megamenu"); ?>
  557. </div>
  558. </td>
  559. <td class='mega-value mega-instances'>
  560. <?php if (count($locations)): ?>
  561. <table>
  562. <tr>
  563. <th><?php _e("Menu Location", "megamenu"); ?></th><th><?php _e("Active Instance", "megamenu"); ?></th>
  564. </tr>
  565. <?php foreach( $locations as $location => $description ): ?>
  566. <?php if (max_mega_menu_is_enabled($location)): ?>
  567. <?php $active_instance = isset($saved_settings['instances'][$location]) ? $saved_settings['instances'][$location] : 0; ?>
  568. <tr>
  569. <td><?php echo $description; ?></td><td><input type='text' name='settings[instances][<?php echo $location ?>]' value='<?php echo esc_attr( $active_instance ); ?>' /></td>
  570. </tr>
  571. <?php endif; ?>
  572. <?php endforeach; ?>
  573. </table>
  574. <div class='mega-description'><?php _e("0: Apply to all instances. 1: Apply to first instance. 2: Apply to second instance", "megamenu"); ?>…</div>
  575. <?php endif; ?>
  576. </td>
  577. </tr>
  578. </table>
  579. <?php do_action( "megamenu_general_settings", $saved_settings ); ?>
  580. <?php submit_button(); ?>
  581. </form>
  582. </div>
  583. <?php
  584. }
  585. /**
  586. * Content for 'Settings' tab
  587. *
  588. * @since 1.4
  589. */
  590. public function menu_locations_page( $saved_settings ) {
  591. $all_locations = get_registered_nav_menus();
  592. // PolyLang - remove auto created/translated menu locations
  593. if ( function_exists( 'pll_default_language' ) ) {
  594. $default_lang = pll_default_language( 'name' );
  595. foreach ( $all_locations as $loc => $description ) {
  596. if ( false !== strpos( $loc, '___' ) ) {
  597. // Remove locations created by Polylang
  598. unregister_nav_menu( $loc );
  599. } else {
  600. // Remove the language name appended to the original locations
  601. register_nav_menu( $loc, str_replace( ' ' . $default_lang, '', $description ) );
  602. }
  603. }
  604. $all_locations = get_registered_nav_menus();
  605. }
  606. $locations = array();
  607. $custom_locations = get_option( 'megamenu_locations' );
  608. if ( is_array( $custom_locations ) ) {
  609. $all_locations = array_merge( $custom_locations, $all_locations );
  610. }
  611. if ( count( $all_locations ) ) {
  612. $megamenu_locations = array();
  613. // reorder locations so custom MMM locations are listed at the bottom
  614. foreach ( $all_locations as $location => $val ) {
  615. if ( strpos( $location, 'max_mega_menu_' ) === FALSE ) {
  616. $locations[$location] = $val;
  617. } else {
  618. $megamenu_locations[$location] = $val;
  619. }
  620. }
  621. $locations = array_merge( $locations, $megamenu_locations );
  622. }
  623. ?>
  624. <div class='menu_settings menu_settings_menu_locations'>
  625. <form action="<?php echo admin_url('admin-post.php'); ?>" method="post">
  626. <input type="hidden" name="action" value="megamenu_save_settings" />
  627. <?php wp_nonce_field( 'megamenu_save_settings' ); ?>
  628. <h3 class='first'><?php _e("Menu Locations", "megamenu"); ?></h3>
  629. <table>
  630. <tr>
  631. <td class='mega-name'>
  632. <?php _e("Registered Menu Locations", "megamenu"); ?>
  633. <div class='mega-description'><?php _e("This is an overview of the menu locations supported by your theme. You can enable Max Mega Menu and adjust the settings for a specific menu location by going to Appearance > Menus.", "megamenu"); ?></div>
  634. </td>
  635. <td class='mega-value'>
  636. <p>
  637. <?php
  638. if ( ! count($locations)) {
  639. _e("Your theme does not natively support menus, but you can add a new menu location using Max Mega Menu and display the menu using the Max Mega Menu widget or shortcode.", "megamenu");
  640. } else {
  641. echo sprintf( _n("Your theme supports %s menu location.", "Your theme supports %s menu locations.", count($locations), "megamenu"), count($locations) );
  642. }
  643. ?>
  644. </p>
  645. <?php
  646. if ( count ( $locations ) ) {
  647. echo "<div class='accordion-container'>";
  648. echo "<ul class='outer-border'>";
  649. foreach ( $locations as $location => $description ) {
  650. $menu_id = $this->get_menu_id_for_location( $location );
  651. $is_custom_location = strpos( $location, 'max_mega_menu_' ) !== FALSE;
  652. ?>
  653. <li class='control-section accordion-section mega-location'>
  654. <h4 class='accordion-section-title hndle'>
  655. <?php echo esc_attr( $description ) ?>
  656. <?php
  657. if ($menu_id) {
  658. echo "<div class='mega-assigned-menu'>";
  659. echo "<a href='" . admin_url("nav-menus.php?action=edit&menu={$menu_id}") . "'>" . $this->get_menu_name_for_location( $location ) . "</a>";
  660. echo "</div>";
  661. }
  662. ?>
  663. </h4>
  664. <div class='accordion-section-content'>
  665. <?php if ( ! max_mega_menu_is_enabled( $location ) ): ?>
  666. <div class='notice fail'><p><?php _e("Max Mega Menu is not enabled for this menu location. If you wish to use Max Mega Menu for this location you must enable it under Appearance > Menus.", "megamenu"); ?></p></div>
  667. <?php endif; ?>
  668. <table>
  669. <?php if ( $is_custom_location ) : ?>
  670. <tr>
  671. <td class='mega-name'>
  672. <?php _e("Location Description", "megamenu"); ?>
  673. <div class='mega-description'><?php _e("Change the name of the location.", "megamenu"); ?></div>
  674. </td>
  675. <td class='mega-value wide'>
  676. <input type='text' name='location[<?php echo $location ?>]' value='<?php echo esc_attr( $description ); ?>' />
  677. </td>
  678. </tr>
  679. <?php endif; ?>
  680. </table>
  681. <h5><?php _e("Menu Display Options", "megamenu"); ?></h5>
  682. <?php if ( ! $is_custom_location ) : ?>
  683. <p><?php _e("These options are for advanced users only. Your theme should already include the code required to display this menu on your site.", "megamenu"); ?>
  684. <?php endif; ?>
  685. <table>
  686. <tr>
  687. <td class='mega-name'>
  688. <?php _e("PHP Function", "megamenu"); ?>
  689. <div class='mega-description'><?php _e("For use in a theme template (usually header.php)", "megamenu"); ?></div>
  690. </td>
  691. <td class='mega-value'>
  692. <textarea readonly="readonly">&lt;?php wp_nav_menu( array( 'theme_location' => '<?php echo $location ?>' ) ); ?&gt;</textarea>
  693. </td>
  694. </tr>
  695. <tr>
  696. <td class='mega-name'>
  697. <?php _e("Shortcode", "megamenu"); ?>
  698. <div class='mega-description'><?php _e("For use in a post or page.", "megamenu"); ?></div>
  699. </td>
  700. <td class='mega-value'>
  701. <textarea readonly="readonly">[maxmegamenu location=<?php echo $location ?>]</textarea>
  702. </td>
  703. </tr>
  704. <tr>
  705. <td class='mega-name'>
  706. <?php _e("Widget", "megamenu"); ?>
  707. <div class='mega-description'><?php _e("For use in a widget area.", "megamenu"); ?></div>
  708. </td>
  709. <td class='mega-value'>
  710. <?php _e("Add the 'Max Mega Menu' widget to a widget area.", "megamenu") ?>
  711. </td>
  712. </tr>
  713. </table>
  714. <?php
  715. if ( $is_custom_location ) {
  716. $delete_location_url = esc_url( add_query_arg(
  717. array(
  718. 'action' => 'megamenu_delete_menu_location',
  719. 'location' => $location
  720. ),
  721. wp_nonce_url( admin_url("admin-post.php"), 'megamenu_delete_menu_location' )
  722. ) );
  723. echo '<div class="megamenu_submit"><div class="mega_left">';
  724. submit_button();
  725. echo '</div><div class="mega_right">';
  726. echo "<a class='confirm mega-delete' href='{$delete_location_url}'>" . __("Delete location", "megamenu") . "</a>";
  727. echo '</div></div>';
  728. }
  729. ?>
  730. </div>
  731. </li>
  732. <?php
  733. }
  734. echo "</div>";
  735. echo "</div>";
  736. }
  737. $add_location_url = esc_url( add_query_arg(
  738. array(
  739. 'action'=>'megamenu_add_menu_location'
  740. ),
  741. wp_nonce_url( admin_url("admin-post.php"), 'megamenu_add_menu_location' )
  742. ) );
  743. echo "<br /><p><a class='button button-secondary' href='{$add_location_url}'>" . __("Add another menu location", "megamenu") . "</a></p>";
  744. ?>
  745. </td>
  746. </tr>
  747. </table>
  748. <?php do_action( "megamenu_menu_locations", $saved_settings ); ?>
  749. </form>
  750. </div>
  751. <?php
  752. }
  753. /**
  754. * Returns the menu ID for a specified menu location, defaults to 0
  755. *
  756. * @since 1.8
  757. * @param string $location
  758. */
  759. private function get_menu_id_for_location( $location ) {
  760. $locations = get_nav_menu_locations();
  761. $id = isset( $locations[ $location ] ) ? $locations[ $location ] : 0;
  762. return $id;
  763. }
  764. /**
  765. * Returns the menu name for a specified menu location
  766. *
  767. * @since 1.8
  768. * @param string $location
  769. */
  770. private function get_menu_name_for_location( $location ) {
  771. $id = $this->get_menu_id_for_location( $location );
  772. $menus = wp_get_nav_menus();
  773. foreach ( $menus as $menu ) {
  774. if ( $menu->term_id == $id ) {
  775. return $menu->name;
  776. }
  777. }
  778. return false;
  779. }
  780. /**
  781. * Content for 'Tools' tab
  782. *
  783. * @since 1.4
  784. */
  785. public function tools_page( $saved_settings ) {
  786. ?>
  787. <div class='menu_settings menu_settings_tools'>
  788. <h3 class='first'><?php _e("Tools", "megamenu"); ?></h3>
  789. <table>
  790. <tr>
  791. <td class='mega-name'>
  792. <?php _e("Cache", "megamenu"); ?>
  793. <div class='mega-description'><?php _e("The CSS cache is automatically cleared every time a menu or a menu theme is saved. You can manually clear the CSS cache using this tool.", "megamenu"); ?></div>
  794. </td>
  795. <td class='mega-value'>
  796. <form action="<?php echo admin_url('admin-post.php'); ?>" method="post">
  797. <?php wp_nonce_field( 'megamenu_clear_css_cache' ); ?>
  798. <input type="hidden" name="action" value="megamenu_clear_css_cache" />
  799. <input type='submit' class='button button-secondary' value='<?php _e("Clear CSS Cache", "megamenu"); ?>' />
  800. </form>
  801. </td>
  802. </tr>
  803. <tr>
  804. <td class='mega-name'>
  805. <?php _e("Export Theme", "megamenu"); ?>
  806. <div class='mega-description'><?php _e("Export a menu theme", "megamenu"); ?></div>
  807. </td>
  808. <td class='mega-value'>
  809. <form method="post" action="<?php echo admin_url( "admin.php?page=maxmegamenu_tools") ?>">
  810. <?php
  811. if ( isset( $_POST['theme_export'] ) ) {
  812. $style_manager = new Mega_Menu_Style_Manager();
  813. $default_theme = $style_manager->get_default_theme();
  814. $theme_to_export = $_POST['theme_export'];
  815. if ( isset( $this->themes[ $theme_to_export ] ) ) {
  816. $theme_to_export = $this->themes[ $theme_to_export ];
  817. $diff = array();
  818. foreach ( $default_theme as $key => $value ) {
  819. if ( isset( $theme_to_export[$key] ) && $theme_to_export[$key] != $value || $key == 'title') {
  820. $diff[$key] = $theme_to_export[$key];
  821. }
  822. }
  823. if ( isset( $_POST['format'] ) && $_POST['format'] == 'json' ) {
  824. echo "<p>" . __("Log into the site you wish to import the theme to. Go to Mega Menu > Tools and paste this into the 'Import Theme' text area:", "megamenu") . "</p>";
  825. echo "<textarea>" . htmlentities( json_encode( $diff ) ) . "</textarea>";
  826. } else {
  827. $key = strtolower( str_replace(" ", "_", $theme_to_export['title'] ) );
  828. $key .= "_" . time();
  829. echo "<p>" . __("Paste this code into your themes functions.php file:", "megamenu") . "</p>";
  830. echo '<textarea>';
  831. echo 'function megamenu_add_theme_' . $key . '($themes) {';
  832. echo "\n" . ' $themes["' . $key .'"] = array(';
  833. foreach ($diff as $theme_key => $value) {
  834. echo "\n '" . $theme_key . "' => '" . $value . "',";
  835. }
  836. echo "\n" . ' );';
  837. echo "\n" . ' return $themes;';
  838. echo "\n" . '}';
  839. echo "\n" . 'add_filter("megamenu_themes", "megamenu_add_theme_' . $key . '");';
  840. echo '</textarea>';
  841. }
  842. }
  843. } else {
  844. echo "<select name='theme_export'>";
  845. foreach ( $this->themes as $id => $theme ) {
  846. echo "<option value='{$id}'>{$theme['title']}</option>";
  847. }
  848. echo "</select>";
  849. echo "<h4>" . __("Export Format", "megamenu") . "</h4>";
  850. echo "<label><input value='json' type='radio' checked='checked' name='format'>" . __("JSON - I want to import this theme into another site I'm developing", "megamenu") . "</label>";
  851. echo "<label><input value='php' type='radio' name='format'>" . __("PHP - I want to distribute this Menu Theme in a WordPress Theme I'm developing", "megamenu") . "<label>";
  852. echo "<input type='submit' name='export' class='button button-secondary' value='" . __("Export Theme", "megamenu") . "' />";
  853. }
  854. ?>
  855. </form>
  856. </td>
  857. </tr>
  858. <tr>
  859. <td class='mega-name'>
  860. <?php _e("Import Theme", "megamenu"); ?>
  861. <div class='mega-description'><?php _e("Import a menu theme in JSON format", "megamenu"); ?></div>
  862. </td>
  863. <td class='mega-value'>
  864. <form action="<?php echo admin_url('admin-post.php'); ?>" method="post">
  865. <?php wp_nonce_field( 'megamenu_import_theme' ); ?>
  866. <input type="hidden" name="action" value="megamenu_import_theme" />
  867. <textarea name='data'></textarea>
  868. <input type='submit' class='button button-secondary' value='<?php _e("Import Theme", "megamenu"); ?>' />
  869. </form>
  870. </td>
  871. </tr>
  872. <tr>
  873. <td class='mega-name'>
  874. <?php _e("Plugin Data", "megamenu"); ?>
  875. <div class='mega-description'><?php _e("Delete all saved Max Mega Menu plugin data from the database. Use with caution!", "megamenu"); ?></div>
  876. </td>
  877. <td class='mega-value'>
  878. <form action="<?php echo admin_url('admin-post.php'); ?>" method="post">
  879. <?php wp_nonce_field( 'megamenu_delete_data' ); ?>
  880. <input type="hidden" name="action" value="megamenu_delete_data" />
  881. <input type='submit' class='button button-secondary confirm' value='<?php _e("Delete Data", "megamenu"); ?>' />
  882. </form>
  883. </td>
  884. </tr>
  885. </table>
  886. </div>
  887. <?php
  888. }
  889. /**
  890. * Main settings page wrapper.
  891. *
  892. * @since 1.4
  893. */
  894. public function page() {
  895. $tab = isset( $_GET['page'] ) ? substr( $_GET['page'], 12 ) : false;
  896. // backwards compatibility
  897. if ( isset ( $_GET['tab'] ) ) {
  898. $tab = $_GET['tab'];
  899. }
  900. if ( ! $tab ) {
  901. $tab = 'general_settings';
  902. }
  903. $header_links = apply_filters( "megamenu_header_links", array(
  904. 'homepage' => array(
  905. 'url' => 'https://www.megamenu.com/?utm_source=free&amp;utm_medium=settings&amp;utm_campaign=pro',
  906. 'target' => '_mmmpro',
  907. 'text' => __("Homepage", "megamenu"),
  908. 'class' => ''
  909. ),
  910. 'documentation' => array(
  911. 'url' => 'https://www.megamenu.com/documentation/installation/?utm_source=free&amp;utm_medium=settings&amp;utm_campaign=pro',
  912. 'text' => __("Documentation", "megamenu"),
  913. 'target' => '_mmmpro',
  914. 'class' => ''
  915. ),
  916. 'troubleshooting' => array(
  917. 'url' => 'https://www.megamenu.com/articles/troubleshooting/?utm_source=free&amp;utm_medium=settings&amp;utm_campaign=pro',
  918. 'text' => __("Troubleshooting", "megamenu"),
  919. 'target' => '_mmmpro',
  920. 'class' => ''
  921. )
  922. ) );
  923. if ( ! is_plugin_active('megamenu-pro/megamenu-pro.php') ) {
  924. //$header_links['rate_us'] = array(
  925. // 'url' => 'https://wordpress.org/support/plugin/megamenu/reviews/#new-post',
  926. // 'text' => __("If you like this plugin, please vote and support us!", "megamenu"),
  927. // 'target' => '_blank',
  928. // 'class' => 'mega-star'
  929. //);
  930. $header_links['pro'] = array(
  931. 'url' => 'https://www.megamenu.com/upgrade/?utm_source=free&amp;utm_medium=settings&amp;utm_campaign=pro',
  932. 'target' => '_mmmpro',
  933. 'text' => __("Upgrade to Pro", "megamenu"),
  934. 'class' => 'mega-highlight'
  935. );
  936. }
  937. $versions = apply_filters( "megamenu_versions", array(
  938. 'core' => array(
  939. 'version' => MEGAMENU_VERSION,
  940. 'text' => __("Core version", "megamenu")
  941. ),
  942. 'pro' => array(
  943. 'version' => "<a href='https://www.megamenu.com/upgrade/?utm_source=free&amp;utm_medium=settings&amp;utm_campaign=pro' target='_mmmpro'>not installed</a>",
  944. 'text' => __("Pro extension", "megamenu")
  945. )
  946. ) );
  947. ?>
  948. <div class='megamenu_outer_wrap'>
  949. <div class='megamenu_header_top'>
  950. <ul>
  951. <?php
  952. foreach ( $header_links as $id => $data ) {
  953. echo "<li class='{$data['class']}'><a href='{$data['url']}' target='{$data['target']}'>{$data['text']}";
  954. echo "</a>";
  955. echo "</li>";
  956. }
  957. ?>
  958. </ul>
  959. </div>
  960. <div class='megamenu_header'>
  961. <div class='megamenu_header_left'>
  962. <h2><?php _e("Max Mega Menu", "megamenu"); ?></h2>
  963. <div class='version'>
  964. <?php
  965. $total = count( $versions );
  966. $count = 0;
  967. $separator = ' - ';
  968. foreach ( $versions as $id => $data ) {
  969. echo $data['text'] . ": <b>" . $data['version'] . "</b>";
  970. $count = $count + 1;
  971. if ( $total > 0 && $count != $total ) {
  972. echo $separator;
  973. }
  974. }
  975. ?>
  976. </div>
  977. </div>
  978. </div>
  979. <div class='megamenu_wrap'>
  980. <div class='megamenu_right'>
  981. <?php $this->print_messages(); ?>
  982. <?php
  983. $saved_settings = get_option("megamenu_settings");
  984. if ( has_action( "megamenu_page_{$tab}" ) ) {
  985. do_action( "megamenu_page_{$tab}", $saved_settings );
  986. } else {
  987. do_action( "megamenu_page_general_settings", $saved_settings );
  988. }
  989. ?>
  990. </div>
  991. </div>
  992. <div class='megamenu_left'>
  993. <ul>
  994. <?php
  995. $tabs = apply_filters("megamenu_menu_tabs", array(
  996. 'general_settings' => __("General Settings", "megamenu"),
  997. 'theme_editor' => __("Menu Themes", "megamenu"),
  998. 'menu_locations' => __("Menu Locations", "megamenu"),
  999. 'tools' => __("Tools", "megamenu")
  1000. ));
  1001. foreach ( $tabs as $key => $title ) {
  1002. $class = $tab == $key ? 'active' : '';
  1003. if ( $key == 'general_settings' ) {
  1004. $args = array( 'page' => 'maxmegamenu' );
  1005. } else {
  1006. $args = array( 'page' => 'maxmegamenu_' . $key );
  1007. }
  1008. $url = esc_url( add_query_arg( $args, admin_url("admin.php") ) );
  1009. echo "<li><a class='{$class}' href='{$url}'>{$title}</a></li>";
  1010. }
  1011. ?>
  1012. </ul>
  1013. </div>
  1014. </div>
  1015. <?php
  1016. }
  1017. /**
  1018. * Display messages to the user
  1019. *
  1020. * @since 1.0
  1021. */
  1022. public function print_messages() {
  1023. $this->init();
  1024. $style_manager = new Mega_Menu_Style_Manager();
  1025. $test = $style_manager->test_theme_compilation( $this->active_theme );
  1026. if ( is_wp_error( $test ) ) {
  1027. echo "<p class='fail'>" . $test->get_error_message() . "</p>";
  1028. }
  1029. if ( isset( $_GET['deleted'] ) && $_GET['deleted'] == 'false' ) {
  1030. echo "<p class='fail'>" . __("Failed to delete theme. The theme is in use by a menu.", "megamenu") . "</p>";
  1031. }
  1032. if ( isset( $_GET['clear_css_cache'] ) && $_GET['clear_css_cache'] == 'true' ) {
  1033. echo "<p class='success'>";
  1034. echo __("The cache has been cleared and the menu CSS has been regenerated.", "megamenu");
  1035. $active_plugins = max_mega_menu_get_active_caching_plugins();
  1036. if ( count( $active_plugins ) ) {
  1037. echo "<br /><br />";
  1038. echo __("You may also need to clear the cache for any Caching, Minification or CDN plugin you have installed.", "megamenu");
  1039. }
  1040. echo "</p>";
  1041. }
  1042. if ( isset( $_GET['delete_data'] ) && $_GET['delete_data'] == 'true' ) {
  1043. echo "<p class='success'>" . __("All plugin data removed", "megamenu") . "</p>";
  1044. }
  1045. if ( isset( $_GET['deleted'] ) && $_GET['deleted'] == 'true' ) {
  1046. echo "<p class='success'>" . __("Theme Deleted", "megamenu") . "</p>";
  1047. }
  1048. if ( isset( $_GET['duplicated'] ) ) {
  1049. echo "<p class='success'>" . __("Theme Duplicated", "megamenu") . "</p>";
  1050. }
  1051. if ( isset( $_GET['saved'] ) ) {
  1052. echo "<p class='success'>" . __("Changes Saved", "megamenu") . "</p>";
  1053. }
  1054. if ( isset( $_GET['reverted'] ) ) {
  1055. echo "<p class='success'>" . __("Theme Reverted", "megamenu") . "</p>";
  1056. }
  1057. if ( isset( $_GET['created'] ) ) {
  1058. echo "<p class='success'>" . __("New Theme Created. To apply this theme to a menu, go to <i>Appearance > Menus > Max Mega Menu Settings</i> and select this theme from the 'Theme' dropdown.", "megamenu") . "</p>";
  1059. }
  1060. if ( isset( $_GET['add_location'] ) ) {
  1061. echo "<p class='success'>" . __("New Menu Location Created", "megamenu") . "</p>";
  1062. }
  1063. if ( isset( $_GET['delete_location'] ) ) {
  1064. echo "<p class='success'>" . __("Menu Location Deleted", "megamenu") . "</p>";
  1065. }
  1066. if ( isset( $_GET['theme_imported'] ) && $_GET['theme_imported'] == 'false' ) {
  1067. echo "<p class='fail'>" . __("Theme Import Failed", "megamenu") . "</p>";
  1068. }
  1069. if ( isset( $_POST['theme_export'] ) ) {
  1070. echo "<p class='success'>" . __("Theme Exported", "megamenu") . "</p>";
  1071. }
  1072. if ( is_plugin_active('clearfy/clearfy.php') ) {
  1073. if ( $clearfy_options = get_option('wbcr_clearfy_cache_options') ) {
  1074. if ( $clearfy_options['disable_dashicons'] == true ) {
  1075. echo "<p class='fail'>" . __("Please enable Dashicons in the Clearfy plugin options. Max Mega Menu requires Dashicons.", "megamenu") . "</p>";
  1076. }
  1077. }
  1078. }
  1079. do_action("megamenu_print_messages");
  1080. }
  1081. /**
  1082. * Lists the available themes
  1083. *
  1084. * @since 1.0
  1085. */
  1086. public function theme_selector() {
  1087. $list_items = "<select id='theme_selector'>";
  1088. foreach ( $this->themes as $id => $theme ) {
  1089. $locations = $this->theme_is_being_used_by_location( $id );
  1090. $selected = $id == $this->id ? 'selected=selected' : '';
  1091. $list_items .= "<option {$selected} value='" . admin_url("admin.php?page=maxmegamenu_theme_editor&theme={$id}") . "'>";
  1092. $list_items .= $theme['title'];
  1093. if ( is_array( $locations ) ) {
  1094. $list_items .= " (" . implode( ", ", $locations ) . ")";
  1095. }
  1096. $list_items .= "</option>";
  1097. }
  1098. return $list_items .= "</select>";
  1099. }
  1100. /**
  1101. * Checks to see if a given string contains any of the provided search terms
  1102. *
  1103. * @param srgin $key
  1104. * @param array $needles
  1105. * @since 1.0
  1106. */
  1107. private function string_contains( $key, $needles ) {
  1108. foreach ( $needles as $needle ) {
  1109. if ( strpos( $key, $needle ) !== FALSE ) {
  1110. return true;
  1111. }
  1112. }
  1113. return false;
  1114. }
  1115. /**
  1116. * Displays the theme editor form.
  1117. *
  1118. * @since 1.0
  1119. */
  1120. public function theme_editor_page( $saved_settings ) {
  1121. $this->init();
  1122. $create_url = esc_url( add_query_arg(
  1123. array(
  1124. 'action'=>'megamenu_add_theme'
  1125. ),
  1126. wp_nonce_url( admin_url("admin-post.php"), 'megamenu_create_theme' )
  1127. ) );
  1128. $duplicate_url = esc_url( add_query_arg(
  1129. array(
  1130. 'action'=>'megamenu_duplicate_theme',
  1131. 'theme_id' => $this->id
  1132. ),
  1133. wp_nonce_url( admin_url("admin-post.php"), 'megamenu_duplicate_theme' )
  1134. ) );
  1135. $delete_url = esc_url( add_query_arg(
  1136. array(
  1137. 'action'=>'megamenu_delete_theme',
  1138. 'theme_id' => $this->id
  1139. ),
  1140. wp_nonce_url( admin_url("admin-post.php"), 'megamenu_delete_theme' )
  1141. ) );
  1142. $revert_url = esc_url( add_query_arg(
  1143. array(
  1144. 'action'=>'megamenu_revert_theme',
  1145. 'theme_id' => $this->id
  1146. ),
  1147. wp_nonce_url( admin_url("admin-post.php"), 'megamenu_revert_theme' )
  1148. ) );
  1149. ?>
  1150. <div class='menu_settings menu_settings_menu_themes'>
  1151. <div class='theme_selector'>
  1152. <?php _e("Select theme to edit", "megamenu"); ?> <?php echo $this->theme_selector(); ?> <?php _e("or", "megamenu"); ?>
  1153. <a href='<?php echo $create_url ?>'><?php _e("create a new theme", "megamenu"); ?></a> <?php _e("or", "megamenu"); ?>
  1154. <a href='<?php echo $duplicate_url ?>'><?php _e("duplicate this theme", "megamenu"); ?></a>
  1155. </div>
  1156. <h3 class='editing_theme'><?php echo __("Editing theme", "megamenu") . ": " . $this->active_theme['title']; ?></h3>
  1157. <?php
  1158. $saved_settings = get_option("megamenu_settings");
  1159. if (isset($saved_settings['css']) && $saved_settings['css'] == 'disabled') {
  1160. ?>
  1161. <div class='fail'><?php _e("CSS Output (under Mega Menu > General Settings) has been disabled. Therefore, changes made within the theme editor will not be applied to your menu.", "megamenu"); ?></div>
  1162. <?php
  1163. }
  1164. $locations = $this->theme_is_being_used_by_location( $this->id );
  1165. if ( ! $locations && ! isset($_GET['created'] ) ) {
  1166. ?>
  1167. <div class='warning'><?php _e("This menu theme is not currently active as it has not been applied to any menu locations. You may wish to check you are editing the correct menu theme - you can choose a different theme to edit using the 'Select theme to edit' selector above. Alternatively, to apply this theme to a menu go to <i>Appearance > Menus > Max Mega Menu Settings</i> and select this theme from the 'Theme' dropdown.", "megamenu"); ?></div>
  1168. <?php
  1169. }
  1170. ?>
  1171. <form action="<?php echo admin_url('admin-post.php'); ?>" method="post" class="theme_editor">
  1172. <input type="hidden" name="theme_id" value="<?php echo esc_attr( $this->id ); ?>" />
  1173. <input type="hidden" name="action" value="megamenu_save_theme" />
  1174. <?php wp_nonce_field( 'megamenu_save_theme' ); ?>
  1175. <?php
  1176. $settings = apply_filters( 'megamenu_theme_editor_settings', array(
  1177. 'general' => array(
  1178. 'title' => __( "General Settings", "megamenu" ),
  1179. 'settings' => array(
  1180. 'title' => array(
  1181. 'priority' => 10,
  1182. 'title' => __( "Theme Title", "megamenu" ),
  1183. 'description' => "",
  1184. 'settings' => array(
  1185. array(
  1186. 'title' => "",
  1187. 'type' => 'freetext',
  1188. 'key' => 'title'
  1189. )
  1190. )
  1191. ),
  1192. 'arrow' => array(
  1193. 'priority' => 20,
  1194. 'title' => __( "Arrow", "megamenu" ),
  1195. 'description' => __( "Select the arrow styles.", "megamenu" ),
  1196. 'settings' => array(
  1197. array(
  1198. 'title' => __( "Up", "megamenu" ),
  1199. 'type' => 'arrow',
  1200. 'key' => 'arrow_up'
  1201. ),
  1202. array(
  1203. 'title' => __( "Down", "megamenu" ),
  1204. 'type' => 'arrow',
  1205. 'key' => 'arrow_down'
  1206. ),
  1207. array(
  1208. 'title' => __( "Left", "megamenu" ),
  1209. 'type' => 'arrow',
  1210. 'key' => 'arrow_left'
  1211. ),
  1212. array(
  1213. 'title' => __( "Right", "megamenu" ),
  1214. 'type' => 'arrow',
  1215. 'key' => 'arrow_right'
  1216. )
  1217. )
  1218. ),
  1219. 'line_height' => array(
  1220. 'priority' => 30,
  1221. 'title' => __( "Line Height", "megamenu" ),
  1222. 'description' => __( "Set the general line height to use in the sub menu contents.", "megamenu" ),
  1223. 'settings' => array(
  1224. array(
  1225. 'title' => "",
  1226. 'type' => 'freetext',
  1227. 'key' => 'line_height'
  1228. )
  1229. )
  1230. ),
  1231. 'z_index' => array(
  1232. 'priority' => 40,
  1233. 'title' => __( "Z Index", "megamenu" ),
  1234. 'description' => __( "Set the z-index to ensure the sub menus appear ontop of other content.", "megamenu" ),
  1235. 'settings' => array(
  1236. array(
  1237. 'title' => "",
  1238. 'type' => 'freetext',
  1239. 'key' => 'z_index',
  1240. 'validation' => 'int'
  1241. )
  1242. )
  1243. ),
  1244. 'shadow' => array(
  1245. 'priority' => 50,
  1246. 'title' => __( "Shadow", "megamenu" ),
  1247. 'description' => __( "Apply a shadow to mega and flyout menus.", "megamenu" ),
  1248. 'settings' => array(
  1249. array(
  1250. 'title' => __( "Enabled", "megamenu" ),
  1251. 'type' => 'checkbox',
  1252. 'key' => 'shadow'
  1253. ),
  1254. array(
  1255. 'title' => __( "Horizontal", "megamenu" ),
  1256. 'type' => 'freetext',
  1257. 'key' => 'shadow_horizontal',
  1258. 'validation' => 'px'
  1259. ),
  1260. array(
  1261. 'title' => __( "Vertical", "megamenu" ),
  1262. 'type' => 'freetext',
  1263. 'key' => 'shadow_vertical',
  1264. 'validation' => 'px'
  1265. ),
  1266. array(
  1267. 'title' => __( "Blur", "megamenu" ),
  1268. 'type' => 'freetext',
  1269. 'key' => 'shadow_blur',
  1270. 'validation' => 'px'
  1271. ),
  1272. array(
  1273. 'title' => __( "Spread", "megamenu" ),
  1274. 'type' => 'freetext',
  1275. 'key' => 'shadow_spread',
  1276. 'validation' => 'px'
  1277. ),
  1278. array(
  1279. 'title' => __( "Color", "megamenu" ),
  1280. 'type' => 'color',
  1281. 'key' => 'shadow_color'
  1282. )
  1283. )
  1284. ),
  1285. 'transitions' => array(
  1286. 'priority' => 60,
  1287. 'title' => __( "Hover Transitions", "megamenu" ),
  1288. 'description' => __( "Apply hover transitions to menu items. Note: Transitions will not apply to gradient backgrounds.", "megamenu" ),
  1289. 'settings' => array(
  1290. array(
  1291. 'title' => __( "Enabled", "megamenu" ),
  1292. 'type' => 'checkbox',
  1293. 'key' => 'transitions'
  1294. )
  1295. )
  1296. ),
  1297. 'resets' => array(
  1298. 'priority' => 70,
  1299. 'title' => __( "Reset Widget Styling", "megamenu" ),
  1300. 'description' => __( "Reset the styling of widgets within the mega menu?", "megamenu" ),
  1301. 'settings' => array(
  1302. array(
  1303. 'title' => __( "Enabled", "megamenu" ),
  1304. 'type' => 'checkbox',
  1305. 'key' => 'resets'
  1306. )
  1307. )
  1308. )
  1309. )
  1310. ),
  1311. 'menu_bar' => array(
  1312. 'title' => __( "Menu Bar", "megamenu" ),
  1313. 'settings' => array(
  1314. 'menu_item_height' => array(
  1315. 'priority' => 05,
  1316. 'title' => __( "Menu Height", "megamenu" ),
  1317. 'description' => __( "Define the height of each top level menu item link. This value plus the Menu Padding (top and bottom) settings define the overall height of the menu bar.", "megamenu" ),
  1318. 'settings' => array(
  1319. array(
  1320. 'title' => "",
  1321. 'type' => 'freetext',
  1322. 'key' => 'menu_item_link_height',
  1323. 'validation' => 'px'
  1324. )
  1325. )
  1326. ),
  1327. 'menu_background' => array(
  1328. 'priority' => 10,
  1329. 'title' => __( "Menu Background", "megamenu" ),
  1330. 'description' => __( "The background color for the main menu bar. Set each value to transparent for a 'button' style menu.", "megamenu" ),
  1331. 'settings' => array(
  1332. array(
  1333. 'title' => __( "From", "megamenu" ),
  1334. 'type' => 'color',
  1335. 'key' => 'container_background_from'
  1336. ),
  1337. array(
  1338. 'title' => __( "Copy", "megamenu" ),
  1339. 'type' => 'copy_color',
  1340. 'key' => 'copy_color'
  1341. ),
  1342. array(
  1343. 'title' => __( "To", "megamenu" ),
  1344. 'type' => 'color',
  1345. 'key' => 'container_background_to'
  1346. )
  1347. )
  1348. ),
  1349. 'menu_padding' => array(
  1350. 'priority' => 20,
  1351. 'title' => __( "Menu Padding", "megamenu" ),
  1352. 'description' => __( "Padding for the main menu bar.", "megamenu" ),
  1353. 'settings' => array(
  1354. array(
  1355. 'title' => __( "Top", "megamenu" ),
  1356. 'type' => 'freetext',
  1357. 'key' => 'container_padding_top',
  1358. 'validation' => 'px'
  1359. ),
  1360. array(
  1361. 'title' => __( "Right", "megamenu" ),
  1362. 'type' => 'freetext',
  1363. 'key' => 'container_padding_right',
  1364. 'validation' => 'px'
  1365. ),
  1366. array(
  1367. 'title' => __( "Bottom", "megamenu" ),
  1368. 'type' => 'freetext',
  1369. 'key' => 'container_padding_bottom',
  1370. 'validation' => 'px'
  1371. ),
  1372. array(
  1373. 'title' => __( "Left", "megamenu" ),
  1374. 'type' => 'freetext',
  1375. 'key' => 'container_padding_left',
  1376. 'validation' => 'px'
  1377. )
  1378. )
  1379. ),
  1380. 'menu_border_radius' => array(
  1381. 'priority' => 30,
  1382. 'title' => __( "Menu Border Radius", "megamenu" ),
  1383. 'description' => __( "Set a border radius on the main menu bar.", "megamenu" ),
  1384. 'settings' => array(
  1385. array(
  1386. 'title' => __( "Top Left", "megamenu" ),
  1387. 'type' => 'freetext',
  1388. 'key' => 'container_border_radius_top_left',
  1389. 'validation' => 'px'
  1390. ),
  1391. array(
  1392. 'title' => __( "Top Right", "megamenu" ),
  1393. 'type' => 'freetext',
  1394. 'key' => 'container_border_radius_top_right',
  1395. 'validation' => 'px'
  1396. ),
  1397. array(
  1398. 'title' => __( "Bottom Right", "megamenu" ),
  1399. 'type' => 'freetext',
  1400. 'key' => 'container_border_radius_bottom_right',
  1401. 'validation' => 'px'
  1402. ),
  1403. array(
  1404. 'title' => __( "Bottom Left", "megamenu" ),
  1405. 'type' => 'freetext',
  1406. 'key' => 'container_border_radius_bottom_left',
  1407. 'validation' => 'px'
  1408. )
  1409. )
  1410. ),
  1411. 'menu_item_align' => array(
  1412. 'priority' => 40,
  1413. 'title' => __( "Menu Items Align", "megamenu" ),
  1414. 'description' => __( "Align <i>all</i> menu items to the left (default), centrally or to the right.", "megamenu" ),
  1415. 'info' => array( __( "This option will apply to all menu items. To align an individual menu item to the right, edit the menu item itself and set 'Menu Item Align' to 'Right'.", "megamenu" ) ),
  1416. 'settings' => array(
  1417. array(
  1418. 'title' => "",
  1419. 'type' => 'align',
  1420. 'key' => 'menu_item_align'
  1421. )
  1422. )
  1423. ),
  1424. 'top_level_menu_items' => array(
  1425. 'priority' => 50,
  1426. 'title' => __( "Top Level Menu Items", "megamenu" ),
  1427. 'description' => '',
  1428. ),
  1429. 'menu_item_background' => array(
  1430. 'priority' => 60,
  1431. 'title' => __( "Menu Item Background", "megamenu" ),
  1432. 'description' => __( "The background color for each top level menu item. Tip: Set these values to transparent if you've already set a background color on the menu bar.", "megamenu" ),
  1433. 'settings' => array(
  1434. array(
  1435. 'title' => __( "From", "megamenu" ),
  1436. 'type' => 'color',
  1437. 'key' => 'menu_item_background_from'
  1438. ),
  1439. array(
  1440. 'title' => __( "Copy", "megamenu" ),
  1441. 'type' => 'copy_color',
  1442. 'key' => 'copy_color'
  1443. ),
  1444. array(
  1445. 'title' => __( "To", "megamenu" ),
  1446. 'type' => 'color',
  1447. 'key' => 'menu_item_background_to'
  1448. )
  1449. )
  1450. ),
  1451. 'menu_item_background_hover' => array(
  1452. 'priority' => 70,
  1453. 'title' => __( "Menu Item Background (Hover)", "megamenu" ),
  1454. 'description' => __( "The background color for a top level menu item (on hover).", "megamenu" ),
  1455. 'settings' => array(
  1456. array(
  1457. 'title' => __( "From", "megamenu" ),
  1458. 'type' => 'color',
  1459. 'key' => 'menu_item_background_hover_from'
  1460. ),
  1461. array(
  1462. 'title' => __( "Copy", "megamenu" ),
  1463. 'type' => 'copy_color',
  1464. 'key' => 'copy_color'
  1465. ),
  1466. array(
  1467. 'title' => __( "To", "megamenu" ),
  1468. 'type' => 'color',
  1469. 'key' => 'menu_item_background_hover_to'
  1470. )
  1471. )
  1472. ),
  1473. 'menu_item_spacing' => array(
  1474. 'priority' => 80,
  1475. 'title' => __( "Menu Item Spacing", "megamenu" ),
  1476. 'description' => __( "Define the size of the gap between each top level menu item.", "megamenu" ),
  1477. 'settings' => array(
  1478. array(
  1479. 'title' => "",
  1480. 'type' => 'freetext',
  1481. 'key' => 'menu_item_spacing',
  1482. 'validation' => 'px'
  1483. )
  1484. )
  1485. ),
  1486. 'menu_item_font' => array(
  1487. 'priority' => 100,
  1488. 'title' => __( "Font", "megamenu" ),
  1489. 'description' => __( "The font to use for each top level menu item.", "megamenu" ),
  1490. 'settings' => array(
  1491. array(
  1492. 'title' => __( "Color", "megamenu" ),
  1493. 'type' => 'color',
  1494. 'key' => 'menu_item_link_color'
  1495. ),
  1496. array(
  1497. 'title' => __( "Size", "megamenu" ),
  1498. 'type' => 'freetext',
  1499. 'key' => 'menu_item_link_font_size',
  1500. 'validation' => 'px'
  1501. ),
  1502. array(
  1503. 'title' => __( "Family", "megamenu" ),
  1504. 'type' => 'font',
  1505. 'key' => 'menu_item_link_font'
  1506. ),
  1507. array(
  1508. 'title' => __( "Transform", "megamenu" ),
  1509. 'type' => 'transform',
  1510. 'key' => 'menu_item_link_text_transform'
  1511. ),
  1512. array(
  1513. 'title' => __( "Weight", "megamenu" ),
  1514. 'type' => 'weight',
  1515. 'key' => 'menu_item_link_weight'
  1516. ),
  1517. array(
  1518. 'title' => __( "Decoration", "megamenu" ),
  1519. 'type' => 'decoration',
  1520. 'key' => 'menu_item_link_text_decoration'
  1521. ),
  1522. array(
  1523. 'title' => __( "Align", "megamenu" ),
  1524. 'type' => 'align',
  1525. 'key' => 'menu_item_link_text_align'
  1526. ),
  1527. )
  1528. ),
  1529. 'menu_item_font_hover' => array(
  1530. 'priority' => 110,
  1531. 'title' => __( "Font (Hover)", "megamenu" ),
  1532. 'description' => __( "Set the font to use for each top level menu item (on hover).", "megamenu" ),
  1533. 'settings' => array(
  1534. array(
  1535. 'title' => __( "Color", "megamenu" ),
  1536. 'type' => 'color',
  1537. 'key' => 'menu_item_link_color_hover'
  1538. ),
  1539. array(
  1540. 'title' => __( "Weight", "megamenu" ),
  1541. 'type' => 'weight',
  1542. 'key' => 'menu_item_link_weight_hover'
  1543. ),
  1544. array(
  1545. 'title' => __( "Decoration", "megamenu" ),
  1546. 'type' => 'decoration',
  1547. 'key' => 'menu_item_link_text_decoration_hover'
  1548. ),
  1549. )
  1550. ),
  1551. 'menu_item_padding' => array(
  1552. 'priority' => 120,
  1553. 'title' => __( "Menu Item Padding", "megamenu" ),
  1554. 'description' => __( "Set the padding for each top level menu item.", "megamenu" ),
  1555. 'settings' => array(
  1556. array(
  1557. 'title' => __( "Top", "megamenu" ),
  1558. 'type' => 'freetext',
  1559. 'key' => 'menu_item_link_padding_top',
  1560. 'validation' => 'px'
  1561. ),
  1562. array(
  1563. 'title' => __( "Right", "megamenu" ),
  1564. 'type' => 'freetext',
  1565. 'key' => 'menu_item_link_padding_right',
  1566. 'validation' => 'px'
  1567. ),
  1568. array(
  1569. 'title' => __( "Bottom", "megamenu" ),
  1570. 'type' => 'freetext',
  1571. 'key' => 'menu_item_link_padding_bottom',
  1572. 'validation' => 'px'
  1573. ),
  1574. array(
  1575. 'title' => __( "Left", "megamenu" ),
  1576. 'type' => 'freetext',
  1577. 'key' => 'menu_item_link_padding_left',
  1578. 'validation' => 'px'
  1579. )
  1580. )
  1581. ),
  1582. 'menu_item_border' => array(
  1583. 'priority' => 130,
  1584. 'title' => __( "Menu Item Border", "megamenu" ),
  1585. 'description' => __( "Set the border to display on each top level menu item.", "megamenu" ),
  1586. 'settings' => array(
  1587. array(
  1588. 'title' => __( "Color", "megamenu" ),
  1589. 'type' => 'color',
  1590. 'key' => 'menu_item_border_color'
  1591. ),
  1592. array(
  1593. 'title' => __( "Top", "megamenu" ),
  1594. 'type' => 'freetext',
  1595. 'key' => 'menu_item_border_top',
  1596. 'validation' => 'px'
  1597. ),
  1598. array(
  1599. 'title' => __( "Right", "megamenu" ),
  1600. 'type' => 'freetext',
  1601. 'key' => 'menu_item_border_right',
  1602. 'validation' => 'px'
  1603. ),
  1604. array(
  1605. 'title' => __( "Bottom", "megamenu" ),
  1606. 'type' => 'freetext',
  1607. 'key' => 'menu_item_border_bottom',
  1608. 'validation' => 'px'
  1609. ),
  1610. array(
  1611. 'title' => __( "Left", "megamenu" ),
  1612. 'type' => 'freetext',
  1613. 'key' => 'menu_item_border_left',
  1614. 'validation' => 'px'
  1615. )
  1616. )
  1617. ),
  1618. 'menu_item_border_hover' => array(
  1619. 'priority' => 140,
  1620. 'title' => __( "Menu Item Border (Hover)", "megamenu" ),
  1621. 'description' => __( "Set the hover border color.", "megamenu" ),
  1622. 'settings' => array(
  1623. array(
  1624. 'title' => __( "Color", "megamenu" ),
  1625. 'type' => 'color',
  1626. 'key' => 'menu_item_border_color_hover'
  1627. )
  1628. )
  1629. ),
  1630. 'menu_item_border_radius' => array(
  1631. 'priority' => 150,
  1632. 'title' => __( "Menu Item Border Radius", "megamenu" ),
  1633. 'description' => __( "Set rounded corners for each top level menu item.", "megamenu" ),
  1634. 'settings' => array(
  1635. array(
  1636. 'title' => __( "Top Left", "megamenu" ),
  1637. 'type' => 'freetext',
  1638. 'key' => 'menu_item_link_border_radius_top_left',
  1639. 'validation' => 'px'
  1640. ),
  1641. array(
  1642. 'title' => __( "Top Right", "megamenu" ),
  1643. 'type' => 'freetext',
  1644. 'key' => 'menu_item_link_border_radius_top_right',
  1645. 'validation' => 'px'
  1646. ),
  1647. array(
  1648. 'title' => __( "Bottom Right", "megamenu" ),
  1649. 'type' => 'freetext',
  1650. 'key' => 'menu_item_link_border_radius_bottom_right',
  1651. 'validation' => 'px'
  1652. ),
  1653. array(
  1654. 'title' => __( "Bottom Left", "megamenu" ),
  1655. 'type' => 'freetext',
  1656. 'key' => 'menu_item_link_border_radius_bottom_left',
  1657. 'validation' => 'px'
  1658. )
  1659. )
  1660. ),
  1661. 'menu_item_divider' => array(
  1662. 'priority' => 160,
  1663. 'title' => __( "Menu Item Divider", "megamenu" ),
  1664. 'description' => __( "Show a small divider bar between each menu item.", "megamenu" ),
  1665. 'settings' => array(
  1666. array(
  1667. 'title' => __( "Enabled", "megamenu" ),
  1668. 'type' => 'checkbox',
  1669. 'key' => 'menu_item_divider'
  1670. ),
  1671. array(
  1672. 'title' => __( "Color", "megamenu" ),
  1673. 'type' => 'color',
  1674. 'key' => 'menu_item_divider_color'
  1675. ),
  1676. array(
  1677. 'title' => __( "Glow Opacity", "megamenu" ),
  1678. 'type' => 'freetext',
  1679. 'key' => 'menu_item_divider_glow_opacity',
  1680. 'validation' => 'float'
  1681. )
  1682. )
  1683. ),
  1684. 'menu_item_highlight' => array(
  1685. 'priority' => 170,
  1686. 'title' => __( "Highlight Current Item", "megamenu" ),
  1687. 'description' => __( "Apply the 'hover' styling to current menu items.", "megamenu" ),
  1688. 'settings' => array(
  1689. array(
  1690. 'title' => __( "Enabled", "megamenu" ),
  1691. 'type' => 'checkbox',
  1692. 'key' => 'menu_item_highlight_current'
  1693. )
  1694. )
  1695. )
  1696. )
  1697. ),
  1698. 'mega_panels' => array(
  1699. 'title' => __( "Mega Menus", "megamenu" ),
  1700. 'settings' => array(
  1701. 'panel_background' => array(
  1702. 'priority' => 10,
  1703. 'title' => __( "Panel Background", "megamenu" ),
  1704. 'description' => __( "Set a background color for a whole sub menu.", "megamenu" ),
  1705. 'settings' => array(
  1706. array(
  1707. 'title' => __( "From", "megamenu" ),
  1708. 'type' => 'color',
  1709. 'key' => 'panel_background_from'
  1710. ),
  1711. array(
  1712. 'title' => __( "Copy", "megamenu" ),
  1713. 'type' => 'copy_color',
  1714. 'key' => 'copy_color'
  1715. ),
  1716. array(
  1717. 'title' => __( "To", "megamenu" ),
  1718. 'type' => 'color',
  1719. 'key' => 'panel_background_to'
  1720. )
  1721. )
  1722. ),
  1723. 'panel_width' => array(
  1724. 'priority' => 20,
  1725. 'title' => __( "Panel Width", "megamenu" ),
  1726. 'description' => __( "Mega Panel width.", "megamenu" ),
  1727. 'info' => array(
  1728. __("A 100% wide panel will only ever be as wide as the menu itself. For a fixed sub menu width set this to a pixel value.", "megamenu"),
  1729. __("Advanced: Enter a jQuery selector to synchronize the width and position of the sub menu with existing page element (e.g. body, #container, .page).", "megamenu"),
  1730. "<a href='https://www.megamenu.com/documentation/adjust-sub-menu-width/' target='blank'>" . __("Documentation: Configuring the sub menu width", "megamenu") . '</a>'
  1731. ),
  1732. 'settings' => array(
  1733. array(
  1734. 'title' => __( "Outer Width", "megamenu" ),
  1735. 'type' => 'freetext',
  1736. 'key' => 'panel_width'
  1737. ),
  1738. array(
  1739. 'title' => __( "Inner Width", "megamenu" ),
  1740. 'type' => 'freetext',
  1741. 'key' => 'panel_inner_width'
  1742. )
  1743. )
  1744. ),
  1745. 'panel_padding' => array(
  1746. 'priority' => 30,
  1747. 'title' => __( "Panel Padding", "megamenu" ),
  1748. 'description' => __( "Set the padding for the whole sub menu. Set these values 0px if you wish your sub menu content to go edge-to-edge.", "megamenu" ),
  1749. 'settings' => array(
  1750. array(
  1751. 'title' => __( "Top", "megamenu" ),
  1752. 'type' => 'freetext',
  1753. 'key' => 'panel_padding_top',
  1754. 'validation' => 'px'
  1755. ),
  1756. array(
  1757. 'title' => __( "Right", "megamenu" ),
  1758. 'type' => 'freetext',
  1759. 'key' => 'panel_padding_right',
  1760. 'validation' => 'px'
  1761. ),
  1762. array(
  1763. 'title' => __( "Bottom", "megamenu" ),
  1764. 'type' => 'freetext',
  1765. 'key' => 'panel_padding_bottom',
  1766. 'validation' => 'px'
  1767. ),
  1768. array(
  1769. 'title' => __( "Left", "megamenu" ),
  1770. 'type' => 'freetext',
  1771. 'key' => 'panel_padding_left',
  1772. 'validation' => 'px'
  1773. )
  1774. )
  1775. ),
  1776. 'panel_border' => array(
  1777. 'priority' => 40,
  1778. 'title' => __( "Panel Border", "megamenu" ),
  1779. 'description' => __( "Set the border to display on the sub menu.", "megamenu" ),
  1780. 'settings' => array(
  1781. array(
  1782. 'title' => __( "Color", "megamenu" ),
  1783. 'type' => 'color',
  1784. 'key' => 'panel_border_color'
  1785. ),
  1786. array(
  1787. 'title' => __( "Top", "megamenu" ),
  1788. 'type' => 'freetext',
  1789. 'key' => 'panel_border_top',
  1790. 'validation' => 'px'
  1791. ),
  1792. array(
  1793. 'title' => __( "Right", "megamenu" ),
  1794. 'type' => 'freetext',
  1795. 'key' => 'panel_border_right',
  1796. 'validation' => 'px'
  1797. ),
  1798. array(
  1799. 'title' => __( "Bottom", "megamenu" ),
  1800. 'type' => 'freetext',
  1801. 'key' => 'panel_border_bottom',
  1802. 'validation' => 'px'
  1803. ),
  1804. array(
  1805. 'title' => __( "Left", "megamenu" ),
  1806. 'type' => 'freetext',
  1807. 'key' => 'panel_border_left',
  1808. 'validation' => 'px'
  1809. )
  1810. )
  1811. ),
  1812. 'panel_border_radius' => array(
  1813. 'priority' => 50,
  1814. 'title' => __( "Panel Border Radius", "megamenu" ),
  1815. 'description' => __( "Set rounded corners for the sub menu.", "megamenu" ),
  1816. 'settings' => array(
  1817. array(
  1818. 'title' => __( "Top Left", "megamenu" ),
  1819. 'type' => 'freetext',
  1820. 'key' => 'panel_border_radius_top_left',
  1821. 'validation' => 'px'
  1822. ),
  1823. array(
  1824. 'title' => __( "Top Right", "megamenu" ),
  1825. 'type' => 'freetext',
  1826. 'key' => 'panel_border_radius_top_right',
  1827. 'validation' => 'px'
  1828. ),
  1829. array(
  1830. 'title' => __( "Bottom Right", "megamenu" ),
  1831. 'type' => 'freetext',
  1832. 'key' => 'panel_border_radius_bottom_right',
  1833. 'validation' => 'px'
  1834. ),
  1835. array(
  1836. 'title' => __( "Bottom Left", "megamenu" ),
  1837. 'type' => 'freetext',
  1838. 'key' => 'panel_border_radius_bottom_left',
  1839. 'validation' => 'px'
  1840. )
  1841. )
  1842. ),
  1843. 'widget_padding' => array(
  1844. 'priority' => 60,
  1845. 'title' => __( "Panel Items Padding", "megamenu" ),
  1846. 'description' => __( "Use this to define the amount of space around each widget / set of menu items within the sub menu.", "megamenu" ),
  1847. 'settings' => array(
  1848. array(
  1849. 'title' => __( "Top", "megamenu" ),
  1850. 'type' => 'freetext',
  1851. 'key' => 'panel_widget_padding_top',
  1852. 'validation' => 'px'
  1853. ),
  1854. array(
  1855. 'title' => __( "Right", "megamenu" ),
  1856. 'type' => 'freetext',
  1857. 'key' => 'panel_widget_padding_right',
  1858. 'validation' => 'px'
  1859. ),
  1860. array(
  1861. 'title' => __( "Bottom", "megamenu" ),
  1862. 'type' => 'freetext',
  1863. 'key' => 'panel_widget_padding_bottom',
  1864. 'validation' => 'px'
  1865. ),
  1866. array(
  1867. 'title' => __( "Left", "megamenu" ),
  1868. 'type' => 'freetext',
  1869. 'key' => 'panel_widget_padding_left',
  1870. 'validation' => 'px'
  1871. )
  1872. )
  1873. ),
  1874. 'mega_menu_widgets' => array(
  1875. 'priority' => 65,
  1876. 'title' => __( "Widgets", "megamenu" ),
  1877. 'description' => '',
  1878. ),
  1879. 'widget_heading_font' => array(
  1880. 'priority' => 70,
  1881. 'title' => __( "Heading Font", "megamenu" ),
  1882. 'description' => __( "Set the font to use Widget headers in the mega menu. Tip: set this to the same style as the Second Level Menu Item Header font to keep your styling consistent.", "megamenu" ),
  1883. 'settings' => array(
  1884. array(
  1885. 'title' => __( "Color", "megamenu" ),
  1886. 'type' => 'color',
  1887. 'key' => 'panel_header_color'
  1888. ),
  1889. array(
  1890. 'title' => __( "Size", "megamenu" ),
  1891. 'type' => 'freetext',
  1892. 'key' => 'panel_header_font_size',
  1893. 'validation' => 'px'
  1894. ),
  1895. array(
  1896. 'title' => __( "Family", "megamenu" ),
  1897. 'type' => 'font',
  1898. 'key' => 'panel_header_font'
  1899. ),
  1900. array(
  1901. 'title' => __( "Transform", "megamenu" ),
  1902. 'type' => 'transform',
  1903. 'key' => 'panel_header_text_transform'
  1904. ),
  1905. array(
  1906. 'title' => __( "Weight", "megamenu" ),
  1907. 'type' => 'weight',
  1908. 'key' => 'panel_header_font_weight'
  1909. ),
  1910. array(
  1911. 'title' => __( "Decoration", "megamenu" ),
  1912. 'type' => 'decoration',
  1913. 'key' => 'panel_header_text_decoration'
  1914. ),
  1915. )
  1916. ),
  1917. 'widget_heading_padding' => array(
  1918. 'priority' => 90,
  1919. 'title' => __( "Heading Padding", "megamenu" ),
  1920. 'description' => __( "Set the padding for the widget headings.", "megamenu" ),
  1921. 'settings' => array(
  1922. array(
  1923. 'title' => __( "Top", "megamenu" ),
  1924. 'type' => 'freetext',
  1925. 'key' => 'panel_header_padding_top',
  1926. 'validation' => 'px'
  1927. ),
  1928. array(
  1929. 'title' => __( "Right", "megamenu" ),
  1930. 'type' => 'freetext',
  1931. 'key' => 'panel_header_padding_right',
  1932. 'validation' => 'px'
  1933. ),
  1934. array(
  1935. 'title' => __( "Bottom", "megamenu" ),
  1936. 'type' => 'freetext',
  1937. 'key' => 'panel_header_padding_bottom',
  1938. 'validation' => 'px'
  1939. ),
  1940. array(
  1941. 'title' => __( "Left", "megamenu" ),
  1942. 'type' => 'freetext',
  1943. 'key' => 'panel_header_padding_left',
  1944. 'validation' => 'px'
  1945. )
  1946. )
  1947. ),
  1948. 'widget_heading_margin' => array(
  1949. 'priority' => 100,
  1950. 'title' => __( "Heading Margin", "megamenu" ),
  1951. 'description' => __( "Set the margin for the widget headings.", "megamenu" ),
  1952. 'settings' => array(
  1953. array(
  1954. 'title' => __( "Top", "megamenu" ),
  1955. 'type' => 'freetext',
  1956. 'key' => 'panel_header_margin_top',
  1957. 'validation' => 'px'
  1958. ),
  1959. array(
  1960. 'title' => __( "Right", "megamenu" ),
  1961. 'type' => 'freetext',
  1962. 'key' => 'panel_header_margin_right',
  1963. 'validation' => 'px'
  1964. ),
  1965. array(
  1966. 'title' => __( "Bottom", "megamenu" ),
  1967. 'type' => 'freetext',
  1968. 'key' => 'panel_header_margin_bottom',
  1969. 'validation' => 'px'
  1970. ),
  1971. array(
  1972. 'title' => __( "Left", "megamenu" ),
  1973. 'type' => 'freetext',
  1974. 'key' => 'panel_header_margin_left',
  1975. 'validation' => 'px'
  1976. )
  1977. )
  1978. ),
  1979. 'widget_header_border' => array(
  1980. 'priority' => 110,
  1981. 'title' => __( "Header Border", "megamenu" ),
  1982. 'description' => __( "Set the border for the widget headings.", "megamenu" ),
  1983. 'settings' => array(
  1984. array(
  1985. 'title' => __( "Color", "megamenu" ),
  1986. 'type' => 'color',
  1987. 'key' => 'panel_header_border_color'
  1988. ),
  1989. array(
  1990. 'title' => __( "Top", "megamenu" ),
  1991. 'type' => 'freetext',
  1992. 'key' => 'panel_header_border_top',
  1993. 'validation' => 'px'
  1994. ),
  1995. array(
  1996. 'title' => __( "Right", "megamenu" ),
  1997. 'type' => 'freetext',
  1998. 'key' => 'panel_header_border_right',
  1999. 'validation' => 'px'
  2000. ),
  2001. array(
  2002. 'title' => __( "Bottom", "megamenu" ),
  2003. 'type' => 'freetext',
  2004. 'key' => 'panel_header_border_bottom',
  2005. 'validation' => 'px'
  2006. ),
  2007. array(
  2008. 'title' => __( "Left", "megamenu" ),
  2009. 'type' => 'freetext',
  2010. 'key' => 'panel_header_border_left',
  2011. 'validation' => 'px'
  2012. )
  2013. )
  2014. ),
  2015. 'widget_content_font' => array(
  2016. 'priority' => 115,
  2017. 'title' => __( "Content Font", "megamenu" ),
  2018. 'description' => __( "Set the font to use for panel contents.", "megamenu" ),
  2019. 'settings' => array(
  2020. array(
  2021. 'title' => __( "Color", "megamenu" ),
  2022. 'type' => 'color',
  2023. 'key' => 'panel_font_color'
  2024. ),
  2025. array(
  2026. 'title' => __( "Size", "megamenu" ),
  2027. 'type' => 'freetext',
  2028. 'key' => 'panel_font_size',
  2029. 'validation' => 'px'
  2030. ),
  2031. array(
  2032. 'title' => __( "Family", "megamenu" ),
  2033. 'type' => 'font',
  2034. 'key' => 'panel_font_family'
  2035. )
  2036. )
  2037. ),
  2038. 'second_level_menu_items' => array(
  2039. 'priority' => 120,
  2040. 'title' => __( "Second Level Menu Items", "megamenu" ),
  2041. 'description' => '',
  2042. ),
  2043. 'second_level_font' => array(
  2044. 'priority' => 130,
  2045. 'title' => __( "Font", "megamenu" ),
  2046. 'description' => __( "Set the font for second level menu items when they're displayed in a Mega Menu.", "megamenu" ),
  2047. 'settings' => array(
  2048. array(
  2049. 'title' => __( "Color", "megamenu" ),
  2050. 'type' => 'color',
  2051. 'key' => 'panel_second_level_font_color'
  2052. ),
  2053. array(
  2054. 'title' => __( "Size", "megamenu" ),
  2055. 'type' => 'freetext',
  2056. 'key' => 'panel_second_level_font_size',
  2057. 'validation' => 'px'
  2058. ),
  2059. array(
  2060. 'title' => __( "Family", "megamenu" ),
  2061. 'type' => 'font',
  2062. 'key' => 'panel_second_level_font'
  2063. ),
  2064. array(
  2065. 'title' => __( "Transform", "megamenu" ),
  2066. 'type' => 'transform',
  2067. 'key' => 'panel_second_level_text_transform'
  2068. ),
  2069. array(
  2070. 'title' => __( "Weight", "megamenu" ),
  2071. 'type' => 'weight',
  2072. 'key' => 'panel_second_level_font_weight'
  2073. ),
  2074. array(
  2075. 'title' => __( "Decoration", "megamenu" ),
  2076. 'type' => 'decoration',
  2077. 'key' => 'panel_second_level_text_decoration'
  2078. ),
  2079. )
  2080. ),
  2081. 'second_level_font_hover' => array(
  2082. 'priority' => 140,
  2083. 'title' => __( "Font (Hover)", "megamenu" ),
  2084. 'description' => __( "Set the font style on hover.", "megamenu" ),
  2085. 'settings' => array(
  2086. array(
  2087. 'title' => __( "Color", "megamenu" ),
  2088. 'type' => 'color',
  2089. 'key' => 'panel_second_level_font_color_hover'
  2090. ),
  2091. array(
  2092. 'title' => __( "Weight", "megamenu" ),
  2093. 'type' => 'weight',
  2094. 'key' => 'panel_second_level_font_weight_hover'
  2095. ),
  2096. array(
  2097. 'title' => __( "Decoration", "megamenu" ),
  2098. 'type' => 'decoration',
  2099. 'key' => 'panel_second_level_text_decoration_hover'
  2100. ),
  2101. )
  2102. ),
  2103. 'second_level_background_hover' => array(
  2104. 'priority' => 150,
  2105. 'title' => __( "Background (Hover)", "megamenu" ),
  2106. 'description' => __( "Set the background hover color for second level menu items.", "megamenu" ),
  2107. 'settings' => array(
  2108. array(
  2109. 'title' => __( "From", "megamenu" ),
  2110. 'type' => 'color',
  2111. 'key' => 'panel_second_level_background_hover_from'
  2112. ),
  2113. array(
  2114. 'title' => __( "Copy", "megamenu" ),
  2115. 'type' => 'copy_color',
  2116. 'key' => 'copy_color'
  2117. ),
  2118. array(
  2119. 'title' => __( "To", "megamenu" ),
  2120. 'type' => 'color',
  2121. 'key' => 'panel_second_level_background_hover_to'
  2122. )
  2123. )
  2124. ),
  2125. 'second_level_padding' => array(
  2126. 'priority' => 160,
  2127. 'title' => __( "Padding", "megamenu" ),
  2128. 'description' => __( "Set the padding for the second level menu items.", "megamenu" ),
  2129. 'settings' => array(
  2130. array(
  2131. 'title' => __( "Top", "megamenu" ),
  2132. 'type' => 'freetext',
  2133. 'key' => 'panel_second_level_padding_top',
  2134. 'validation' => 'px'
  2135. ),
  2136. array(
  2137. 'title' => __( "Right", "megamenu" ),
  2138. 'type' => 'freetext',
  2139. 'key' => 'panel_second_level_padding_right',
  2140. 'validation' => 'px'
  2141. ),
  2142. array(
  2143. 'title' => __( "Bottom", "megamenu" ),
  2144. 'type' => 'freetext',
  2145. 'key' => 'panel_second_level_padding_bottom',
  2146. 'validation' => 'px'
  2147. ),
  2148. array(
  2149. 'title' => __( "Left", "megamenu" ),
  2150. 'type' => 'freetext',
  2151. 'key' => 'panel_second_level_padding_left',
  2152. 'validation' => 'px'
  2153. )
  2154. )
  2155. ),
  2156. 'second_level_margin' => array(
  2157. 'priority' => 170,
  2158. 'title' => __( "Margin", "megamenu" ),
  2159. 'description' => __( "Set the margin for the second level menu items.", "megamenu" ),
  2160. 'settings' => array(
  2161. array(
  2162. 'title' => __( "Top", "megamenu" ),
  2163. 'type' => 'freetext',
  2164. 'key' => 'panel_second_level_margin_top',
  2165. 'validation' => 'px'
  2166. ),
  2167. array(
  2168. 'title' => __( "Right", "megamenu" ),
  2169. 'type' => 'freetext',
  2170. 'key' => 'panel_second_level_margin_right',
  2171. 'validation' => 'px'
  2172. ),
  2173. array(
  2174. 'title' => __( "Bottom", "megamenu" ),
  2175. 'type' => 'freetext',
  2176. 'key' => 'panel_second_level_margin_bottom',
  2177. 'validation' => 'px'
  2178. ),
  2179. array(
  2180. 'title' => __( "Left", "megamenu" ),
  2181. 'type' => 'freetext',
  2182. 'key' => 'panel_second_level_margin_left',
  2183. 'validation' => 'px'
  2184. )
  2185. )
  2186. ),
  2187. 'second_level_border' => array(
  2188. 'priority' => 180,
  2189. 'title' => __( "Border", "megamenu" ),
  2190. 'description' => __( "Set the border for the second level menu items.", "megamenu" ),
  2191. 'settings' => array(
  2192. array(
  2193. 'title' => __( "Color", "megamenu" ),
  2194. 'type' => 'color',
  2195. 'key' => 'panel_second_level_border_color'
  2196. ),
  2197. array(
  2198. 'title' => __( "Top", "megamenu" ),
  2199. 'type' => 'freetext',
  2200. 'key' => 'panel_second_level_border_top',
  2201. 'validation' => 'px'
  2202. ),
  2203. array(
  2204. 'title' => __( "Right", "megamenu" ),
  2205. 'type' => 'freetext',
  2206. 'key' => 'panel_second_level_border_right',
  2207. 'validation' => 'px'
  2208. ),
  2209. array(
  2210. 'title' => __( "Bottom", "megamenu" ),
  2211. 'type' => 'freetext',
  2212. 'key' => 'panel_second_level_border_bottom',
  2213. 'validation' => 'px'
  2214. ),
  2215. array(
  2216. 'title' => __( "Left", "megamenu" ),
  2217. 'type' => 'freetext',
  2218. 'key' => 'panel_second_level_border_left',
  2219. 'validation' => 'px'
  2220. )
  2221. )
  2222. ),
  2223. 'third_level_menu_items' => array(
  2224. 'priority' => 190,
  2225. 'title' => __( "Third Level Menu Items", "megamenu" ),
  2226. 'description' => '',
  2227. ),
  2228. 'third_level_font' => array(
  2229. 'priority' => 200,
  2230. 'title' => __( "Font", "megamenu" ),
  2231. 'description' => __( "Set the font for third level menu items when they're displayed in a Mega Menu.", "megamenu" ),
  2232. 'settings' => array(
  2233. array(
  2234. 'title' => __( "Color", "megamenu" ),
  2235. 'type' => 'color',
  2236. 'key' => 'panel_third_level_font_color'
  2237. ),
  2238. array(
  2239. 'title' => __( "Size", "megamenu" ),
  2240. 'type' => 'freetext',
  2241. 'key' => 'panel_third_level_font_size',
  2242. 'validation' => 'px'
  2243. ),
  2244. array(
  2245. 'title' => __( "Family", "megamenu" ),
  2246. 'type' => 'font',
  2247. 'key' => 'panel_third_level_font'
  2248. ),
  2249. array(
  2250. 'title' => __( "Transform", "megamenu" ),
  2251. 'type' => 'transform',
  2252. 'key' => 'panel_third_level_text_transform'
  2253. ),
  2254. array(
  2255. 'title' => __( "Weight", "megamenu" ),
  2256. 'type' => 'weight',
  2257. 'key' => 'panel_third_level_font_weight'
  2258. ),
  2259. array(
  2260. 'title' => __( "Decoration", "megamenu" ),
  2261. 'type' => 'decoration',
  2262. 'key' => 'panel_third_level_text_decoration'
  2263. ),
  2264. )
  2265. ),
  2266. 'third_level_font_hover' => array(
  2267. 'priority' => 210,
  2268. 'title' => __( "Font (Hover)", "megamenu" ),
  2269. 'description' => __( "Set the font style on hover.", "megamenu" ),
  2270. 'settings' => array(
  2271. array(
  2272. 'title' => __( "Color", "megamenu" ),
  2273. 'type' => 'color',
  2274. 'key' => 'panel_third_level_font_color_hover'
  2275. ),
  2276. array(
  2277. 'title' => __( "Weight", "megamenu" ),
  2278. 'type' => 'weight',
  2279. 'key' => 'panel_third_level_font_weight_hover'
  2280. ),
  2281. array(
  2282. 'title' => __( "Decoration", "megamenu" ),
  2283. 'type' => 'decoration',
  2284. 'key' => 'panel_third_level_text_decoration_hover'
  2285. ),
  2286. )
  2287. ),
  2288. 'third_level_background_hover' => array(
  2289. 'priority' => 220,
  2290. 'title' => __( "Background (Hover)", "megamenu" ),
  2291. 'description' => __( "Set the background hover color for third level menu items.", "megamenu" ),
  2292. 'settings' => array(
  2293. array(
  2294. 'title' => __( "From", "megamenu" ),
  2295. 'type' => 'color',
  2296. 'key' => 'panel_third_level_background_hover_from'
  2297. ),
  2298. array(
  2299. 'title' => __( "Copy", "megamenu" ),
  2300. 'type' => 'copy_color',
  2301. 'key' => 'copy_color'
  2302. ),
  2303. array(
  2304. 'title' => __( "To", "megamenu" ),
  2305. 'type' => 'color',
  2306. 'key' => 'panel_third_level_background_hover_to'
  2307. )
  2308. )
  2309. ),
  2310. 'third_level_padding' => array(
  2311. 'priority' => 230,
  2312. 'title' => __( "Padding", "megamenu" ),
  2313. 'description' => __( "Set the padding for the third level menu items.", "megamenu" ),
  2314. 'settings' => array(
  2315. array(
  2316. 'title' => __( "Top", "megamenu" ),
  2317. 'type' => 'freetext',
  2318. 'key' => 'panel_third_level_padding_top',
  2319. 'validation' => 'px'
  2320. ),
  2321. array(
  2322. 'title' => __( "Right", "megamenu" ),
  2323. 'type' => 'freetext',
  2324. 'key' => 'panel_third_level_padding_right',
  2325. 'validation' => 'px'
  2326. ),
  2327. array(
  2328. 'title' => __( "Bottom", "megamenu" ),
  2329. 'type' => 'freetext',
  2330. 'key' => 'panel_third_level_padding_bottom',
  2331. 'validation' => 'px'
  2332. ),
  2333. array(
  2334. 'title' => __( "Left", "megamenu" ),
  2335. 'type' => 'freetext',
  2336. 'key' => 'panel_third_level_padding_left',
  2337. 'validation' => 'px'
  2338. )
  2339. )
  2340. )
  2341. )
  2342. ),
  2343. 'flyout_menus' => array(
  2344. 'title' => __( "Flyout Menus", "megamenu"),
  2345. 'settings' => array(
  2346. 'flyout_menu_background' => array(
  2347. 'priority' => 10,
  2348. 'title' => __( "Sub Menu Background", "megamenu" ),
  2349. 'description' => __( "Set the background color for the flyout menu.", "megamenu" ),
  2350. 'settings' => array(
  2351. array(
  2352. 'title' => __( "From", "megamenu" ),
  2353. 'type' => 'color',
  2354. 'key' => 'flyout_menu_background_from'
  2355. ),
  2356. array(
  2357. 'title' => __( "Copy", "megamenu" ),
  2358. 'type' => 'copy_color',
  2359. 'key' => 'copy_color'
  2360. ),
  2361. array(
  2362. 'title' => __( "To", "megamenu" ),
  2363. 'type' => 'color',
  2364. 'key' => 'flyout_menu_background_to'
  2365. )
  2366. )
  2367. ),
  2368. 'flyout_menu_width' => array(
  2369. 'priority' => 20,
  2370. 'title' => __( "Sub Menu Width", "megamenu" ),
  2371. 'description' => __( "The width of each flyout menu. This must be a fixed pixel value.", "megamenu" ),
  2372. 'info' => array(
  2373. __( "Set this value to the width of your longest menu item title to stop menu items wrapping onto 2 lines.", "megamenu" ),
  2374. __( "Experimental: Set this value to 'auto' to use a flexible width.", "megamenu" )
  2375. ),
  2376. 'settings' => array(
  2377. array(
  2378. 'title' => "",
  2379. 'type' => 'freetext',
  2380. 'key' => 'flyout_width',
  2381. 'validation' => 'px'
  2382. )
  2383. )
  2384. ),
  2385. 'flyout_menu_padding' => array(
  2386. 'priority' => 30,
  2387. 'title' => __( "Sub Menu Padding", "megamenu" ),
  2388. 'description' => __( "Set the padding for the whole flyout menu.", "megamenu" ),
  2389. 'info' => array( __( "Only suitable for single level flyout menus. If you're using multi level flyout menus set these values to 0px.", "megamenu" ) ),
  2390. 'settings' => array(
  2391. array(
  2392. 'title' => __( "Top", "megamenu" ),
  2393. 'type' => 'freetext',
  2394. 'key' => 'flyout_padding_top',
  2395. 'validation' => 'px'
  2396. ),
  2397. array(
  2398. 'title' => __( "Right", "megamenu" ),
  2399. 'type' => 'freetext',
  2400. 'key' => 'flyout_padding_right',
  2401. 'validation' => 'px'
  2402. ),
  2403. array(
  2404. 'title' => __( "Bottom", "megamenu" ),
  2405. 'type' => 'freetext',
  2406. 'key' => 'flyout_padding_bottom',
  2407. 'validation' => 'px'
  2408. ),
  2409. array(
  2410. 'title' => __( "Left", "megamenu" ),
  2411. 'type' => 'freetext',
  2412. 'key' => 'flyout_padding_left',
  2413. 'validation' => 'px'
  2414. )
  2415. )
  2416. ),
  2417. 'flyout_menu_border' => array(
  2418. 'priority' => 40,
  2419. 'title' => __( "Sub Menu Border", "megamenu" ),
  2420. 'description' => __( "Set the border for the flyout menu.", "megamenu" ),
  2421. 'settings' => array(
  2422. array(
  2423. 'title' => __( "Color", "megamenu" ),
  2424. 'type' => 'color',
  2425. 'key' => 'flyout_border_color'
  2426. ),
  2427. array(
  2428. 'title' => __( "Top", "megamenu" ),
  2429. 'type' => 'freetext',
  2430. 'key' => 'flyout_border_top',
  2431. 'validation' => 'px'
  2432. ),
  2433. array(
  2434. 'title' => __( "Right", "megamenu" ),
  2435. 'type' => 'freetext',
  2436. 'key' => 'flyout_border_right',
  2437. 'validation' => 'px'
  2438. ),
  2439. array(
  2440. 'title' => __( "Bottom", "megamenu" ),
  2441. 'type' => 'freetext',
  2442. 'key' => 'flyout_border_bottom',
  2443. 'validation' => 'px'
  2444. ),
  2445. array(
  2446. 'title' => __( "Left", "megamenu" ),
  2447. 'type' => 'freetext',
  2448. 'key' => 'flyout_border_left',
  2449. 'validation' => 'px'
  2450. )
  2451. )
  2452. ),
  2453. 'flyout_menu_border_radius' => array(
  2454. 'priority' => 50,
  2455. 'title' => __( "Sub Menu Border Radius", "megamenu" ),
  2456. 'description' => __( "Set rounded corners for flyout menus. Rounded corners will be applied to all flyout menu levels.", "megamenu" ),
  2457. 'settings' => array(
  2458. array(
  2459. 'title' => __( "Top Left", "megamenu" ),
  2460. 'type' => 'freetext',
  2461. 'key' => 'flyout_border_radius_top_left',
  2462. 'validation' => 'px'
  2463. ),
  2464. array(
  2465. 'title' => __( "Top Right", "megamenu" ),
  2466. 'type' => 'freetext',
  2467. 'key' => 'flyout_border_radius_top_right',
  2468. 'validation' => 'px'
  2469. ),
  2470. array(
  2471. 'title' => __( "Bottom Right", "megamenu" ),
  2472. 'type' => 'freetext',
  2473. 'key' => 'flyout_border_radius_bottom_right',
  2474. 'validation' => 'px'
  2475. ),
  2476. array(
  2477. 'title' => __( "Bottom Left", "megamenu" ),
  2478. 'type' => 'freetext',
  2479. 'key' => 'flyout_border_radius_bottom_left',
  2480. 'validation' => 'px'
  2481. )
  2482. )
  2483. ),
  2484. 'flyout_menu_item_background' => array(
  2485. 'priority' => 60,
  2486. 'title' => __( "Menu Item Background", "megamenu" ),
  2487. 'description' => __( "Set the background color for a flyout menu item.", "megamenu" ),
  2488. 'settings' => array(
  2489. array(
  2490. 'title' => __( "From", "megamenu" ),
  2491. 'type' => 'color',
  2492. 'key' => 'flyout_background_from'
  2493. ),
  2494. array(
  2495. 'title' => __( "Copy", "megamenu" ),
  2496. 'type' => 'copy_color',
  2497. 'key' => 'copy_color'
  2498. ),
  2499. array(
  2500. 'title' => __( "To", "megamenu" ),
  2501. 'type' => 'color',
  2502. 'key' => 'flyout_background_to'
  2503. )
  2504. )
  2505. ),
  2506. 'flyout_menu_item_background_hover' => array(
  2507. 'priority' => 70,
  2508. 'title' => __( "Menu Item Background (Hover)", "megamenu" ),
  2509. 'description' => __( "Set the background color for a flyout menu item (on hover).", "megamenu" ),
  2510. 'settings' => array(
  2511. array(
  2512. 'title' => __( "From", "megamenu" ),
  2513. 'type' => 'color',
  2514. 'key' => 'flyout_background_hover_from'
  2515. ),
  2516. array(
  2517. 'title' => __( "Copy", "megamenu" ),
  2518. 'type' => 'copy_color',
  2519. 'key' => 'copy_color'
  2520. ),
  2521. array(
  2522. 'title' => __( "To", "megamenu" ),
  2523. 'type' => 'color',
  2524. 'key' => 'flyout_background_hover_to'
  2525. )
  2526. )
  2527. ),
  2528. 'flyout_menu_item_height' => array(
  2529. 'priority' => 80,
  2530. 'title' => __( "Menu Item Height", "megamenu" ),
  2531. 'description' => __( "The height of each flyout menu item.", "megamenu" ),
  2532. 'settings' => array(
  2533. array(
  2534. 'title' => "",
  2535. 'type' => 'freetext',
  2536. 'key' => 'flyout_link_height',
  2537. 'validation' => 'px'
  2538. )
  2539. )
  2540. ),
  2541. 'flyout_menu_item_padding' => array(
  2542. 'priority' => 90,
  2543. 'title' => __( "Menu Item Padding", "megamenu" ),
  2544. 'description' => __( "Set the padding for each flyout menu item.", "megamenu" ),
  2545. 'settings' => array(
  2546. array(
  2547. 'title' => __( "Top", "megamenu" ),
  2548. 'type' => 'freetext',
  2549. 'key' => 'flyout_link_padding_top',
  2550. 'validation' => 'px'
  2551. ),
  2552. array(
  2553. 'title' => __( "Right", "megamenu" ),
  2554. 'type' => 'freetext',
  2555. 'key' => 'flyout_link_padding_right',
  2556. 'validation' => 'px'
  2557. ),
  2558. array(
  2559. 'title' => __( "Bottom", "megamenu" ),
  2560. 'type' => 'freetext',
  2561. 'key' => 'flyout_link_padding_bottom',
  2562. 'validation' => 'px'
  2563. ),
  2564. array(
  2565. 'title' => __( "Left", "megamenu" ),
  2566. 'type' => 'freetext',
  2567. 'key' => 'flyout_link_padding_left',
  2568. 'validation' => 'px'
  2569. )
  2570. )
  2571. ),
  2572. 'flyout_menu_item_font' => array(
  2573. 'priority' => 100,
  2574. 'title' => __( "Menu Item Font", "megamenu" ),
  2575. 'description' => __( "Set the font for the flyout menu items.", "megamenu" ),
  2576. 'settings' => array(
  2577. array(
  2578. 'title' => __( "Color", "megamenu" ),
  2579. 'type' => 'color',
  2580. 'key' => 'flyout_link_color'
  2581. ),
  2582. array(
  2583. 'title' => __( "Size", "megamenu" ),
  2584. 'type' => 'freetext',
  2585. 'key' => 'flyout_link_size',
  2586. 'validation' => 'px'
  2587. ),
  2588. array(
  2589. 'title' => __( "Family", "megamenu" ),
  2590. 'type' => 'font',
  2591. 'key' => 'flyout_link_family'
  2592. ),
  2593. array(
  2594. 'title' => __( "Transform", "megamenu" ),
  2595. 'type' => 'transform',
  2596. 'key' => 'flyout_link_text_transform'
  2597. ),
  2598. array(
  2599. 'title' => __( "Weight", "megamenu" ),
  2600. 'type' => 'weight',
  2601. 'key' => 'flyout_link_weight'
  2602. ),
  2603. array(
  2604. 'title' => __( "Decoration", "megamenu" ),
  2605. 'type' => 'decoration',
  2606. 'key' => 'flyout_link_text_decoration'
  2607. ),
  2608. )
  2609. ),
  2610. 'flyout_menu_item_font_hover' => array(
  2611. 'priority' => 110,
  2612. 'title' => __( "Menu Item Font (Hover)", "megamenu" ),
  2613. 'description' => __( "Set the font for the flyout menu items.", "megamenu" ),
  2614. 'settings' => array(
  2615. array(
  2616. 'title' => __( "Color", "megamenu" ),
  2617. 'type' => 'color',
  2618. 'key' => 'flyout_link_color_hover'
  2619. ),
  2620. array(
  2621. 'title' => __( "Weight", "megamenu" ),
  2622. 'type' => 'weight',
  2623. 'key' => 'flyout_link_weight_hover'
  2624. ),
  2625. array(
  2626. 'title' => __( "Decoration", "megamenu" ),
  2627. 'type' => 'decoration',
  2628. 'key' => 'flyout_link_text_decoration_hover'
  2629. ),
  2630. )
  2631. ),
  2632. 'flyout_menu_item_divider' => array(
  2633. 'priority' => 120,
  2634. 'title' => __( "Menu Item Divider", "megamenu" ),
  2635. 'description' => __( "Show a line divider below each menu item.", "megamenu" ),
  2636. 'settings' => array(
  2637. array(
  2638. 'title' => __( "Enabled", "megamenu" ),
  2639. 'type' => 'checkbox',
  2640. 'key' => 'flyout_menu_item_divider'
  2641. ),
  2642. array(
  2643. 'title' => __( "Color", "megamenu" ),
  2644. 'type' => 'color',
  2645. 'key' => 'flyout_menu_item_divider_color'
  2646. )
  2647. )
  2648. ),
  2649. )
  2650. ),
  2651. 'mobile_menu' => array(
  2652. 'title' => __( "Mobile Menu", "megamenu" ),
  2653. 'settings' => array(
  2654. 'mobile_toggle_bar' => array(
  2655. 'priority' => 5,
  2656. 'title' => __( "Mobile Toggle Bar", "megamenu" ),
  2657. 'description' => '',
  2658. ),
  2659. 'toggle_bar_background' => array(
  2660. 'priority' => 20,
  2661. 'title' => __( "Toggle Bar Background", "megamenu" ),
  2662. 'description' => __( "Set the background color for the mobile menu toggle bar.", "megamenu" ),
  2663. 'info' => array(
  2664. __("Don't forget to update the Menu toggle block text and icon color in the Toggle Bar Designer above!", "megamenu"),
  2665. ),
  2666. 'settings' => array(
  2667. array(
  2668. 'title' => __( "From", "megamenu" ),
  2669. 'type' => 'color',
  2670. 'key' => 'toggle_background_from'
  2671. ),
  2672. array(
  2673. 'title' => __( "Copy", "megamenu" ),
  2674. 'type' => 'copy_color',
  2675. 'key' => 'copy_color'
  2676. ),
  2677. array(
  2678. 'title' => __( "To", "megamenu" ),
  2679. 'type' => 'color',
  2680. 'key' => 'toggle_background_to'
  2681. )
  2682. )
  2683. ),
  2684. 'toggle_bar_height' => array(
  2685. 'priority' => 25,
  2686. 'title' => __( "Toggle Bar Height", "megamenu" ),
  2687. 'description' => __( "Set the height of the mobile menu toggle bar.", "megamenu" ),
  2688. 'settings' => array(
  2689. array(
  2690. 'title' => "",
  2691. 'type' => 'freetext',
  2692. 'key' => 'toggle_bar_height'
  2693. )
  2694. )
  2695. ),
  2696. 'disable_mobile_toggle' => array(
  2697. 'priority' => 28,
  2698. 'title' => __( "Disable Mobile Toggle Bar", "megamenu" ),
  2699. 'description' => __( "Hide the toggle bar and display the menu in it's open state by default.", "megamenu" ),
  2700. 'settings' => array(
  2701. array(
  2702. 'title' => "",
  2703. 'type' => 'checkbox',
  2704. 'key' => 'disable_mobile_toggle'
  2705. )
  2706. )
  2707. ),
  2708. 'responsive_breakpoint' => array(
  2709. 'priority' => 3,
  2710. 'title' => __( "Responsive Breakpoint", "megamenu" ),
  2711. 'description' => __( "The menu will be converted to a mobile menu when the browser width is below this value.", "megamenu" ),
  2712. 'settings' => array(
  2713. array(
  2714. 'title' => "",
  2715. 'type' => 'freetext',
  2716. 'key' => 'responsive_breakpoint',
  2717. 'validation' => 'px'
  2718. )
  2719. ),
  2720. ),
  2721. 'responsive_breakpoint_disabled' => array(
  2722. 'priority' => 4,
  2723. 'title' => __( "The 'Responsive Breakpoint' option has been set to 0px. The desktop version of the menu will be displayed for all browsers (regardless of the browser width), so the following options are disabled.", "megamenu" ),
  2724. 'description' => '',
  2725. ),
  2726. 'mobile_toggle_disabled' => array(
  2727. 'priority' => 5,
  2728. 'title' => __( "The 'Disable Mobile Toggle Bar' option has been enabled. The following options are disabled as the mobile toggle bar will not be displayed.", "megamenu" ),
  2729. 'description' => '',
  2730. ),
  2731. 'mobile_top_level_menu_items' => array(
  2732. 'priority' => 33,
  2733. 'title' => __( "Mobile Sub Menu", "megamenu" ),
  2734. 'description' => '',
  2735. ),
  2736. 'mobile_menu_overlay' => array(
  2737. 'priority' => 34,
  2738. 'title' => __( "Sub Menu - Overlay Content", "megamenu" ),
  2739. 'description' => __( "If enabled, the mobile sub menu will overlay the page content (instead of pushing the page content down)", "megamenu" ),
  2740. 'settings' => array(
  2741. array(
  2742. 'title' => "",
  2743. 'type' => 'checkbox',
  2744. 'key' => 'mobile_menu_overlay'
  2745. )
  2746. )
  2747. ),
  2748. 'mobile_menu_force_width' => array(
  2749. 'priority' => 35,
  2750. 'title' => __( "Sub Menu - Force Full Width", "megamenu" ),
  2751. 'description' => __( "Experimental: If enabled, the mobile sub menu will match the width and position on the given page element (rather than being limited to the width of the toggle bar). For a full width sub menu, leave the 'Selector' value set to 'body'.", "megamenu" ),
  2752. 'settings' => array(
  2753. array(
  2754. 'title' => "Enabled",
  2755. 'type' => 'checkbox',
  2756. 'key' => 'mobile_menu_force_width'
  2757. ),
  2758. array(
  2759. 'title' => __( "Selector", "megamenu" ),
  2760. 'type' => 'freetext',
  2761. 'key' => 'mobile_menu_force_width_selector'
  2762. ),
  2763. )
  2764. ),
  2765. 'mobile_menu_item_height' => array(
  2766. 'priority' => 38,
  2767. 'title' => __( "Menu Item Height", "megamenu" ),
  2768. 'description' => __( "Height of each top level item in the mobile menu.", "megamenu" ),
  2769. 'settings' => array(
  2770. array(
  2771. 'title' => "",
  2772. 'type' => 'freetext',
  2773. 'key' => 'mobile_menu_item_height'
  2774. )
  2775. )
  2776. ),
  2777. 'mobile_background' => array(
  2778. 'priority' => 40,
  2779. 'title' => __( "Menu Background", "megamenu" ),
  2780. 'description' => __( "The background color for the mobile menu.", "megamenu" ),
  2781. 'settings' => array(
  2782. array(
  2783. 'title' => __( "From", "megamenu" ),
  2784. 'type' => 'color',
  2785. 'key' => 'mobile_background_from'
  2786. ),
  2787. array(
  2788. 'title' => __( "Copy", "megamenu" ),
  2789. 'type' => 'copy_color',
  2790. 'key' => 'copy_color'
  2791. ),
  2792. array(
  2793. 'title' => __( "To", "megamenu" ),
  2794. 'type' => 'color',
  2795. 'key' => 'mobile_background_to'
  2796. )
  2797. )
  2798. ),
  2799. 'mobile_background_hover' => array(
  2800. 'priority' => 45,
  2801. 'title' => __( "Menu Item Background (Hover)", "megamenu" ),
  2802. 'description' => __( "The background color for each top level item the mobile menu on hover (or when the menu item is clicked/active).", "megamenu" ),
  2803. 'settings' => array(
  2804. array(
  2805. 'title' => __( "From", "megamenu" ),
  2806. 'type' => 'color',
  2807. 'key' => 'mobile_menu_item_background_hover_from'
  2808. ),
  2809. array(
  2810. 'title' => __( "Copy", "megamenu" ),
  2811. 'type' => 'copy_color',
  2812. 'key' => 'copy_color'
  2813. ),
  2814. array(
  2815. 'title' => __( "To", "megamenu" ),
  2816. 'type' => 'color',
  2817. 'key' => 'mobile_menu_item_background_hover_to'
  2818. )
  2819. )
  2820. ),
  2821. 'mobile_menu_item_font' => array(
  2822. 'priority' => 50,
  2823. 'title' => __( "Font", "megamenu" ),
  2824. 'description' => __( "The font to use for each top level menu item in the mobile menu.", "megamenu" ),
  2825. 'settings' => array(
  2826. array(
  2827. 'title' => __( "Color", "megamenu" ),
  2828. 'type' => 'color',
  2829. 'key' => 'mobile_menu_item_link_color'
  2830. ),
  2831. array(
  2832. 'title' => __( "Size", "megamenu" ),
  2833. 'type' => 'freetext',
  2834. 'key' => 'mobile_menu_item_link_font_size',
  2835. 'validation' => 'px'
  2836. ),
  2837. array(
  2838. 'title' => __( "Align", "megamenu" ),
  2839. 'type' => 'align',
  2840. 'key' => 'mobile_menu_item_link_text_align'
  2841. ),
  2842. )
  2843. ),
  2844. 'mobile_menu_item_font_hover' => array(
  2845. 'priority' => 55,
  2846. 'title' => __( "Font (Hover)", "megamenu" ),
  2847. 'description' => __( "The font color to use for each top level menu item in the mobile menu on hover (or when the menu item is clicked/active).", "megamenu" ),
  2848. 'settings' => array(
  2849. array(
  2850. 'title' => __( "Color", "megamenu" ),
  2851. 'type' => 'color',
  2852. 'key' => 'mobile_menu_item_link_color_hover'
  2853. )
  2854. )
  2855. ),
  2856. 'mobile_mega_menus' => array(
  2857. 'priority' => 60,
  2858. 'title' => __( "Mega Menus", "megamenu" ),
  2859. 'description' => '',
  2860. ),
  2861. 'mobile_columns' => array(
  2862. 'priority' => 65,
  2863. 'title' => __( "Mega Menu Columns", "megamenu" ),
  2864. 'description' => __( "Collapse mega menu content into this many columns on mobile.", "megamenu" ),
  2865. 'settings' => array(
  2866. array(
  2867. 'title' => "",
  2868. 'type' => 'mobile_columns',
  2869. 'key' => 'mobile_columns'
  2870. )
  2871. )
  2872. )
  2873. )
  2874. ),
  2875. 'custom_styling' => array(
  2876. 'title' => __( "Custom Styling", "megamenu"),
  2877. 'settings' => array(
  2878. 'custom_styling' => array(
  2879. 'priority' => 40,
  2880. 'title' => __( "CSS Editor", "megamenu" ),
  2881. 'description' => __( "Define any custom CSS you wish to add to menus using this theme. You can use standard CSS or SCSS.", "megamenu"),
  2882. 'settings' => array(
  2883. array(
  2884. 'title' => "",
  2885. 'type' => 'textarea',
  2886. 'key' => 'custom_css'
  2887. )
  2888. )
  2889. )
  2890. )
  2891. )
  2892. ) );
  2893. echo "<h2 class='nav-tab-wrapper'>";
  2894. $is_first = true;
  2895. foreach ( $settings as $section_id => $section ) {
  2896. if ($is_first) {
  2897. $active = 'nav-tab-active ';
  2898. $is_first = false;
  2899. } else {
  2900. $active = '';
  2901. }
  2902. echo "<a class='mega-tab nav-tab {$active}' data-tab='mega-tab-content-{$section_id}'>".$section['title'] . "</a>";
  2903. }
  2904. echo "</h2>";
  2905. $is_first = true;
  2906. foreach ( $settings as $section_id => $section ) {
  2907. if ($is_first) {
  2908. $display = 'block';
  2909. $is_first = false;
  2910. } else {
  2911. $display = 'none';
  2912. }
  2913. echo " <div class='mega-tab-content mega-tab-content-{$section_id}' style='display: {$display}'>";
  2914. echo " <table class='{$section_id}'>";
  2915. // order the fields by priority
  2916. uasort( $section['settings'], array( $this, "compare_elems" ) );
  2917. foreach ( $section['settings'] as $group_id => $group ) {
  2918. echo "<tr class='mega-{$group_id}'>";
  2919. if ( isset( $group['settings'] ) ) {
  2920. echo "<td class='mega-name'>" . $group['title'] . "<div class='mega-description'>" . $group['description'] . "</div></td>";
  2921. echo "<td class='mega-value'>";
  2922. foreach ( $group['settings'] as $setting_id => $setting ) {
  2923. if ( isset( $setting['validation'] ) ) {
  2924. echo "<label class='mega-{$setting['key']}' data-validation='{$setting['validation']}'>";
  2925. } else {
  2926. echo "<label class='mega-{$setting['key']}'>";
  2927. }
  2928. echo "<span class='mega-short-desc'>{$setting['title']}</span>";
  2929. switch ( $setting['type'] ) {
  2930. case "freetext":
  2931. $this->print_theme_freetext_option( $setting['key'] );
  2932. break;
  2933. case "textarea":
  2934. $this->print_theme_textarea_option( $setting['key'] );
  2935. break;
  2936. case "align":
  2937. $this->print_theme_align_option( $setting['key'] );
  2938. break;
  2939. case "checkbox":
  2940. $this->print_theme_checkbox_option( $setting['key'] );
  2941. break;
  2942. case "arrow":
  2943. $this->print_theme_arrow_option( $setting['key'] );
  2944. break;
  2945. case "color":
  2946. $this->print_theme_color_option( $setting['key'] );
  2947. break;
  2948. case "weight":
  2949. $this->print_theme_weight_option( $setting['key'] );
  2950. break;
  2951. case "font":
  2952. $this->print_theme_font_option( $setting['key'] );
  2953. break;
  2954. case "transform":
  2955. $this->print_theme_transform_option( $setting['key'] );
  2956. break;
  2957. case "decoration":
  2958. $this->print_theme_text_decoration_option( $setting['key'] );
  2959. break;
  2960. case "mobile_columns":
  2961. $this->print_theme_mobile_columns_option( $setting['key'] );
  2962. break;
  2963. case "copy_color":
  2964. $this->print_theme_copy_color_option( $setting['key'] );
  2965. break;
  2966. default:
  2967. do_action("megamenu_print_theme_option_{$setting['type']}", $setting['key'], $this->id );
  2968. break;
  2969. }
  2970. echo "</label>";
  2971. }
  2972. if ( isset( $group['info'] ) ) {
  2973. foreach ( $group['info'] as $paragraph ) {
  2974. echo "<div class='mega-info'>{$paragraph}</div>";
  2975. }
  2976. }
  2977. foreach ( $group['settings'] as $setting_id => $setting ) {
  2978. if ( isset( $setting['validation'] ) ) {
  2979. echo "<div class='mega-validation-message mega-validation-message-mega-{$setting['key']}'>";
  2980. if ( $setting['validation'] == 'int' ) {
  2981. $message = __("Enter a whole number (e.g. 1, 5, 100, 999)");
  2982. }
  2983. if ( $setting['validation'] == 'px' ) {
  2984. $message = __("Enter a value including a unit (e.g. 10px, 10rem, 10%)");
  2985. }
  2986. if ( $setting['validation'] == 'float' ) {
  2987. $message = __("Enter a valid number (e.g. 0.1, 1, 10, 999)");
  2988. }
  2989. if ( strlen( $setting['title'] ) ) {
  2990. echo $setting['title'] . ": " . $message;
  2991. } else {
  2992. echo $message;
  2993. }
  2994. echo "</div>";
  2995. }
  2996. }
  2997. echo "</td>";
  2998. } else {
  2999. echo "<td colspan='2'><h5>{$group['title']}</h5></td>";
  3000. }
  3001. echo "</tr>";
  3002. }
  3003. echo "</table>";
  3004. echo "</div>";
  3005. }
  3006. ?>
  3007. <div class='megamenu_submit'>
  3008. <div class='mega_left'>
  3009. <?php submit_button(); ?><span class='spinner'></span>
  3010. </div>
  3011. <div class='mega_right'>
  3012. <?php if ( $this->string_contains( $this->id, array("custom") ) ) : ?>
  3013. <a class='delete confirm' href='<?php echo $delete_url; ?>'><?php _e("Delete Theme", "megamenu"); ?></a>
  3014. <?php else : ?>
  3015. <a class='confirm' href='<?php echo $revert_url; ?>'><?php _e("Revert Theme", "megamenu"); ?></a>
  3016. <?php endif; ?>
  3017. </div>
  3018. </div>
  3019. <?php $this->show_cache_warning(); ?>
  3020. </form>
  3021. </div>
  3022. <?php
  3023. }
  3024. /**
  3025. * Check for installed caching/minification/CDN plugins and output a warning if one is found to be
  3026. * installed and activated
  3027. */
  3028. private function show_cache_warning() {
  3029. $active_plugins = max_mega_menu_get_active_caching_plugins();
  3030. if ( count( $active_plugins ) ):
  3031. ?>
  3032. <hr />
  3033. <div>
  3034. <h3><?php _e("Changes not showing up?", "megamenu"); ?></h3>
  3035. <p><?php echo _n("We have detected the following plugin that may prevent changes made within the theme editor from being applied to the menu.", "We have detected the following plugins that may prevent changes made within the theme editor from being applied to the menu.", count( $active_plugins), "megamenu"); ?></p>
  3036. <ul class='ul-disc'>
  3037. <?php
  3038. foreach ( $active_plugins as $name ) {
  3039. echo "<li>" . $name . "</li>";
  3040. }
  3041. ?>
  3042. </ul>
  3043. <p><?php echo _n("Try clearing the cache of the above plugin if your changes are not being applied to the menu.", "Try clearing the caches of the above plugins if your changes are not being applied to the menu.", count( $active_plugins), "megamenu"); ?></p>
  3044. </div>
  3045. <?php
  3046. endif;
  3047. }
  3048. /**
  3049. * Compare array values
  3050. *
  3051. * @param array $elem1
  3052. * @param array $elem2
  3053. * @return bool
  3054. * @since 2.1
  3055. */
  3056. private function compare_elems( $elem1, $elem2 ) {
  3057. return $elem1['priority'] > $elem2['priority'];
  3058. }
  3059. /**
  3060. * Print a select dropdown with left, center and right options
  3061. *
  3062. * @since 1.6.1
  3063. * @param string $key
  3064. * @param string $value
  3065. */
  3066. public function print_theme_align_option( $key ) {
  3067. $value = $this->active_theme[$key];
  3068. ?>
  3069. <select name='settings[<?php echo $key ?>]'>
  3070. <option value='left' <?php selected( $value, 'left' ); ?>><?php _e("Left", "megamenu") ?></option>
  3071. <option value='center' <?php selected( $value, 'center' ); ?>><?php _e("Center", "megamenu") ?></option>
  3072. <option value='right' <?php selected( $value, 'right' ); ?>><?php _e("Right", "megamenu") ?></option>
  3073. </select>
  3074. <?php
  3075. }
  3076. /**
  3077. * Print a copy icon
  3078. *
  3079. * @since 2.2.3
  3080. * @param string $key
  3081. * @param string $value
  3082. */
  3083. public function print_theme_copy_color_option( $key ) {
  3084. ?>
  3085. <span class='dashicons dashicons-arrow-right-alt'></span>
  3086. <?php
  3087. }
  3088. /**
  3089. * Print a select dropdown with 1 and 2 options
  3090. *
  3091. * @since 1.2.0
  3092. * @param string $key
  3093. * @param string $value
  3094. */
  3095. public function print_theme_mobile_columns_option( $key ) {
  3096. $value = $this->active_theme[$key];
  3097. ?>
  3098. <select name='settings[<?php echo $key ?>]'>
  3099. <option value='1' <?php selected( $value, '1' ); ?>><?php _e("1 Column", "megamenu") ?></option>
  3100. <option value='2' <?php selected( $value, '2' ); ?>><?php _e("2 Columns", "megamenu") ?></option>
  3101. </select>
  3102. <?php
  3103. }
  3104. /**
  3105. * Print a select dropdown with text decoration options
  3106. *
  3107. * @since 1.6.1
  3108. * @param string $key
  3109. * @param string $value
  3110. */
  3111. public function print_theme_text_decoration_option( $key ) {
  3112. $value = $this->active_theme[$key];
  3113. ?>
  3114. <select name='settings[<?php echo $key ?>]'>
  3115. <option value='none' <?php selected( $value, 'none' ); ?>><?php _e("None", "megamenu") ?></option>
  3116. <option value='underline' <?php selected( $value, 'underline' ); ?>><?php _e("Underline", "megamenu") ?></option>
  3117. </select>
  3118. <?php
  3119. }
  3120. /**
  3121. * Print a checkbox option
  3122. *
  3123. * @since 1.6.1
  3124. * @param string $key
  3125. * @param string $value
  3126. */
  3127. public function print_theme_checkbox_option( $key ) {
  3128. $value = $this->active_theme[$key];
  3129. ?>
  3130. <input type='hidden' name='checkboxes[<?php echo $key ?>]' />
  3131. <input type='checkbox' name='settings[<?php echo $key ?>]' <?php checked( $value, 'on' ); ?> />
  3132. <?php
  3133. }
  3134. /**
  3135. * Print an arrow dropdown selection box
  3136. *
  3137. * @since 1.0
  3138. * @param string $key
  3139. * @param string $value
  3140. */
  3141. public function print_theme_arrow_option( $key ) {
  3142. $value = $this->active_theme[$key];
  3143. $arrow_icons = $this->arrow_icons();
  3144. ?>
  3145. <select class='icon_dropdown' name='settings[<?php echo $key ?>]'>
  3146. <?php
  3147. echo "<option value='disabled'>" . __("Disabled", "megamenu") . "</option>";
  3148. foreach ($arrow_icons as $code => $class) {
  3149. $name = str_replace('dashicons-', '', $class);
  3150. $name = ucwords(str_replace(array('-','arrow'), ' ', $name));
  3151. echo "<option data-class='{$class}' value='{$code}' " . selected( $value, $code, false ) . ">" . $name . "</option>";
  3152. }
  3153. ?>
  3154. </select>
  3155. <?php
  3156. }
  3157. /**
  3158. * Print a colorpicker
  3159. *
  3160. * @since 1.0
  3161. * @param string $key
  3162. * @param string $value
  3163. */
  3164. public function print_theme_color_option( $key ) {
  3165. $value = $this->active_theme[$key];
  3166. if ( $value == 'transparent' ) {
  3167. $value = 'rgba(0,0,0,0)';
  3168. }
  3169. if ( $value == 'rgba(0,0,0,0)' ) {
  3170. $value_text = 'transparent';
  3171. } else {
  3172. $value_text = $value;
  3173. }
  3174. echo "<div class='mm-picker-container'>";
  3175. echo " <input type='text' class='mm_colorpicker' name='settings[$key]' value='{$value}' />";
  3176. echo " <div class='chosen-color'>{$value_text}</div>";
  3177. echo "</div>";
  3178. }
  3179. /**
  3180. * Print a font weight selector
  3181. *
  3182. * @since 1.0
  3183. * @param string $key
  3184. * @param string $value
  3185. */
  3186. public function print_theme_weight_option( $key ) {
  3187. $value = $this->active_theme[$key];
  3188. $options = apply_filters( "megamenu_font_weights", array(
  3189. 'inherit' => __("Theme Default", "megamenu"),
  3190. '300' => __("Light (300)", "megamenu"),
  3191. 'normal' => __("Normal (400)", "megamenu"),
  3192. 'bold' => __("Bold (700)", "megamenu"),
  3193. ) );
  3194. /**
  3195. * '100' => __("Thin (100)", "megamenu"),
  3196. * '200' => __("Extra Light (200)", "megamenu"),
  3197. * '300' => __("Light (300)", "megamenu"),
  3198. * 'normal' => __("Normal (400)", "megamenu"),
  3199. * '500' => __("Medium (500)", "megamenu"),
  3200. * '600' => __("Semi Bold (600)", "megamenu"),
  3201. * 'bold' => __("Bold (700)", "megamenu"),
  3202. * '800' => __("Extra Bold (800)", "megamenu"),
  3203. * '900' => __("Black (900)", "megamenu")
  3204. */
  3205. echo "<select name='settings[$key]'>";
  3206. foreach ( $options as $weight => $name ) {
  3207. echo "<option value='{$weight}' " . selected( $value, $weight, true ) . ">{$name}</option>";
  3208. }
  3209. echo "</select>";
  3210. }
  3211. /**
  3212. * Print a font transform selector
  3213. *
  3214. * @since 1.0
  3215. * @param string $key
  3216. * @param string $value
  3217. */
  3218. public function print_theme_transform_option( $key ) {
  3219. $value = $this->active_theme[$key];
  3220. echo "<select name='settings[$key]'>";
  3221. echo " <option value='none' " . selected( $value, 'none', true) . ">" . __("Normal", "megamenu") . "</option>";
  3222. echo " <option value='capitalize'" . selected( $value, 'capitalize', true) . ">" . __("Capitalize", "megamenu") . "</option>";
  3223. echo " <option value='uppercase'" . selected( $value, 'uppercase', true) . ">" . __("UPPERCASE", "megamenu") . "</option>";
  3224. echo " <option value='lowercase'" . selected( $value, 'lowercase', true) . ">" . __("lowercase", "megamenu") . "</option>";
  3225. echo "</select>";
  3226. }
  3227. /**
  3228. * Print a textarea
  3229. *
  3230. * @since 1.0
  3231. * @param string $key
  3232. * @param string $value
  3233. */
  3234. public function print_theme_textarea_option( $key ) {
  3235. $value = $this->active_theme[$key];
  3236. ?>
  3237. <textarea id='codemirror' name='settings[<?php echo $key ?>]'><?php echo stripslashes( $value ) ?></textarea>
  3238. <p><b><?php _e("Custom Styling Tips", "megamenu"); ?></b></p>
  3239. <p><?php _e("You can enter standard CSS or <a href='https://sass-lang.com/guide' target='_blank'>SCSS</a> into the custom styling area. If using SCSS there are some variables and mixins you can use:"); ?></p>
  3240. <ul class='custom_styling_tips'>
  3241. <li><code>#{$wrap}</code> <?php _e("converts to the ID selector of the menu wrapper, e.g. div#mega-menu-wrap-primary", "megamenu"); ?></li>
  3242. <li><code>#{$menu}</code> <?php _e("converts to the ID selector of the menu, e.g. ul#mega-menu-primary", "megamenu"); ?></li>
  3243. <li><code>@include mobile|desktop { .. }</code> <?php _e("wraps the CSS within a media query based on the configured Responsive Breakpoint (see example CSS)", "megamenu"); ?></li>
  3244. <?php
  3245. $string = __("Using the %wrap% and %menu% variables makes your theme portable (allowing you to apply the same theme to multiple menu locations)", "megamenu");
  3246. $string = str_replace('%wrap%', '<code>#{$wrap}</code>', $string);
  3247. $string = str_replace('%menu%', '<code>#{$menu}</code>', $string);
  3248. ?>
  3249. <li><?php echo $string; ?></li>
  3250. <li>Example CSS:</li>
  3251. <code>/** Add text shadow to top level menu items on desktop AND mobile **/
  3252. <br />#{$wrap} #{$menu} > li.mega-menu-item > a.mega-menu-link {
  3253. <br />&nbsp;&nbsp;&nbsp;&nbsp;text-shadow: 1px 1px #000000;
  3254. <br />}
  3255. </code>
  3256. <br /><br />
  3257. <code>/** Add text shadow to top level menu items on desktop only **/
  3258. <br />@include desktop {
  3259. <br />&nbsp;&nbsp;&nbsp;&nbsp;#{$wrap} #{$menu} > li.mega-menu-item > a.mega-menu-link {
  3260. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;text-shadow: 1px 1px #000000;
  3261. <br />&nbsp;&nbsp;&nbsp;&nbsp;}
  3262. <br />}
  3263. </code></li>
  3264. </ul>
  3265. <?php
  3266. }
  3267. /**
  3268. * Print a font selector
  3269. *
  3270. * @since 1.0
  3271. * @param string $key
  3272. * @param string $value
  3273. */
  3274. public function print_theme_font_option( $key ) {
  3275. $value = $this->active_theme[$key];
  3276. echo "<select name='settings[$key]'>";
  3277. echo "<option value='inherit'>" . __("Theme Default", "megamenu") . "</option>";
  3278. foreach ( $this->fonts() as $font ) {
  3279. $parts = explode(",", $font);
  3280. $font_name = trim($parts[0]);
  3281. echo "<option value=\"{$font}\" " . selected( $font, $value ) . ">{$font_name}</option>";
  3282. }
  3283. echo "</select>";
  3284. }
  3285. /**
  3286. * Print a text input
  3287. *
  3288. * @since 1.0
  3289. * @param string $key
  3290. * @param string $value
  3291. */
  3292. public function print_theme_freetext_option( $key ) {
  3293. $value = $this->active_theme[$key];
  3294. echo "<input class='mega-setting-{$key}' type='text' name='settings[$key]' value='{$value}' />";
  3295. }
  3296. /**
  3297. * Returns a list of available fonts.
  3298. *
  3299. * @since 1.0
  3300. */
  3301. public function fonts() {
  3302. $fonts = array(
  3303. "Georgia, serif",
  3304. "Palatino Linotype, Book Antiqua, Palatino, serif",
  3305. "Times New Roman, Times, serif",
  3306. "Arial, Helvetica, sans-serif",
  3307. "Arial Black, Gadget, sans-serif",
  3308. "Comic Sans MS, cursive, sans-serif",
  3309. "Impact, Charcoal, sans-serif",
  3310. "Lucida Sans Unicode, Lucida Grande, sans-serif",
  3311. "Tahoma, Geneva, sans-serif",
  3312. "Trebuchet MS, Helvetica, sans-serif",
  3313. "Verdana, Geneva, sans-serif",
  3314. "Courier New, Courier, monospace",
  3315. "Lucida Console, Monaco, monospace"
  3316. );
  3317. $fonts = apply_filters( "megamenu_fonts", $fonts );
  3318. return $fonts;
  3319. }
  3320. /**
  3321. * List of all available arrow DashIcon classes.
  3322. *
  3323. * @since 1.0
  3324. * @return array - Sorted list of icon classes
  3325. */
  3326. private function arrow_icons() {
  3327. $icons = array(
  3328. 'dash-f142' => 'dashicons-arrow-up',
  3329. 'dash-f140' => 'dashicons-arrow-down',
  3330. 'dash-f141' => 'dashicons-arrow-left',
  3331. 'dash-f139' => 'dashicons-arrow-right',
  3332. 'dash-f342' => 'dashicons-arrow-up-alt',
  3333. 'dash-f346' => 'dashicons-arrow-down-alt',
  3334. 'dash-f340' => 'dashicons-arrow-left-alt',
  3335. 'dash-f344' => 'dashicons-arrow-right-alt',
  3336. 'dash-f343' => 'dashicons-arrow-up-alt2',
  3337. 'dash-f347' => 'dashicons-arrow-down-alt2',
  3338. 'dash-f341' => 'dashicons-arrow-left-alt2',
  3339. 'dash-f345' => 'dashicons-arrow-right-alt2',
  3340. 'dash-f132' => 'dashicons-plus',
  3341. 'dash-f460' => 'dashicons-minus',
  3342. 'dash-f158' => 'dashicons-no',
  3343. 'dash-f335' => 'dashicons-no-alt',
  3344. );
  3345. $icons = apply_filters( "megamenu_arrow_icons", $icons );
  3346. return $icons;
  3347. }
  3348. /**
  3349. * Enqueue nav-menus.php scripts
  3350. *
  3351. * @since 1.8.3
  3352. */
  3353. public function enqueue_scripts() {
  3354. wp_enqueue_script('accordion');
  3355. wp_enqueue_style( 'spectrum', MEGAMENU_BASE_URL . 'js/spectrum/spectrum.css', false, MEGAMENU_VERSION );
  3356. wp_enqueue_style( 'mega-menu-settings', MEGAMENU_BASE_URL . 'css/admin/admin.css', false, MEGAMENU_VERSION );
  3357. wp_deregister_style('codemirror');
  3358. wp_enqueue_style( 'mega-menu-codemirror', MEGAMENU_BASE_URL . 'js/codemirror/codemirror.css', false, MEGAMENU_VERSION );
  3359. wp_enqueue_style( 'select2', MEGAMENU_BASE_URL . 'js/select2/select2.css', false, MEGAMENU_VERSION );
  3360. wp_enqueue_script( 'spectrum', MEGAMENU_BASE_URL . 'js/spectrum/spectrum.js', array( 'jquery' ), MEGAMENU_VERSION );
  3361. wp_deregister_script('codemirror');
  3362. wp_enqueue_script( 'mega-menu-codemirror', MEGAMENU_BASE_URL . 'js/codemirror/codemirror.js', array(), MEGAMENU_VERSION );
  3363. wp_enqueue_script( 'mega-menu-select2', MEGAMENU_BASE_URL . 'js/select2/select2.min.js', array(), MEGAMENU_VERSION );
  3364. wp_enqueue_script( 'mega-menu-theme-editor', MEGAMENU_BASE_URL . 'js/settings.js', array( 'jquery', 'spectrum', 'mega-menu-codemirror' ), MEGAMENU_VERSION );
  3365. wp_localize_script( 'mega-menu-theme-editor', 'megamenu_settings',
  3366. array(
  3367. 'confirm' => __("Are you sure?", "megamenu"),
  3368. "theme_save_error" => __("Error saving theme.", "megamenu"),
  3369. "theme_save_error_refresh" => __("Please try refreshing the page.", "megamenu"),
  3370. "theme_save_error_exhausted" => __("The server ran out of memory whilst trying to regenerate the menu CSS.", "megamenu"),
  3371. "theme_save_error_memory_limit" => __("Try disabling unusued plugins to increase the available memory. Alternatively, for details on how to increase your server memory limit see:", "megamenu"),
  3372. "theme_save_error_500" => __("The server returned a 500 error. The server did not provide an error message (you should find details of the error in your server error log), but this is usually due to your server memory limit being reached.", "megamenu"),
  3373. "increase_memory_limit_url" => "http://www.wpbeginner.com/wp-tutorials/fix-wordpress-memory-exhausted-error-increase-php-memory/",
  3374. "increase_memory_limit_anchor_text" => "How to increase the WordPress memory limit"
  3375. )
  3376. );
  3377. }
  3378. }
  3379. endif;