This file contains hidden or 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
| // The HTML | |
| echo '<textarea id="fancy-textarea">' . esc_textarea($val) . '</textarea>'; | |
| //Enqueing JS & CSS and setting up | |
| function codemirror_enqueue_scripts($hook) { | |
| $cm_settings['codeEditor'] = wp_enqueue_code_editor(array('type' => 'text/css')); | |
| wp_localize_script('jquery', 'cm_settings', $cm_settings); | |
| wp_enqueue_script('wp-theme-plugin-editor'); | |
| wp_enqueue_style('wp-codemirror'); |
This file contains hidden or 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
| add_action( 'admin_print_scripts-post-new.php', 'your_prefix_enqueue_scripts' ); | |
| add_action( 'admin_print_scripts-post.php', 'your_prefix_enqueue_scripts' ); | |
| // OR | |
| function enqueue_my_scripts() { | |
| global $pagenow; | |
| if ( ! empty( $pagenow ) && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) { | |
| wp_enqueue_script(); | |
| } |
This file contains hidden or 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
| /* | |
| * Get The First Image From a Post | |
| */ | |
| function post_first_image() { | |
| global $post; | |
| ob_start(); | |
| ob_end_clean(); | |
| $output = preg_match_all( '/<img.+?src=[\'"]([^\'"]+)[\'"].*?>/i', $post->post_content, $matches ); | |
| if ( $output != 0 ) { |
This file contains hidden or 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
| function cf7_redriect() { | |
| var url = window.location.pathname.split('/'); | |
| if (typeof url[1] === 'undefined') { | |
| window.location.href = 'https://www.liferesolutions.com.au/thank-you-contact-form/'; | |
| } else { | |
| if (url[1] == 'eap') { | |
| window.location.href = 'https://www.liferesolutions.com.au/thank-you-eap/'; | |
| } else { | |
| window.location.href = 'https://www.liferesolutions.com.au/thank-you-contact-form/'; |
This file contains hidden or 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
| global $wp_query; | |
| $wp_query->set_404(); | |
| status_header( 404 ); | |
| get_template_part( 404 ); | |
| exit(); | |
| /** | |
| * Show 404 No Found Page on Single View of Custom Post. | |
| */ | |
| function wpse_128636_redirect_post() { |
This file contains hidden or 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
| /* | |
| * Show Only One Category on Archive Page. | |
| */ | |
| function wp98_pre_get_posts( $query ) { | |
| if ( is_post_type_archive( 'cpt_services' ) && $query->is_main_query() ) { | |
| $query->set( | |
| 'tax_query', array( | |
| array( | |
| 'taxonomy' => 'cpt_services_group', | |
| 'terms' => 'menu', |
This file contains hidden or 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
| function exclude_category( $query ) { | |
| if ( $query->is_home() && $query->is_main_query() ) { | |
| $query->set( 'cat', '-1,-1347' ); | |
| } | |
| } | |
| add_action( 'pre_get_posts', 'exclude_category' ); |
This file contains hidden or 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
| var stickyElement = $( "#list-faq-wrap" ); | |
| var stickyElementPos = stickyElement.offset(); | |
| $( window ).scroll( function () { | |
| var windowpos = $( window ).scrollTop(); | |
| if ( windowpos >= stickyElementPos.top - 20 ) { | |
| stickyElement.addClass( "stick" ); | |
| } else { | |
| stickyElement.removeClass( "stick" ); | |
| } | |
| } ); |
This file contains hidden or 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
| const item = { | |
| action: 'custom_add_to_cart', | |
| product_id: Button.getAttribute( 'data-product_id' ), | |
| quantity: document.querySelector( '.qty[name="quantity"]' ).value | |
| }; | |
| var formData = new FormData(); | |
| for ( let key in item ) { | |
| formData.append( key, item[key] ); | |
| } |
This file contains hidden or 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
| /** | |
| * Remove Width and Height Attributes From Images | |
| */ | |
| function remove_width_attribute( $html ) { | |
| $html = preg_replace( '/(width|height)="\d*"\s/', "", $html ); | |
| return $html; | |
| } | |
| add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 ); |