-
AuthorPosts
-
September 22, 2018 at 2:41 pm #1013068
Best Kriesi-Support,
For a project I am looking for a function with which I can add a custom Enfold theme option tab. I made a screenshot that shows how I see it for me. Can you help me in this?
September 22, 2018 at 3:23 pm #1013077Hey FullPixel,
You can use this code to add a new tab + options (I extracted the code from a plugin I created):
add_filter('avf_option_page_init', 'add_option_tab', 10, 1); //Adds option page to Enfold theme option panel add_filter('avf_option_page_data_init','add_option_to_settings_page', 10, 1); //Adds options to the "Custom Post Types" option page function add_option_tab($avia_pages) { $avia_pages[] = array( 'slug' => 'eucookielawsettings', 'parent'=>'avia', 'icon'=>"hammer_screwdriver.png", 'title'=>__('EU Cookie Law','avia-eu-cookie-law')); return $avia_pages; } /* * Adds options to the "Custom Post Types" option page */ function add_option_to_settings_page($avia_elements) { $avia_elements[] = array( "slug" => "eucookielawsettings", "name" => __("Cookie Duration",'avia-eu-cookie-law'), "desc" => __("Select how many days to hide the cookie law banner (after it's been displayed to the user).",'avia-eu-cookie-law'), "id" => "cookielaw_cookie_duration", "type" => "select", "std" => 7, "subtype" => array( __('1 Day','avia-eu-cookie-law') => 1, __('3 Days','avia-eu-cookie-law') => 3, __('5 Days','avia-eu-cookie-law') => 5, __('7 Days','avia-eu-cookie-law') => 7, __('14 Days','avia-eu-cookie-law') => 14, __('28 Days','avia-eu-cookie-law') => 28, __('1 Year','avia-eu-cookie-law') => 365 )); $avia_elements[] = array( "slug" => "eucookielawsettings", "name" => __("Privacy/Cookies Page",'avia-eu-cookie-law'), "desc" => __("Please select the page (Privacy & Cookies Policy) that you would like your banner to click through to.",'avia-eu-cookie-law'), "id" => "cookielaw_information_page", "type" => "select", "subtype" => 'page'); $avia_elements[] = array( "slug" => "eucookielawsettings", "name" => __("Cookie Banner Message",'avia-eu-cookie-law'), "desc" => __("Please enter the message that you would like to dispay to your visitors. Make sure to add the [cookiepageurl] placeholder so that your page is linked up.",'avia-eu-cookie-law'), "id" => "cookielaw_message", "type" => "textarea", "std" => " <h4>Cookies Policy</h4> \n". 'Our Website uses cookies to improve your experience. Please visit our <a href="[cookiepageurl]">Cookie Policy</a> page for more information about cookies and how we use them. ' ); return $avia_elements; }
Best regards,
PeterSeptember 22, 2018 at 3:52 pm #1013085Hi Peter,
This is exactly what I was looking for. Is there a possibility to display the content from “Cookie Banner Message (En the other options)” in the front end with something of echo avia_get_option ( ‘cookie _banner_message ‘ ); ?
to get the data?And can you also share how I can change the tab of menu position?
Thank you very much for your quick help
September 22, 2018 at 4:07 pm #1013088Hi,
1) Afaik there’s no easy way to change the tab position. You would need to reorder $avia_elements array.
2) Yes you can get the option value by the id. I.e. the message setting has the id “cookielaw_message” and you can get it with
$message = avia_get_option('cookielaw_message');
If you want to echo it on the front end use`
$message = avia_get_option('cookielaw_message'); echo $message;
Best regards,
PeterSeptember 22, 2018 at 4:24 pm #1013090This reply has been marked as private.September 22, 2018 at 4:30 pm #1013093Hi,
Great, glad I could help you :)
Best regards,
Peter -
AuthorPosts
- The topic ‘Add a custom " Theme options " tab’ is closed to new replies.