Advertisement
Guest User

Nellie > Branding functions.php file

a guest
Apr 23rd, 2018
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 49.62 KB | None | 0 0
  1. <?php
  2. function ac_theme_enqueue_styles()
  3. {
  4.     $parent_style = 'parent-style-nellie';
  5.     wp_enqueue_style($parent_style, get_stylesheet_directory_uri() . '/assets/css/divi.css');
  6.     wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css', array(
  7.         $parent_style
  8.     ));
  9. }
  10. add_action('wp_enqueue_scripts', 'ac_theme_enqueue_styles');
  11. function ac_n_dq_parent_style()
  12. {
  13.     wp_dequeue_style('divi-style');
  14.     wp_register_style('parent-style-nellie', get_stylesheet_directory_uri() . '/assets/css/divi.css', false, '1.0.0');
  15.     wp_enqueue_style('parent-style-nellie');
  16. }
  17. function ac_n_parent_script_enq()
  18. {
  19.     add_action('wp_enqueue_scripts', 'ac_n_dq_parent_style');
  20. }
  21. add_action('after_setup_theme', 'ac_n_parent_script_enq');
  22. add_action('after_setup_theme', 'ac_n_load_text_domain');
  23. function ac_n_load_text_domain()
  24. {
  25.     load_child_theme_textdomain('Nellie', get_stylesheet_directory() . '/languages');
  26. }
  27. require 'inc/update.php';
  28. $ac_auto_updater = new acautoupdater('Nellie', 'https://ayanize.com/api/?action=get_metadata&slug=Nellie');
  29. require_once get_stylesheet_directory() . '/inc/pl-installer.php';
  30. require get_stylesheet_directory() . '/includes/login/settings.php';
  31. require get_stylesheet_directory() . '/inc/ac-importer.php';
  32. require get_stylesheet_directory() . '/includes/footer/footer.php';
  33. require get_stylesheet_directory() . '/includes/404/404page.php';
  34. require get_stylesheet_directory() . '/includes/branding/functions.php';
  35. require get_stylesheet_directory() . '/includes/maps/functions.php';
  36. require get_stylesheet_directory() . '/woocommerce/functions.php';
  37. require get_stylesheet_directory() . '/inc/theme.php';
  38. require get_stylesheet_directory() . '/includes/sc/functions.php';
  39. require get_stylesheet_directory() . '/includes/branding/code/settings.php';
  40. require get_stylesheet_directory() . '/includes/general/functions.php';
  41. require get_stylesheet_directory() . '/includes/mobile/functions.php';
  42. add_action('init', 'remove_wc_column_num');
  43. add_action('admin_enqueue_scripts', 'ac_admin_import_scripts');
  44. add_action('wp_enqueue_scripts', 'ac_front_js');
  45. add_action('admin_enqueue_scripts', 'ac_load_admin_scripts');
  46. add_action('admin_enqueue_scripts', 'ac_load_alt_admin_css');
  47. add_action('ac_plugins_settings', 'ac_install_req_plugins_');
  48. add_action('admin_menu', 'ac_add_menu');
  49. add_action('admin_menu', 'ac_n_add_sub_menu');
  50. add_action('admin_init', 'ac_theme_options');
  51. add_action('admin_init', 'ac_register_theme_options_settings');
  52. add_action('admin_head', 'ac_force_plugin_activation');
  53. add_action('admin_init', 'ac_nag_ignore');
  54. if (get_option('ac_misc_remove_header_format') == 0) {
  55.     add_action('admin_init', 'ac_header_centered_default');
  56. }
  57. function ac_n_wc_support()
  58. {
  59.     add_theme_support('wc-product-gallery-zoom');
  60.     add_theme_support('wc-product-gallery-lightbox');
  61.     add_theme_support('wc-product-gallery-slider');
  62. }
  63. add_action('after_setup_theme', 'ac_n_wc_support', 20);
  64. add_shortcode('wc-sidebar', 'ac_wc_sidebar');
  65. add_action('wp_print_styles', 'ac_call_custom_gf');
  66. remove_filter('pre_user_description', 'wp_filter_kses');
  67. add_action('ac_small_logo', 'ac_switch_small_logo_header');
  68. add_filter('user_contactmethods', 'ac_modify_contact_methods');
  69. if (get_option('ac_misc_back_header_menu_tabs') == 0) {
  70.     add_action('admin_head', 'show_ac_wc_tab');
  71. }
  72. add_action('ac_login_register', 'ac_rename_login_register');
  73. add_action('login_head', 'ac_login_placeholder', 999);
  74. add_action('wp_enqueue_scripts', 'switch_logo');
  75. add_action('admin_init', 'ac_misc_settings_register');
  76. add_action('wp_login_failed', 'ac_front_login_fail');
  77. add_action('wp_head', 'ac_custom_css_bg', 20);
  78. if (get_option('ac_misc_remove_header_bg') == 1) {
  79.     remove_action('wp_head', 'ac_custom_css_bg', 20);
  80. }
  81. add_action('wp_head', 'ac_custom_css', 20);
  82. add_action('ac_header_elmns', 'ac_header_contacts');
  83. add_filter('wp_nav_menu_items', 'do_shortcode');
  84. add_shortcode('ac', 'ac_wc_mega_menu');
  85. add_action('admin_bar_menu', 'ac_add_options_toolbar', 9999);
  86. add_action('wp_head', 'ac_noindex_404_template_page', 1);
  87. add_action('ac_post_type_meta', 'display_post_type_meta', 99);
  88. add_action('ac_post_type_cat', 'ac_display_cpt_cat_name');
  89. add_filter('wp_prepare_themes_for_js', 'ac_branding_themes');
  90. function ac_n_get_divi_ver()
  91. {
  92.     $theme   = wp_get_theme('Divi');
  93.     $ver     = $theme->get('Version');
  94.     $compare = version_compare($ver, '3.0.0', '>');
  95.     return $compare;
  96. }
  97. function ac_n_get_curr_nellie()
  98. {
  99.     $theme   = wp_get_theme('Nellie');
  100.     $ver     = $theme->get('Version');
  101.     $compare = version_compare($ver, '1.4', '=');
  102.     return $compare;
  103. }
  104. function remove_wc_column_num()
  105. {
  106.     remove_filter('loop_shop_columns', 'et_modify_shop_page_columns_num');
  107. }
  108. function ac_admin_import_scripts()
  109. {
  110.     wp_register_script('dummy-import', get_stylesheet_directory_uri() . '/inc/ac-import.js', false, '1.0.0');
  111.     wp_enqueue_script('dummy-import');
  112. }
  113. function ac_front_js()
  114. {
  115.     wp_register_script('ac-front-js', get_stylesheet_directory_uri() . '/js/front.js', array(
  116.         'jquery'
  117.     ), '1.1', false);
  118.     wp_enqueue_script('ac-front-js');
  119.     wp_register_script('ac-front-stick', get_stylesheet_directory_uri() . '/js/stick.js', array(
  120.         'jquery'
  121.     ), '1.1', false);
  122.     wp_enqueue_script('ac-front-stick');
  123. }
  124. function ac_load_admin_scripts()
  125. {
  126.     global $pagenow;
  127.     $page = (isset($_REQUEST['page']) ? $_REQUEST['page'] : false);
  128.     if ($pagenow == 'admin.php' && $page == 'ac_nellie_options') {
  129.         wp_register_style('ncp-css', get_stylesheet_directory_uri() . '/assets/css/panel.css', false, '1.0.0');
  130.         wp_enqueue_style('ncp-css');
  131.     }
  132. }
  133. function ac_load_alt_admin_css()
  134. {
  135.     global $pagenow;
  136.     $page = (isset($_REQUEST['page']) ? $_REQUEST['page'] : false);
  137.     if ($pagenow == 'admin.php' && $page == 'ac_nellie_options') {
  138.         return;
  139.     }
  140.     wp_register_style('n-admin-css', get_stylesheet_directory_uri() . '/assets/css/admin.css', false, '1.0.0');
  141.     wp_enqueue_style('n-admin-css');
  142. }
  143. function ac_install_req_plugins_()
  144. {
  145.     $plugins = array(
  146.         array(
  147.             'name' => 'WooCommerce',
  148.             'slug' => 'woocommerce',
  149.             'required' => true,
  150.             'force_activation' => true,
  151.             'force_deactivation' => false
  152.         )
  153.     );
  154.     tgmpa($plugins);
  155.     $config = array(
  156.         'id' => 'ac_nellie',
  157.         'default_path' => '',
  158.         'menu' => 'tgmpa-install-plugins',
  159.         'parent_slug' => 'themes.php',
  160.         'capability' => 'edit_theme_options',
  161.         'has_notices' => true,
  162.         'dismissable' => true,
  163.         'dismiss_msg' => '',
  164.         'is_automatic' => true,
  165.         'message' => ''
  166.     );
  167.     tgmpa($plugins, $config);
  168. }
  169. function ac_n_submenus()
  170. {
  171.     if ('publish' == get_post_status('987451248')) {
  172.         return true;
  173.     } else {
  174.         return false;
  175.     }
  176. }
  177. function ac_add_menu()
  178. {
  179.     if (ac_n_submenus()) {
  180.         add_menu_page(__('Nellie'), __('Nellie'), 'manage_options', 'ac_nellie_options&tab=gen_options', 'theme_options_functions');
  181.     } else {
  182.         add_menu_page(__('Nellie'), __('Nellie'), 'manage_options', 'ac_nellie_options', 'theme_options_functions');
  183.     }
  184. }
  185. function ac_n_add_sub_menu()
  186. {
  187.     if (ac_n_submenus()) {
  188.         add_submenu_page('ac_nellie_options', __('General', 'Nellie'), __('General', 'Nellie'), 'manage_options', 'ac_nellie_options', 'theme_options_functions');
  189.     } else {
  190.         add_submenu_page('ac_nellie_options&tab=gen_options', __('General', 'Nellie'), __('General', 'Nellie'), 'manage_options', 'ac_nellie_options', 'theme_options_functions');
  191.     }
  192. }
  193. function ac_n_add_opt_sub_menus()
  194. {
  195.     $gen_opt = 'ac_nellie_options&tab=gen_options';
  196.     $n_opt   = 'ac_nellie_options';
  197.     if (ac_n_submenus()) {
  198.         $sub_opt = $gen_opt;
  199.     } else {
  200.         $sub_opt = $n_opt;
  201.     }
  202.     if (get_option('ac_n_opt_wc_yes') == 1) {
  203.         add_submenu_page($sub_opt, __('WooCommerce', 'Nellie'), __('WooCommerce', 'Nellie'), 'manage_options', 'admin.php?page=ac_nellie_options&tab=wc_options', NULL);
  204.     }
  205.     if (get_option('ac_n_opt_fb_yes') == 1) {
  206.         add_submenu_page($sub_opt, __('Footer Builder', 'Nellie'), __('Footer Builder', 'Nellie'), 'manage_options', 'admin.php?page=ac_nellie_options&tab=footer_builder_options', NULL);
  207.     }
  208.     if (get_option('ac_n_opt_lp_yes') == 1) {
  209.         add_submenu_page($sub_opt, __('Login Customizer', 'Nellie'), __('Login Customizer', 'Nellie'), 'manage_options', 'admin.php?page=ac_nellie_options&tab=login_options', NULL);
  210.     }
  211.     if (get_option('ac_n_opt_brnd_yes') == 1) {
  212.         add_submenu_page($sub_opt, __('Branding', 'Nellie'), __('Branding', 'Nellie'), 'manage_options', 'admin.php?page=ac_nellie_options&tab=branding_options', NULL);
  213.     }
  214.     if (get_option('ac_n_opt_gm_yes') == 1) {
  215.         add_submenu_page($sub_opt, __('Google Map', 'Nellie'), __('Google Map', 'Nellie'), 'manage_options', 'admin.php?page=ac_nellie_options&tab=maps_options', NULL);
  216.     }
  217.     if (get_option('ac_n_opt_misc_yes') == 1) {
  218.         add_submenu_page($sub_opt, __('Miscellaneous', 'Nellie'), __('Miscellaneous', 'Nellie'), 'manage_options', 'admin.php?page=ac_nellie_options&tab=misc_options', NULL);
  219.     }
  220.     if (get_option('ac_n_opt_sc_yes') == 1) {
  221.         add_submenu_page($sub_opt, __('AC ShortCodes', 'Nellie'), __('AC ShortCodes', 'Nellie'), 'manage_options', 'admin.php?page=ac_nellie_options&tab=sc_options', NULL);
  222.     }
  223.     if (get_option('ac_n_opt_cust_yes') == 1) {
  224.         add_submenu_page($sub_opt, __('Customization', 'Nellie'), __('Customization', 'Nellie'), 'manage_options', 'admin.php?page=ac_nellie_options&tab=code_page_options', NULL);
  225.     }
  226. }
  227. add_action('admin_menu', 'ac_n_add_opt_sub_menus', 100);
  228. function ac_theme_options()
  229. {
  230.     add_settings_section('gen_page', '', 'gen_page_callback', 'gen_page_option');
  231.     add_settings_section('front_page', '', 'front_page_callback', 'front_page_option');
  232.     add_settings_section('second_page', '', 'second_page_callback', 'second_page_option');
  233.     add_settings_section('footer_page', '', 'footer_page_callback', 'footer_page_option');
  234.     add_settings_section('login_page', '', 'login_page_callback', 'login_page_option');
  235.     add_settings_section('branding_page', '', 'branding_page_callback', 'branding_page_option');
  236.     add_settings_section('maps_page', '', 'maps_page_callback', 'maps_page_option');
  237.     add_settings_section('wc_page', '', 'wc_page_callback', 'wc_page_option');
  238.     add_settings_section('misc_page', '', 'misc_page_callback', 'misc_page_option');
  239.     add_settings_section('sc_page', '', 'sc_page_callback', 'sc_page_option');
  240.     add_settings_section('code_page', '', 'code_page_callback', 'code_page_option');
  241. }
  242. function ac_register_theme_options_settings()
  243. {
  244.     register_setting('gen_page_option', 'gen_page_option');
  245.     register_setting('front_page_option', 'front_page_option');
  246.     register_setting('second_page_option', 'second_page_option');
  247.     register_setting('footer_page_option', 'footer_page_option');
  248.     register_setting('code_page_option', 'code_page_option');
  249.     register_setting('login_page_option', 'login_page_option');
  250.     register_setting('branding_page_option', 'branding_page_option');
  251.     register_setting('maps_page_option', 'maps_page_option');
  252.     register_setting('wc_page_option', 'wc_page_option');
  253.     register_setting('misc_page_option', 'misc_page_option');
  254.     register_setting('sc_page_option', 'sc_page_option');
  255. }
  256. function gen_page_callback()
  257. {
  258.     get_template_part('includes/general/options');
  259. }
  260. function front_page_callback()
  261. {
  262.     echo '<h2 id="tabbed-options-heading">' . __('Import Dummy Content', 'Nellie') . '</h2>';
  263.     echo '<div class="import-heading">' . __('Click the IMPORT button once and fetch the Dummy content', 'Nellie') . '</div>';
  264.     echo '<div class="ac-admin-info note">' . __('PROCESS', 'Nellie') . '</div>';
  265.     echo '<div class="ac-admin-info-show">' . __('Once you click the Import Button, the installer will import all the dummy content as designed in our demo site.
  266.  
  267. The import may take several minutes depending on your Internet speed and server configuration. Do not navigate away from this page until the import is complete. You will be properly notified once the import is done.
  268. Clicking on the Import Button more than once will result in duplicate content in your site. Please avoid that unless you really want that content once again.
  269.  
  270. Please be informed that the images shown in the demo site will not be imported. Instead exact dimensional images will be fetched due to media licensing issues. However, you will be able to replace those images with your own once you get the exact dimension as visible on those dummy images.', 'Nellie') . '</div>';
  271.     echo '<div class="import_message">';
  272.     echo '<input type="button" value="' . __('IMPORT', 'Nellie') . '" id="ac_import" class="ac_import"/>';
  273.     echo '<div class="alternate-demo"><h3>' . __('Alternative Method', 'Nellie') . '</h3>
  274.    
  275.     <div class="alternate-demo-content">' . __('If for some reasons, the <strong>Ajax Demo Importer</strong> does not work (<em>if it takes more than 5 minutes to process</em>), please install the following Plugin from WordPress repository', 'Nellie') . __('<a href="https://wordpress.org/plugins/one-click-demo-import/" target="_blank">One Click Demo Import</a>', 'Nellie') . __('<p>Browse the XML file from Nellie Theme Directory or <a href="http://bit.ly/2lfGbI9" target="_blank">download this from here</a>', 'Nellie') . __('<p> Once you install the recommended Importer Plugin, you will notice a Plugin options page <strong>Import Demo Data</strong> under <em>Appearance</em>. Please visit the Plugin Options page and import the XML file and wait for a while before the Nellie Demo Content is fetched into your site</p>', 'Nellie') . '</div>' . '</div>';
  276.     echo '</div>';
  277.     if (ac_n_get_curr_nellie()) {
  278.         echo '<p class="new-import-errors">' . __('Please be informed that you will see import error messages like <em>some pages and media files already exist</em> since you have already run the importer earlier when you first installed Nellie. Please ignore those errors since you would need to run this once again to import the new pages, menus, custom layouts, AC ShortCodes and so.', 'Nellie') . '</p>';
  279.     }
  280.     echo '<span class="import_issues">' . __('The importer will install all the dummy content. If there is any issues in importing or if the import is not successfully done, please report this to us', 'Nellie') . '</span>';
  281. }
  282. function second_page_callback()
  283. {
  284. ?>
  285.  
  286. <div class="wrap">
  287. <form method="post" action="options.php">
  288. <?php
  289.     settings_fields('reading');
  290.     if (!in_array(get_option('blog_charset'), array(
  291.         'utf8',
  292.         'utf-8',
  293.         'UTF8',
  294.         'UTF-8'
  295.     )))
  296.         add_settings_field('blog_charset', __('Encoding for pages and feeds'), 'options_reading_blog_charset', 'reading', 'default', array(
  297.             'label_for' => 'blog_charset'
  298.         ));
  299. ?>
  300.  
  301. <?php
  302.     if (!get_pages()):
  303. ?>
  304. <input name="show_on_front" type="hidden" value="posts" />
  305. <table class="form-table">
  306. <?php
  307.         if ('posts' != get_option('show_on_front')):
  308.             update_option('show_on_front', 'posts');
  309.         endif;
  310.     else:
  311.         if ('page' == get_option('show_on_front') && !get_option('page_on_front') && !get_option('page_for_posts'))
  312.             update_option('show_on_front', 'posts');
  313. ?>
  314. <h2 id="tabbed-options-heading"><?php
  315.         _e('Set Homepage and Menu', 'Nellie');
  316. ?></h2>
  317. <table class="form-table">
  318. <p><?php
  319.         _e('Set the Homepage and Nav Menu (<em>as suggested by this theme</em>)', 'Nellie');
  320. ?></p>
  321.  
  322.  <div class="ac-admin-info note"><?php
  323.         _e('INFO', 'Nellie');
  324. ?></div>
  325. <div class="ac-admin-info-show">
  326. <?php
  327.         _e('These settings can also be done in these pages -', 'Nellie');
  328. ?> <a href="<?php
  329.         echo esc_url(admin_url('options-reading.php'));
  330. ?>"><?php
  331.         _e('Reading');
  332. ?></a> (<em><?php
  333.         _e('for Homepage select</em>) and', 'Nellie');
  334. ?> <a href="<?php
  335.         echo esc_url(admin_url('nav-menus.php'));
  336. ?>"><?php
  337.         _e('Menus', 'Nellie');
  338. ?></a> (<em><?php
  339.         _e('for Menus select', 'Nellie');
  340. ?></em>)
  341. </div>
  342.  
  343. <tr>
  344. <th scope="row"><?php
  345.         _e('Select Homepage', 'Nellie');
  346. ?></th>
  347. <td id="front-static-pages"><fieldset><legend class="screen-reader-text"><span><?php
  348.         _e('Select Homepage', 'Nellie');
  349. ?></span></legend>
  350.         <p><label>
  351.         <input name="show_on_front" type="radio" value="page" class="tog" <?php
  352.         checked('page', get_option('show_on_front'));
  353. ?> checked/>
  354.         <?php
  355.         printf(__('A <a href="%s">static page</a> (select below)', 'Nellie'), 'edit.php?post_type=page');
  356. ?>
  357.     </label>
  358.     </p>
  359. <ul>
  360.     <li><label for="page_on_front"><?php
  361.         printf(__('Homepage: %s', 'Nellie'), wp_dropdown_pages(array(
  362.             'name' => 'page_on_front',
  363.             'echo' => 0,
  364.             'show_option_none' => __('&mdash; Select &mdash;', 'Nellie'),
  365.             'option_none_value' => '0',
  366.             'selected' => get_option('page_on_front')
  367.         )));
  368. ?></label></li>
  369.    
  370. </ul>
  371. <?php
  372.         if ('page' == get_option('show_on_front') && get_option('page_for_posts') == get_option('page_on_front')):
  373. ?>
  374. <div id="front-page-warning" class="error inline"><p><?php
  375.             _e('<strong>Warning:</strong> these pages should not be the same!');
  376. ?></p></div>
  377. <?php
  378.         endif;
  379. ?>
  380. </fieldset></td>
  381. </tr>
  382.  
  383. <?php
  384.     endif;
  385. ?>
  386. <?php
  387.     do_settings_fields('reading', 'default');
  388. ?>
  389. </table>
  390.  
  391. <?php
  392.     do_settings_sections('reading');
  393. ?>
  394.  
  395. <input type="submit" name="submit" id="submit" class="ac-admin-buttons" value="<?php
  396.     _e('Save Changes');
  397. ?>"  />
  398. </form>
  399. </div>
  400.  
  401. <!--adding menu-->
  402. <?php
  403.     if (current_theme_supports('menus')) {
  404.         $locations      = get_registered_nav_menus();
  405.         $menu_locations = get_nav_menu_locations();
  406.     }
  407.     $locations      = get_registered_nav_menus();
  408.     $menu_locations = get_nav_menu_locations();
  409.     $num_locations  = count(array_keys($locations));
  410.     $nav_menus      = wp_get_nav_menus();
  411.     $menu_count     = count($nav_menus);
  412.     foreach ((array) $nav_menus as $key => $_nav_menu) {
  413.         $nav_menus[$key]->truncated_name = wp_html_excerpt($_nav_menu->name, 40, '&hellip;');
  414.     }
  415.     $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'edit';
  416.     switch ($action) {
  417.         case 'add-menu-item':
  418.             check_admin_referer('add-menu_item', 'menu-settings-column-nonce');
  419.             if (isset($_REQUEST['nav-menu-locations']))
  420.                 set_theme_mod('nav_menu_locations', array_map('absint', $_REQUEST['menu-locations']));
  421.             elseif (isset($_REQUEST['menu-item']))
  422.                 wp_save_nav_menu_items($nav_menu_selected_id, $_REQUEST['menu-item']);
  423.             break;
  424.         case 'update':
  425.             check_admin_referer('update-nav_menu', 'update-nav-menu-nonce');
  426.             foreach ($locations as $location => $description) {
  427.                 if ((empty($_POST['menu-locations']) || empty($_POST['menu-locations'][$location])) && isset($menu_locations[$location]) && $menu_locations[$location] == $nav_menu_selected_id)
  428.                     unset($menu_locations[$location]);
  429.             }
  430.             if (isset($_POST['menu-locations'])) {
  431.                 $new_menu_locations = array_map('absint', $_POST['menu-locations']);
  432.                 $menu_locations     = array_merge($menu_locations, $new_menu_locations);
  433.             }
  434.             set_theme_mod('nav_menu_locations', $menu_locations);
  435.         case 'locations':
  436.             if (isset($_POST['menu-locations'])) {
  437.                 check_admin_referer('save-menu-locations');
  438.                 $new_menu_locations = array_map('absint', $_POST['menu-locations']);
  439.                 $menu_locations     = array_merge($menu_locations, $new_menu_locations);
  440.                 set_theme_mod('nav_menu_locations', $menu_locations);
  441.                 $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Menu locations updated.', 'Nellie') . '</p></div>';
  442.             }
  443.             break;
  444.     }
  445. ?>
  446. <div id="menu-locations-wrap">
  447.  
  448. <?php
  449.     if (ac_n_get_curr_nellie()) {
  450.         _e('<p>Select <strong>Mob Menu</strong> for Mobile Menu Location and <strong>Nellie 1.4 Menu</strong> for Primary Menu Location</p>');
  451.     }
  452. ?>
  453.         <form method="post" action="<?php
  454.     echo esc_url(add_query_arg(array(
  455.         'action' => 'locations'
  456.     ), admin_url('admin.php?page=ac_nellie_options&tab=set_hp_menu_options')));
  457. ?>">
  458.        
  459.             <table class="widefat fixed" id="menu-locations-table">
  460.                 <thead>
  461.                 <tr>
  462.                     <th scope="col" class="manage-column column-locations"><?php
  463.     _e('Menu Location', 'Nellie');
  464. ?></th>
  465.                     <th scope="col" class="manage-column column-menus nellie1-4-menus"><?php
  466.     _e('Assigned Menu');
  467. ?></th>
  468.                 </tr>
  469.                 </thead>
  470.                 <tbody class="menu-locations">
  471.                 <?php
  472.     foreach ($locations as $_location => $_name) {
  473. ?>
  474.                     <tr class="menu-locations-row">
  475.                         <td class="menu-location-title"><label for="locations-<?php
  476.         echo $_location;
  477. ?>"><?php
  478.         echo $_name;
  479. ?></label></td>
  480.                         <td class="menu-location-menus">
  481.                             <select name="menu-locations[<?php
  482.         echo $_location;
  483. ?>]" id="locations-<?php
  484.         echo $_location;
  485. ?>">
  486.                                 <option value="0"><?php
  487.         printf('&mdash; %s &mdash;', esc_html__('Select a Menu'));
  488. ?></option>
  489.                                 <?php
  490.         foreach ($nav_menus as $menu):
  491. ?>
  492.                                     <?php
  493.             $selected = isset($menu_locations[$_location]) && $menu_locations[$_location] == $menu->term_id;
  494. ?>
  495.                                     <option <?php
  496.             if ($selected)
  497.                 echo 'data-orig="true"';
  498. ?> <?php
  499.             selected($selected);
  500. ?> value="<?php
  501.             echo $menu->term_id;
  502. ?>">
  503.                                         <?php
  504.             echo wp_html_excerpt($menu->name, 40, '&hellip;');
  505. ?>
  506.                                     </option>
  507.                                 <?php
  508.         endforeach;
  509. ?>
  510.                             </select>
  511.                            
  512.                         </td><!-- .menu-location-menus -->
  513.                     </tr><!-- .menu-locations-row -->
  514.                 <?php
  515.     }
  516. ?>
  517.                 </tbody>
  518.             </table>
  519.             <input type="submit" name="submit" id="submit" class="ac-admin-buttons" value="<?php
  520.     _e('Save Changes');
  521. ?>"  />
  522.             <?php
  523.     wp_nonce_field('save-menu-locations');
  524. ?>
  525.            
  526.            
  527.         </form>
  528.     </div><!-- #menu-locations-wrap -->
  529. <?php
  530. }
  531. function footer_page_callback()
  532. {
  533.     echo '<h2 id="tabbed-options-heading">' . __('Footer Builder', 'Nellie') . '</h2>';
  534.     echo '<div class="dfb-heading">' . __('This theme uses the built-in <a href="https://ayanize.com/product/de-footer-builder/" target="_blank">DE Footer Builder</a>. Click the button below to style or rebuild the footer section', 'Nellie') . '</div>';
  535.     $args     = array(
  536.         'post_type' => 'custom-footer',
  537.         'post_status' => 'publish'
  538.     );
  539.     $hasposts = get_posts($args);
  540.     if ($hasposts) {
  541.         $args = array(
  542.             'post_type' => 'custom-footer',
  543.             'post_status' => 'publish'
  544.         );
  545.         $loop = new WP_Query($args);
  546.         while ($loop->have_posts()):
  547.             $loop->the_post();
  548.             $id = get_the_id();
  549.         endwhile;
  550.         $post_link = get_edit_post_link($id);
  551.         echo '<a class="footer-builder" href="' . $post_link . '">' . __('Footer Builder', 'Nellie') . '</a>';
  552.     } else {
  553.         $new_header_link = admin_url('post-new.php?post_type=custom-footer');
  554.         echo '<a class="footer-builder" href="' . $new_header_link . '">' . __('Create Footer', 'Nellie') . '</a>';
  555.     }
  556. }
  557. function code_page_callback()
  558. {
  559.     echo '<h2 id="tabbed-options-heading">' . __('Custom Styling', 'Nellie') . '</h2>';
  560.     get_template_part('includes/branding/code/options');
  561. }
  562. function login_page_callback()
  563. {
  564.     get_template_part('includes/login/settings-options');
  565. }
  566. function branding_page_callback()
  567. {
  568.     get_template_part('includes/branding/options');
  569. }
  570. function maps_page_callback()
  571. {
  572.     get_template_part('includes/maps/options');
  573. }
  574. function wc_page_callback()
  575. {
  576.     get_template_part('woocommerce/options');
  577. }
  578. function misc_page_callback()
  579. {
  580.     get_template_part('includes/branding/misc/options');
  581. }
  582. function sc_page_callback()
  583. {
  584.     get_template_part('includes/sc/options');
  585. }
  586. add_action('admin_init', 'ac_n_found_missing_tabs');
  587. function ac_n_found_missing_tabs()
  588. {
  589.     global $current_user;
  590.     $user_id = $current_user->ID;
  591.     if (isset($_GET['ac_n_found_missing_tabs']) && '0' == $_GET['ac_n_found_missing_tabs']) {
  592.         add_user_meta($user_id, 'ac_n_missing_tabs_notice', 'true', true);
  593.     }
  594. }
  595. function ac_n_missing_tabs_init()
  596. {
  597.     global $woocommerce, $current_user;
  598.     $user_id = $current_user->ID;
  599.     if (!ac_n_get_curr_nellie()) {
  600.         return;
  601.     }
  602.     $hide_url = add_query_arg('ac_n_found_missing_tabs', '0');
  603.     if (!get_user_meta($user_id, 'ac_n_missing_tabs_notice') && class_exists('woocommerce')) {
  604.         $output = __('<p class="missing-tabs">Not able to find the <strong>Demo Import</strong> or <strong>Homepage & Menu</strong> Settings Tabs? Visit <strong>Misc</strong> Settings Tab and enable the last option field. <a class="missing-tabs-link" href="' . $hide_url . '">Yes, I know. Don\'t bug me again</a> <a href="#" class="ac_admin_help_text"><span>To make Nellie Options Page less cluttered , Nellie will hide the Demo Import and Homepage & Menu Settings Tabs when their jobs are done. However, if for some reasons, you do not see them or want to bring them back, follow the note here</span></a></p>', 'Nellie');
  605.         echo $output;
  606.     }
  607. }
  608. add_action('ac_tabs', 'ac_n_missing_tabs_init');
  609. function ac_get_theme_n_ver()
  610. {
  611.     $theme   = wp_get_theme('Nellie');
  612.     $version = $theme->get('Version');
  613.     echo $version;
  614. }
  615. function ac_n_show_lang_notice()
  616. {
  617.     global $current_user;
  618.     $user_id    = $current_user->ID;
  619.     $show_how   = ac_n_show_how_lang();
  620.     $hide_url_3 = add_query_arg('ac_n_lang_nag_ignore_3', '0');
  621.     if (!get_user_meta($user_id, 'ac_wc_ignore_lang_notice_3') && class_exists('woocommerce')) {
  622.         printf(__('<span class="n-new-lang-notice">Nellie is now available in 7 languages. ', 'Nellie') . __('<strong>English, Spanish, Portuguese, German, French, Dutch</strong> and <strong>Italian</strong>. ', 'Nellie') . __('%2$s | <a class="ac-nag-close" href="%1$s">Close</a></span>', 'Nellie'), $hide_url_3, $show_how);
  623.     }
  624. }
  625. function ac_n_show_how_lang()
  626. {
  627.     $content = __('<div id="show_how"><a href="#">Show How</a><span class="show_how_content">Please go to <strong>Settings > General > Site Language</strong> field. (right at the bottom of the page) Select your language and Save changes.</span></div>', 'Nellie');
  628.     return $content;
  629. }
  630. function ac_n_lang_nag_ignore()
  631. {
  632.     global $current_user;
  633.     $user_id = $current_user->ID;
  634.     if (isset($_GET['ac_n_lang_nag_ignore_3']) && '0' == $_GET['ac_n_lang_nag_ignore_3']) {
  635.         add_user_meta($user_id, 'ac_wc_ignore_lang_notice_3', 'true', true);
  636.     }
  637. }
  638. add_action('admin_init', 'ac_n_lang_nag_ignore');
  639. function theme_options_functions()
  640. {
  641. ?>
  642.    
  643.        
  644.         <div id="ac-panel"><img src="<?php
  645.     echo get_stylesheet_directory_uri() . '/assets/imgs/nellie-dashicon-white.png';
  646. ?>"><h1><?php
  647.     _e('Nellie Options', 'Nellie');
  648. ?></h1><span class="nellie-ver"><?php
  649.     ac_get_theme_n_ver();
  650. ?></span>
  651. <?php
  652.     ac_n_show_lang_notice();
  653. ?></div>  
  654. <div class="wrap">  
  655.  
  656.  
  657. <?php
  658.     do_action('ac_tabs');
  659. ?>
  660.  
  661.         <?php
  662.     settings_errors();
  663. ?>  
  664.  
  665.         <?php
  666.     $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'import_demo_options';
  667. ?>  
  668.  
  669.         <h2 id ="ac-tabbed"class="nav-tab-wrapper">  
  670.        
  671.        
  672.        
  673.        
  674.             <a id="ac-demo-import" href="?page=ac_nellie_options&tab=import_demo_options" class="nav-tab <?php
  675.     echo $active_tab == 'import_demo_options' ? 'nav-tab-active' : '';
  676. ?>"><?php
  677.     _e('Demo Import', 'Nellie');
  678. ?></a>  
  679.             <a id="ac-hp-menu" href="?page=ac_nellie_options&tab=set_hp_menu_options" class="nav-tab <?php
  680.     echo $active_tab == 'set_hp_menu_options' ? 'nav-tab-active' : '';
  681. ?>"><?php
  682.     _e('Homepage &amp; Menu', 'Nellie');
  683. ?></a>
  684.  
  685. <a id="ac-gen-settings" href="?page=ac_nellie_options&tab=gen_options" class="nav-tab <?php
  686.     echo $active_tab == 'gen_options' ? 'nav-tab-active' : '';
  687. ?>"><?php
  688.     _e('General', 'Nellie');
  689. ?></a>
  690.  
  691. <a id="ac-wc-settings" href="?page=ac_nellie_options&tab=wc_options" class="nav-tab <?php
  692.     echo $active_tab == 'wc_options' ? 'nav-tab-active' : '';
  693. ?>"><?php
  694.     _e('WooCommerce', 'Nellie');
  695. ?></a>
  696.  
  697. <a id="ac-build-footer" href="?page=ac_nellie_options&tab=footer_builder_options" class="nav-tab <?php
  698.     echo $active_tab == 'footer_builder_options' ? 'nav-tab-active' : '';
  699. ?>"><?php
  700.     _e('Footer Builder', 'Nellie');
  701. ?></a>
  702.  
  703.  
  704.  <a id="ac-login-settings" href="?page=ac_nellie_options&tab=login_options" class="nav-tab <?php
  705.     echo $active_tab == 'login_options' ? 'nav-tab-active' : '';
  706. ?>"><?php
  707.     _e('Login Page', 'Nellie');
  708. ?></a>
  709. <a id="ac-branding-settings" href="?page=ac_nellie_options&tab=branding_options" class="nav-tab <?php
  710.     echo $active_tab == 'branding_options' ? 'nav-tab-active' : '';
  711. ?>"><?php
  712.     _e('Branding', 'Nellie');
  713. ?></a>
  714. <a id="ac-map-settings" href="?page=ac_nellie_options&tab=maps_options" class="nav-tab <?php
  715.     echo $active_tab == 'maps_options' ? 'nav-tab-active' : '';
  716. ?>"><?php
  717.     _e('Google Map', 'Nellie');
  718. ?></a>
  719. <a id="ac-misc-settings" href="?page=ac_nellie_options&tab=misc_options" class="nav-tab <?php
  720.     echo $active_tab == 'misc_options' ? 'nav-tab-active' : '';
  721. ?>"><?php
  722.     _e('Misc', 'Nellie');
  723. ?></a>
  724. <a id="ac-sc-settings" href="?page=ac_nellie_options&tab=sc_options" class="nav-tab <?php
  725.     echo $active_tab == 'sc_options' ? 'nav-tab-active' : '';
  726. ?>"><?php
  727.     _e('Shortcodes', 'Nellie');
  728. ?></a>
  729. <a id="ac-code-settings" href="?page=ac_nellie_options&tab=code_page_options" class="nav-tab <?php
  730.     echo $active_tab == 'code_page_options' ? 'nav-tab-active' : '';
  731. ?>"><?php
  732.     _e('Customization', 'Nellie');
  733. ?></a>
  734.  
  735.         </h2>  
  736.         <form method="post" action="options.php">  
  737.             <?php
  738.     if ($active_tab == 'import_demo_options') {
  739.         settings_fields('front_page_option');
  740.         do_settings_sections('front_page_option');
  741.     } else if ($active_tab == 'set_hp_menu_options') {
  742.         settings_fields('second_page_option');
  743.         do_settings_sections('second_page_option');
  744.     } else if ($active_tab == 'gen_options') {
  745.         settings_fields('gen_option');
  746.         do_settings_sections('gen_page_option');
  747.     } else if ($active_tab == 'footer_builder_options') {
  748.         settings_fields('footer_page_option');
  749.         do_settings_sections('footer_page_option');
  750.     } else if ($active_tab == 'login_options') {
  751.         settings_fields('login_page_option');
  752.         do_settings_sections('login_page_option');
  753.     } else if ($active_tab == 'branding_options') {
  754.         settings_fields('branding_page_option');
  755.         do_settings_sections('branding_page_option');
  756.     } else if ($active_tab == 'maps_options') {
  757.         settings_fields('maps_page_option');
  758.         do_settings_sections('maps_page_option');
  759.     } else if ($active_tab == 'wc_options') {
  760.         settings_fields('wc_page_option');
  761.         do_settings_sections('wc_page_option');
  762.     } else if ($active_tab == 'misc_options') {
  763.         settings_fields('misc_page_option');
  764.         do_settings_sections('misc_page_option');
  765.     } else if ($active_tab == 'sc_options') {
  766.         settings_fields('sc_page_option');
  767.         do_settings_sections('sc_page_option');
  768.     } else if ($active_tab == 'code_page_options') {
  769.         settings_fields('code_page_option');
  770.         do_settings_sections('code_page_option');
  771.     }
  772. ?>            
  773.         </form>
  774.     </div>
  775. <?php
  776. }
  777. function ac_force_plugin_activation()
  778. {
  779.     echo '<style>#setting-error-tgmpa {
  780.    width: 100%;height: 100%;position: absolute;z-index: 100;left: 0;z-index: 99999;text-align:center; border: none;
  781. }#setting-error-tgmpa p{font-size:25px;}.parent-theme {
  782.    display: none;
  783. }</style>';
  784.     echo '<style>.updated.woocommerce-message.wc-connect {display: none;}</style>';
  785. }
  786. function ac_show_select_header()
  787. {
  788.     global $current_user;
  789.     $user_id      = $current_user->ID;
  790.     $header_style = et_get_option('header_style', 'left');
  791.     $hide_url     = add_query_arg('ac_nag_ignore', '0');
  792.     if (!get_user_meta($user_id, 'ac_ignore_notice') && class_exists('woocommerce')) {
  793.         if ('centered' !== $header_style) {
  794.             echo '<div class="updated"><p>';
  795.             printf(__('Please select the suggested Header Format & Style. Go to Appearance > Customize > Header & Navigation > Header Format > Header Style and choose "Centered" | <a href="%1$s">Dismiss</a>', 'Nellie'), $hide_url);
  796.             echo "</p></div>";
  797.         }
  798.     }
  799. }
  800. function ac_nag_ignore()
  801. {
  802.     global $current_user;
  803.     $user_id = $current_user->ID;
  804.     if (isset($_GET['ac_nag_ignore']) && '0' == $_GET['ac_nag_ignore']) {
  805.         add_user_meta($user_id, 'ac_ignore_notice', 'true', true);
  806.     }
  807. }
  808. function ac_header_centered_default()
  809. {
  810.     et_update_option('header_style', 'centered');
  811. }
  812. function ac_top_search()
  813. {
  814.     $form = '<div class="search-bg">
  815.     <div class="ac-top-search-form"><form role="search" method="get" id="searchform" action="' . home_url('/') . '" >
  816.    <div>
  817.    <input placeholder="' . __('Search the site....', 'Nellie') . '" type="text" value="' . get_search_query() . '" name="s" id="s" />
  818.    <input type="submit" id="searchsubmit" value="' . esc_attr__('Go', 'Nellie') . '" />
  819.     <span class="close-button"></span>
  820.    </div>
  821.    </form> </div>
  822. <span class="srch-button"></span>
  823. </div>';
  824.     return $form;
  825. }
  826. function ac_wc_sidebar()
  827. {
  828.     ob_start();
  829.     $output = dynamic_sidebar('ac-woo-sidebar');
  830.     $output = ob_get_contents();
  831.     ob_end_clean();
  832.     return $output;
  833. }
  834. function ac_custom_modules()
  835. {
  836.     if (class_exists('ET_Builder_Module')) {
  837.         include('inc/modules/blog-ac.php');
  838.     }
  839. }
  840. function call_ac_custom_modules()
  841. {
  842.     global $pagenow;
  843.     $is_admin              = is_admin();
  844.     $action_hook           = $is_admin ? 'wp_loaded' : 'wp';
  845.     $required_admin_pages  = array(
  846.         'edit.php',
  847.         'post.php',
  848.         'post-new.php',
  849.         'admin.php',
  850.         'admin-ajax.php'
  851.     );
  852.     $specific_filter_pages = array(
  853.         'edit.php',
  854.         'admin.php'
  855.     );
  856.     if (!$is_admin || ($is_admin && in_array($pagenow, $required_admin_pages) && (!in_array($pagenow, $specific_filter_pages)))) {
  857.         add_action($action_hook, 'ac_custom_modules', 9789);
  858.     }
  859. }
  860. call_ac_custom_modules();
  861. function ac_call_custom_gf()
  862. {
  863.     wp_register_style('ac-gf-playfair', 'https://fonts.googleapis.com/css?family=Playfair+Display:400,400italic,700');
  864.     wp_register_style('ac-gf-lora', 'https://fonts.googleapis.com/css?family=Lora:400,400italic,700');
  865.     wp_register_style('ac-gf-open-sans-condensed', 'https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300');
  866.     wp_register_style('ac-gf-quicksand', 'https://fonts.googleapis.com/css?family=Quicksand:400,700');
  867.     wp_register_style('ac-gf-roboto', 'https://fonts.googleapis.com/css?family=Roboto:400,300');
  868.     wp_enqueue_style('ac-gf-lora');
  869.     wp_enqueue_style('ac-gf-playfair');
  870.     wp_enqueue_style('ac-gf-open-sans-condensed');
  871.     wp_enqueue_style('ac-gf-quicksand');
  872.     wp_enqueue_style('ac-gf-roboto');
  873. }
  874. function ac_single_post_check()
  875. {
  876.     if (is_single()) {
  877.         global $post;
  878. ?>
  879.        
  880.  
  881.     <div class="author-bio">
  882.     <div class="author-bio-img">
  883.             <?php
  884.         $avatar    = get_avatar(get_the_author_meta('email'), '150');
  885.         $author_id = get_queried_object()->post_author;
  886.         $username  = get_the_author_meta('user_login', $author_id);
  887.         $url       = get_author_posts_url($author_id);
  888. ?>
  889.                
  890.                 <?php
  891.         echo '<a class="ac-author" href="' . $url . '">' . $avatar . '</a>';
  892. ?>
  893.             </div>
  894.             <div class="author-bio-content">
  895.            
  896.            
  897.             <div class="author-info">
  898.                 <h3 class="author-bio-title"><?php
  899.         echo et_pb_get_the_author_posts_link();
  900. ?></h3>
  901.                 <p class="author-bio-description"><?php
  902.         echo get_the_author_meta('user_description');
  903. ?></p>
  904.                
  905.                
  906.                 <ul class="ac-profile-icons">
  907.                     <?php
  908.         $user_site = get_the_author_meta('user_url');
  909.         if ($user_site && $user_site != '') {
  910.             echo '<li class="url"><a href="' . esc_url($user_site) . '"></a></li>';
  911.         }
  912.         $twitter_profile = get_the_author_meta('twitter');
  913.         if ($twitter_profile && $twitter_profile != '') {
  914.             echo '<li class="twitter"><a href="' . esc_url($twitter_profile) . '"></a></li>';
  915.         }
  916.         $facebook_profile = get_the_author_meta('facebook');
  917.         if ($facebook_profile && $facebook_profile != '') {
  918.             echo '<li class="facebook"><a href="' . esc_url($facebook_profile) . '"></a></li>';
  919.         }
  920.         $google_profile = get_the_author_meta('gplus');
  921.         if ($google_profile && $google_profile != '') {
  922.             echo '<li class="google"><a href="' . esc_url($google_profile) . '" rel="author"></a></li>';
  923.         }
  924.         $linkedin_profile = get_the_author_meta('linkedin');
  925.         if ($linkedin_profile && $linkedin_profile != '') {
  926.             echo '<li class="linkedin"><a href="' . esc_url($linkedin_profile) . '"></a></li>';
  927.         }
  928.         $instagram_profile = get_the_author_meta('instagram');
  929.         if ($instagram_profile && $instagram_profile != '') {
  930.             echo '<li class="instagram"><a href="' . esc_url($instagram_profile) . '"></a></li>';
  931.         }
  932.         $pinterest_profile = get_the_author_meta('pinterest');
  933.         if ($pinterest_profile && $pinterest_profile != '') {
  934.             echo '<li class="pinterest"><a href="' . esc_url($pinterest_profile) . '"></a></li>';
  935.         }
  936. ?>
  937.                 </ul>
  938.             </div>
  939.             </div>
  940. <!--END .author-bio-->
  941. </div>
  942.    
  943.     <?php
  944.     }
  945. }
  946. add_action('ac_after_content', 'ac_single_post_check');
  947. function ac_switch_small_logo_header()
  948. {
  949.     $img     = get_option('ac_switch_logo_option');
  950.     $default = get_stylesheet_directory_uri() . '/assets/imgs/logo-scroll.png';
  951.     $url     = get_home_url();
  952.     if (get_option('ac_misc_remove_header_smalllogo') == 1) {
  953.         return;
  954.     }
  955.     if (get_option('ac_switch_logo_option')) {
  956.         echo '<div class="small-logo"><a href="' . esc_url($url) . '"><img src="' . $img . '"></a></div>';
  957.     } else {
  958.         echo '<div class="small-logo"><a href="' . esc_url($url) . '"><img src="' . $default . '"></a></div>';
  959.     }
  960. }
  961. function ac_modify_contact_methods($profile_fields)
  962. {
  963.     $profile_fields['twitter']   = __('Twitter');
  964.     $profile_fields['facebook']  = __('Facebook');
  965.     $profile_fields['gplus']     = __('Google+');
  966.     $profile_fields['linkedin']  = __('LinkedIn');
  967.     $profile_fields['instagram'] = __('Instagram');
  968.     $profile_fields['pinterest'] = __('Pinterest');
  969.     return $profile_fields;
  970. }
  971. function show_ac_wc_tab()
  972. {
  973.     if ('publish' == get_post_status('987451248')) {
  974.         echo '<style>#ac-demo-import{display:none}</style>';
  975.     }
  976.     if (get_option('page_on_front') && class_exists('WooCommerce')) {
  977.         echo '<style>#ac-hp-menu{display:none;}</style>';
  978.     }
  979. }
  980. function ac_login_placeholder()
  981. {
  982.     echo '<script type="text/javascript">
  983. jQuery(document).ready(function(){jQuery(".login form .input, .login input[type=text]").attr("placeholder", "User Name");
  984.    jQuery("#user_pass").attr("placeholder", "User Password");  
  985. });
  986. </script>';
  987. }
  988. function ac_rename_login_register()
  989. {
  990.     if (get_option('ac_acct_login_register_txt')) {
  991.         echo '<span class="ac-login-pu-text">' . get_option('ac_acct_login_register_txt') . '</span>';
  992.     } else {
  993.         echo '<span class="ac-login-pu-text">' . __('Account', 'Nellie') . '</span>';
  994.     }
  995. }
  996. function switch_logo()
  997. {
  998.     $logo_Param = array(
  999.         'ac_shop_bg_image' => get_option('ac_shop_bg_image'),
  1000.         'ac_shop_page' => get_permalink(get_option('woocommerce_shop_page_id')),
  1001.         'ac_n_mob_default_menu' => (bool) get_option('ac_n_mob_default_menu'),
  1002.         'ac_gen_cust_header' => (bool) get_option('ac_gen_cust_header')
  1003.     );
  1004.     wp_localize_script('ac-front-js', 'logoParam', $logo_Param);
  1005.     wp_enqueue_script('ac-front-js');
  1006. }
  1007. function ac_misc_settings_register()
  1008. {
  1009.     register_setting('misc-settings-group', 'ac_switch_logo_option');
  1010.     register_setting('misc-settings-group', 'ac_misc_remove_header_bg');
  1011.     register_setting('misc-settings-group', 'ac_misc_remove_header_cart');
  1012.     register_setting('misc-settings-group', 'ac_misc_remove_header_loginreg');
  1013.     register_setting('misc-settings-group', 'ac_misc_remove_header_smalllogo');
  1014.     register_setting('misc-settings-group', 'ac_misc_remove_header_style');
  1015.     register_setting('misc-settings-group', 'ac_misc_remove_header_search');
  1016.     register_setting('misc-settings-group', 'ac_misc_remove_header_format');
  1017.     register_setting('misc-settings-group', 'ac_get_email');
  1018.     register_setting('misc-settings-group', 'ac_get_phone');
  1019.     register_setting('misc-settings-group', 'ac_misc_disable_search_bar');
  1020.     register_setting('misc-settings-group', 'ac_misc_disable_mob_header');
  1021.     register_setting('misc-settings-group', 'ac_misc_add_header_bg');
  1022.     register_setting('misc-settings-group', 'ac_misc_back_header_menu_tabs');
  1023. }
  1024. function ac_front_login_fail($username)
  1025. {
  1026.     $referrer = $_SERVER['HTTP_REFERER'];
  1027.     if (!empty($referrer) && !strstr($referrer, 'wp-login') && !strstr($referrer, 'wp-admin')) {
  1028.         wp_redirect(home_url('my-account/login-failed/'));
  1029.         exit;
  1030.     }
  1031. }
  1032. function ac_custom_css_bg()
  1033. {
  1034.     $img     = get_option('ac_misc_add_header_bg');
  1035.     $default = get_stylesheet_directory_uri() . '/assets/imgs/checkered.jpg';
  1036.     if ($img) {
  1037.         echo '<style>#main-header {background-image: url("' . $img . '");}</style>';
  1038.         echo '<style>@media only screen and (max-width:980px){
  1039.         #page-container #main-header.et-fixed-header{
  1040.         background-image: url("' . $img . '");}}</style>';
  1041.     } else {
  1042.         echo '<style>#main-header {background-image: url("' . $default . '");</style>';
  1043.         echo '<style>@media only screen and (max-width:980px){
  1044.         #page-container #main-header.et-fixed-header{
  1045.         background-image: url("' . $default . '");}}</style>';
  1046.     }
  1047. }
  1048. function ac_custom_css()
  1049. {
  1050.     if (get_option('ac_misc_disable_search_bar') == 1) {
  1051.         echo '<style>
  1052.           @media only screen and (min-width: 980px){
  1053.           .pro-srch.stick{position:fixed;max-width:84%;}</style>';
  1054.     }
  1055.     if (get_option('ac_misc_disable_mob_header') == 1) {
  1056.         echo '<style>.et_fixed_nav #main-header {
  1057.    position: absolute;
  1058. }</style>';
  1059.     }
  1060. }
  1061. function ac_branding_themes($themes)
  1062. {
  1063.     $theme_opt_n = get_option('ac_branding_remove_nellie_themes');
  1064.     $theme_opt_d = get_option('ac_branding_remove_divi_themes');
  1065.     $parent      = "Divi";
  1066.     $child       = "Nellie";
  1067.     if ($theme_opt_d) {
  1068.         unset($themes[$parent]);
  1069.     }
  1070.     if ($theme_opt_n) {
  1071.         unset($themes[$child]);
  1072.     }
  1073.     return $themes;
  1074. }
  1075. function ac_header_contacts()
  1076. {
  1077.     $email = get_option('ac_get_email');
  1078.     $phone = get_option('ac_get_phone');
  1079.     echo '<div class="ac-top-contacts">';
  1080.     if ($email) {
  1081.         echo '<span class="ac-top-email"><a href="mailto:' . $email . '"><span class="content">' . $email . '</span></a></span>';
  1082.     }
  1083.     if ($phone) {
  1084.         echo '<span class="ac-top-phone"><a href="tel:' . $phone . '"><span class="content">' . $phone . '</span></a></span>';
  1085.     }
  1086.     echo '</div>';
  1087. }
  1088. function ac_wc_mega_menu($atts)
  1089. {
  1090.     $atts = shortcode_atts(array(
  1091.         'per_page' => '4',
  1092.         'columns' => '1',
  1093.         'orderby' => 'title',
  1094.         'order' => 'desc',
  1095.         'cat' => '',
  1096.         'operator' => 'IN'
  1097.     ), $atts);
  1098.     if (!$atts['cat']) {
  1099.         return '';
  1100.     }
  1101.     $ordering_args = WC()->query->get_catalog_ordering_args($atts['orderby'], $atts['order']);
  1102.     $meta_query    = WC()->query->get_meta_query();
  1103.     $query_args    = array(
  1104.         'post_type' => 'product',
  1105.         'post_status' => 'publish',
  1106.         'ignore_sticky_posts' => 1,
  1107.         'orderby' => $ordering_args['orderby'],
  1108.         'order' => $ordering_args['order'],
  1109.         'posts_per_page' => $atts['per_page'],
  1110.         'meta_query' => $meta_query
  1111.     );
  1112.     $query_args    = ac_category_args($query_args, $atts['cat'], $atts['operator']);
  1113.     if (isset($ordering_args['meta_key'])) {
  1114.         $query_args['meta_key'] = $ordering_args['meta_key'];
  1115.     }
  1116.     $return = ac_product_loop($query_args, $atts, 'product_cat');
  1117.     WC()->query->remove_ordering_args();
  1118.     return $return;
  1119. }
  1120. function ac_category_args($args, $cat, $operator)
  1121. {
  1122.     if (!empty($cat)) {
  1123.         $args['tax_query'] = array(
  1124.             array(
  1125.                 'taxonomy' => 'product_cat',
  1126.                 'terms' => array_map('sanitize_title', explode(',', $cat)),
  1127.                 'field' => 'slug',
  1128.                 'operator' => $operator
  1129.             )
  1130.         );
  1131.     }
  1132.     return $args;
  1133. }
  1134. function ac_product_loop($query_args, $atts, $loop_name)
  1135. {
  1136.     global $woocommerce_loop;
  1137.     $products                    = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $query_args, $atts, $loop_name));
  1138.     $columns                     = absint($atts['columns']);
  1139.     $woocommerce_loop['columns'] = $columns;
  1140.     ob_start();
  1141.     if ($products->have_posts()):
  1142. ?>
  1143.             <?php
  1144.         woocommerce_product_loop_start();
  1145. ?>
  1146.                 <?php
  1147.         while ($products->have_posts()):
  1148.             $products->the_post();
  1149. ?>
  1150.                     <?php
  1151.             wc_get_template_part('content', 'product');
  1152. ?>
  1153.                 <?php
  1154.         endwhile;
  1155. ?>
  1156.             <?php
  1157.         woocommerce_product_loop_end();
  1158. ?>
  1159.         <?php
  1160.     endif;
  1161.     woocommerce_reset_loop();
  1162.     wp_reset_postdata();
  1163.     return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
  1164. }
  1165. function ac_add_options_toolbar($wp_admin_bar)
  1166. {
  1167.     if (!is_user_logged_in() || !current_user_can('manage_options') || get_option('ac_branding_hide_this_theme') == 1) {
  1168.         return;
  1169.     }
  1170.     $wp_admin_bar->add_menu(array(
  1171.         'parent' => 'appearance',
  1172.         'id' => 'nellie-opt',
  1173.         'title' => __('Nellie Options', 'Nellie'),
  1174.         'href' => admin_url('admin.php?page=ac_nellie_options')
  1175.     ));
  1176. }
  1177. function ac_noindex_404_template_page()
  1178. {
  1179.     $option = get_option('404page_page_id');
  1180.     if (is_page($option)) {
  1181.         echo '<meta name="robots" content="noindex,nofollow">';
  1182.     }
  1183. }
  1184. function display_post_type_meta()
  1185. {
  1186.     $category = get_the_category();
  1187.     $cpt      = get_option('ac_branding_rename_project_cpt');
  1188.     if (get_post_type() == 'project' && is_archive()) {
  1189.         global $post;
  1190.         $terms = wp_get_object_terms($post->ID, 'project_category');
  1191.         foreach ($terms as $term) {
  1192.             $count = $term->count;
  1193.         }
  1194.         printf(__('<div class="total-cat-posts">Total %1$s : %2$s </div>'), $cpt, $count);
  1195.     } else {
  1196.         echo '<div class="total-cat-posts">' . __('Total Posts :', 'Nellie') . $category[0]->category_count . '</div>';
  1197.     }
  1198. }
  1199. function ac_display_cpt_cat_name()
  1200. {
  1201.     if (get_post_type() == 'project' && is_archive()) {
  1202.         global $post;
  1203.         ob_start();
  1204.         $terms  = the_terms($post->ID, 'project_category');
  1205.         $output = ob_get_contents();
  1206.         ob_end_clean();
  1207.         printf(__(' <h1 class="cat-lists">Category : <span class="ac-author-tem"> %1$s </span></h1>', 'Nellie'), $output);
  1208.     } else {
  1209.         $cat = get_the_category_list(', ');
  1210.         printf(__(' <h1 class="cat-lists">Category: <span class="ac-author-tem"> %1$s </span></h1>', 'Nellie'), $cat);
  1211.     }
  1212. }
  1213. function ac_call_nav_des($item_output, $item, $depth, $args)
  1214. {
  1215.     if (!empty($item->description)) {
  1216.         $item_output = '<img src="' . $item->description . '">';
  1217.     }
  1218.     return $item_output;
  1219. }
  1220. add_filter('walker_nav_menu_start_el', 'ac_call_nav_des', 10, 4);
  1221. add_filter('nav_menu_css_class', 'ac_menu_des_bg_class', 10, 2);
  1222. function ac_menu_des_bg_class($classes, $item)
  1223. {
  1224.     if (!empty($item->description)) {
  1225.         $classes[] = 'menu-bg-img';
  1226.     }
  1227.     return $classes;
  1228. }
  1229. function ac_mob_menu_media()
  1230. {
  1231.     echo '<style>@media only screen and (min-width:1025px){
  1232.         .ac-menu {display: block;}.ac-mobile-menu, .ac-default-menu #mob-menu-container{display:none;}} @media only screen and (max-width:1024px){.ac-menu {display: none;}.ac-mobile-menu{display: block;}}   
  1233.     </style>';
  1234. }
  1235. add_action('wp_head', 'ac_mob_menu_media');
  1236. function css_adjust_1366px()
  1237. {
  1238.     if (!wp_is_mobile())
  1239.         return;
  1240.     echo '<style>@media only screen and (max-width: 1367px){
  1241. .home #main-header {background-color: rgba(0, 0, 0, 0.29);}.container.et_menu_container {z-index: 99; width: 100%; max-width:40%; display: inline-block; vertical-align: middle;}.ac-mobile-menu {display: block;}.ac-menu{display:;}}</style>';
  1242. }
  1243. add_action('wp_head', 'css_adjust_1366px');
  1244. function ac_n_custom_css_default_divi()
  1245. {
  1246.     echo '<style>';
  1247.     echo '@media only screen and (min-width: 1025px){#main-header.et-fixed-header{background-color:#fff}.home #main-header{background-color:transparent}#top-menu li.current-menu-item>a{color:#fff}.nav li ul{background-color:#111}#top-menu .sub-menu li a{color:#fff;font-family:inherit;text-transform:uppercase;font-size:16px;font-weight:300;letter-spacing:.5px;opacity:1}#main-header.et-fixed-header .logo_container{visibility:hidden;margin-top:-72px;opacity:0}}';
  1248.     echo '</style>';
  1249. }
  1250. add_action('wp_head', 'ac_n_custom_css_default_divi', 20);
  1251. if (get_option('ac_misc_remove_header_style') == 1) {
  1252.     remove_action('wp_head', 'ac_n_custom_css_default_divi', 20);
  1253. }
  1254. // register a mobile menu
  1255. function wdm_register_mobile_menu() {
  1256.     add_theme_support( 'nav-menus' );
  1257.     register_nav_menus( array('mobile-menu' => __( 'Mobile Menu', 'wdm' )) );
  1258. }
  1259. add_action( 'init', 'wdm_register_mobile_menu' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement