trailingslashit( get_stylesheet_directory() ) . $template_dir, 10 => trailingslashit( get_template_directory() ) . $template_dir, 100 => give_get_templates_dir(), ]; $file_paths = apply_filters( 'give_template_paths', $file_paths ); // sort the file paths based on priority ksort( $file_paths, SORT_NUMERIC ); return array_map( 'trailingslashit', $file_paths ); } /** * Returns the template directory name. * * Themes can filter this by using the give_templates_dir filter. * * @since 1.0 * @return string */ function give_get_theme_template_dir_name() { return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); } /** * Adds Give Version to the tag * * @since 1.0 * @return void */ function give_version_in_header() { echo '' . "\n"; } add_action( 'wp_head', 'give_version_in_header' ); /** * Determines if we're currently on the Donations History page. * * @since 1.0 * @return bool True if on the Donations History page, false otherwise. */ function give_is_donation_history_page() { $ret = is_page( give_get_option( 'history_page' ) ); return apply_filters( 'give_is_donation_history_page', $ret ); } /** * Adds body classes for Give pages * * @since 4.0.0 updated with give-campaign-page * @since 1.0 * * @param array $class current classes * * @return array Modified array of classes */ function give_add_body_classes( $class ) { $classes = (array) $class; if ( give_is_success_page() ) { $classes[] = 'give-success'; $classes[] = 'give-page'; } if ( give_is_failed_transaction_page() ) { $classes[] = 'give-failed-transaction'; $classes[] = 'give-page'; } if ( give_is_donation_history_page() ) { $classes[] = 'give-donation-history'; $classes[] = 'give-page'; } if ( give_is_test_mode() ) { $classes[] = 'give-test-mode'; $classes[] = 'give-page'; } if ( give_is_campaign_page() ) { $classes[] = 'give-campaign-page'; $classes[] = 'give-page'; } // Theme-specific Classes used to prevent conflicts via CSS /* @var WP_Theme $current_theme */ $current_theme = wp_get_theme(); switch ( $current_theme->get_template() ) { case 'Divi': $classes[] = 'give-divi'; break; case 'Avada': $classes[] = 'give-avada'; break; case 'twentysixteen': $classes[] = 'give-twentysixteen'; break; case 'twentyseventeen': $classes[] = 'give-twentyseventeen'; break; case 'twentynineteen': $classes[] = 'give-twentynineteen'; break; } return array_unique( $classes ); } add_filter( 'body_class', 'give_add_body_classes' ); /** * Add Post Class Filter * * Adds extra post classes for forms * * @since 1.0 * * @param array $classes * @param string|array $class * @param int|string $post_id * * @return array */ function give_add_post_class( $classes, $class = '', $post_id = '' ) { if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { return $classes; } // @TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { unset( $classes[ $key ] ); } return $classes; } add_filter( 'post_class', 'give_add_post_class', 20, 3 ); /** * Get the placeholder image URL for forms etc * * @access public * @return string */ function give_get_placeholder_img_src() { $placeholder_url = esc_url( GIVE_PLUGIN_URL . 'build/assets/dist/images/give-placeholder.jpg'); return apply_filters( 'give_placeholder_img_src', $placeholder_url ); } /** * Global */ if ( ! function_exists( 'give_output_content_wrapper' ) ) { /** * Output the start of the page wrapper. */ function give_output_content_wrapper() { give_get_template_part( 'global/wrapper-start' ); } } if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { /** * Output the end of the page wrapper. */ function give_output_content_wrapper_end() { give_get_template_part( 'global/wrapper-end' ); } } /** * Single Give Form */ if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { function give_left_sidebar_pre_wrap() { echo apply_filters( 'give_left_sidebar_pre_wrap', '
' ); } } if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { function give_left_sidebar_post_wrap() { echo apply_filters( 'give_left_sidebar_post_wrap', '
' ); } } if ( ! function_exists( 'give_get_forms_sidebar' ) ) { function give_get_forms_sidebar() { give_get_template_part( 'single-give-form/sidebar' ); } } if ( ! function_exists( 'give_show_form_images' ) ) { /** * Output the donation form featured image. */ function give_show_form_images() { if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { give_get_template_part( 'single-give-form/featured-image' ); } } } if ( ! function_exists( 'give_template_single_title' ) ) { /** * Output the form title. */ function give_template_single_title() { give_get_template_part( 'single-give-form/title' ); } } /** * Conditional Functions */ if ( ! function_exists( 'is_give_form' ) ) { /** * is_give_form * * Returns true when viewing a single form. * * @since 1.6 * @since 2.10.4 Updated post type slug to match registration. * * @return bool */ function is_give_form() { return is_singular( [ 'give_forms' ] ); } } if ( ! function_exists( 'is_give_category' ) ) { /** * is_give_category * * Returns true when viewing give form category archive. * * @since 1.6 * * @param string $term The term slug your checking for. * Leave blank to return true on any. * Default is blank. * * @return bool */ function is_give_category( $term = '' ) { return is_tax( 'give_forms_category', $term ); } } if ( ! function_exists( 'is_give_tag' ) ) { /** * is_give_tag * * Returns true when viewing give form tag archive. * * @since 1.6 * * @param string $term The term slug your checking for. * Leave blank to return true on any. * Default is blank. * * @return bool */ function is_give_tag( $term = '' ) { return is_tax( 'give_forms_tag', $term ); } } if ( ! function_exists( 'is_give_taxonomy' ) ) { /** * is_give_taxonomy * * Returns true when viewing a give form taxonomy archive. * * @since 1.6 * * @return bool */ function is_give_taxonomy() { return is_tax( get_object_taxonomies( 'give_form' ) ); } }