get_active_languages(); } } } //Retrieve default WPML language if ( ! function_exists( 'cpotheme_wpml_default_language' ) ) { function cpotheme_wpml_default_language() { if ( cpotheme_wpml_active() ) { global $sitepress; return $sitepress->get_default_language(); } } } //Searches for a link inside a string. Used for post formats if ( ! function_exists( 'cpotheme_find_link' ) ) { function cpotheme_find_link( $content, $fallback ) { $link_url = ''; $link_pattern = '/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/'; $post_content = $content; if ( preg_match( $link_pattern, $post_content, $link_url ) ) { return $link_url[0]; } else { return $fallback; } } } //Retrieve page number for the current post or page if ( ! function_exists( 'cpotheme_current_page' ) ) { function cpotheme_current_page() { $current_page = 1; if ( is_front_page() ) { if ( get_query_var( 'page' ) ) { $current_page = get_query_var( 'page' ); } else { $current_page = 1; } } else { if ( get_query_var( 'paged' ) ) { $current_page = get_query_var( 'paged' ); } else { $current_page = 1; } } return $current_page; } } //Retrieve current post or taxonomy id if ( ! function_exists( 'cpotheme_current_id' ) ) { function cpotheme_current_id() { $current_id = false; if ( is_tax() || is_category() || is_tag() ) { $current_id = get_queried_object()->term_id; } else { global $post; if ( isset( $post->ID ) ) { $current_id = $post->ID; } else { $current_id = false; } } return $current_id; } } //Return true if posts should be displayed on homepage function cpotheme_show_posts() { $display = false; if ( ! is_front_page() || cpotheme_get_option( 'home_posts' ) === true ) { $display = true; } return $display; } //Return true if page title should be displayed function cpotheme_show_title() { $display = false; if ( ! is_front_page() && ! is_home() ) { $display = true; } return $display; } //Flush rewrite rules on theme activation add_action( 'after_switch_theme', 'cpotheme_rewrite_flush' ); function cpotheme_rewrite_flush() { flush_rewrite_rules(); } //Sanitize boolean values function cpotheme_sanitize_bool( $data ) { if ( true === $data ) { return true; } return false; } //Return the URL to the premium theme page function cpotheme_upgrade_link( $name = 'Customizer' ) { $url = esc_url_raw( CPOTHEME_PREMIUM_URL . '?utm_source=allegiant&utm_medium=customizer&utm_campaign=upsell' ); $link = '' . esc_attr( CPOTHEME_PREMIUM_NAME ) . ''; return $url; }