Last active
May 16, 2018 15:03
-
-
Save Nikschavan/a0287c2288e1fc9ef66605d8a3442a4e to your computer and use it in GitHub Desktop.
Astra Theme - Add 'Apply Now` button in the Header conditionally with a link to page with a form to apply.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // don't copy this line in your file. | |
// Condition to check if this page requires `Apply Now` button. | |
if ( 1481 === get_the_id() ) { | |
your_prefix_setup_header_button_apply_now(); | |
} | |
/** | |
* Setup filters for changing the values in the Astra Settings. | |
*/ | |
function your_prefix_setup_header_button_apply_now() { | |
add_filter( 'astra_get_option_header-main-rt-section', 'your_prefix_header_rt_text_html' ); | |
add_filter( 'astra_get_option_header-main-rt-section-html', 'your_prefix_header_rt_text_html_content' ); | |
} | |
/** | |
* Returns the item key for text-html area in the custom menu item. | |
* | |
* @return String option key for text-html area in the custom menu item. | |
*/ | |
function your_prefix_header_rt_text_html() { | |
return 'text-html'; | |
} | |
/** | |
* Returns markup required for the `Apply Now` button. | |
* | |
* This can be any HTML markup of your choice. | |
* Here 1792 is the ID for the page where the `Apply Now` form is. | |
* | |
* @return String HTML markup for the `Apply Now` button. | |
*/ | |
function your_prefix_header_rt_text_html_content() { | |
return | |
'<span class="top-nav-book-cta"> | |
<a href="'. get_permalink( 1702 ) .'">Apply Now</a> | |
</span>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment