title)) { if (is_front_page()) { $this->title = essb_option_value('sso_frontpage_title'); } else if (is_single () || is_page ()) { $this->title = get_post_meta ( get_the_ID(), 'essb_post_og_title', true ); if (empty($this->title) && essb_option_bool_value('activate_sw_bridge')) { $this->title = $this->sw_value('og_title'); } // import SEO details if (empty($this->title) && $this->wpseo_detected() && !essb_option_bool_value('deactivate_pair_yoast_sso')) { $this->title = get_post_meta( get_the_ID(), '_yoast_wpseo_opengraph-title' , true ); } if (empty($this->title) && $this->wpseo_detected() && !essb_option_bool_value('deactivate_pair_yoast_seo')) { $this->title = get_post_meta( get_the_ID(), '_yoast_wpseo_title' , true ); } // include WPSEO replace vars if ($this->wpseo_detected() && strpos($this->title, '%%') !== false && function_exists('wpseo_replace_vars')) { $this->title = wpseo_replace_vars($this->title, get_post(get_the_ID())); } if (empty($this->title)) { $this->title = trim( essb_core_convert_smart_quotes( htmlspecialchars_decode(get_the_title ())));; } } elseif ( is_search() ) { $this->title = sprintf( __( 'Search for "%s"', 'essb' ), esc_html( get_search_query() ) ); } elseif ( is_category() || is_tag() || is_tax() ) { if ( is_category() ) { $this->title = single_cat_title( '', false ); } elseif ( is_tag() ) { $this->title = single_tag_title( '', false ); } else { $this->title = single_term_title( '', false ); if ( $this->title === '' ) { $term = $GLOBALS['wp_query']->get_queried_object(); $this->title = $term->name; } } } elseif ( is_author() ) { $this->title = get_the_author_meta( 'display_name', get_query_var( 'author' ) ); } else { $this->title = get_bloginfo('name'); } } return $this->title; } /** * Generate URL * * @return string */ public function url() { if (!isset($this->url)) { if (is_front_page()) { $this->url = get_bloginfo('url'); } else if (is_single () || is_page ()) { $this->url = get_permalink(get_the_ID()); $custom_og_url = get_post_meta ( get_the_ID(), 'essb_post_og_url', true ); if ($custom_og_url != '') { $this->url = $custom_og_url; } } else if ( is_search() ) { $search_query = get_search_query(); // Regex catches case when /search/page/N without search term is itself mistaken for search term. R. if ( ! empty( $search_query ) && ! preg_match( '|^page/\d+$|', $search_query ) ) { $this->url = get_search_link(); } } elseif ( is_tax() || is_tag() || is_category() ) { $term = get_queried_object(); if ( ! empty( $term ) ) { $term_link = get_term_link( $term, $term->taxonomy ); if ( ! is_wp_error( $term_link ) ) { $this->url = $term_link; } else { $this->url = get_bloginfo('url'); } } } elseif ( is_author() ) { $this->url = get_author_posts_url( get_query_var( 'author' ), get_query_var( 'author_name' ) ); } else { $this->url = get_bloginfo('url'); } } return $this->url; } /** * Generate description * * @return string */ public function description() { if (!isset($this->description)) { if (is_front_page()) { $this->description = essb_option_value('sso_frontpage_description'); } else if (is_single () || is_page ()) { $this->description = get_post_meta ( get_the_ID(), 'essb_post_og_desc', true ); if (empty($this->description) && essb_option_bool_value('activate_sw_bridge')) { $this->description = $this->sw_value('og_description'); } // import SEO details if (empty($this->description) && $this->wpseo_detected() && !essb_option_bool_value('deactivate_pair_yoast_sso')) { $this->description = get_post_meta( get_the_ID(), '_yoast_wpseo_opengraph-description' , true ); } if (empty($this->description) && $this->wpseo_detected() && !essb_option_bool_value('deactivate_pair_yoast_seo')) { $this->description = get_post_meta( get_the_ID(), '_yoast_wpseo_metadesc' , true ); } if (empty($this->description)) { easy_share_deactivate(); $this->description = trim( essb_core_convert_smart_quotes( htmlspecialchars_decode(essb_core_get_post_excerpt(get_the_ID())))); easy_share_reactivate(); } } elseif ( is_category() || is_tag() || is_tax() ) { $this->description = strip_tags(term_description()); } elseif ( is_author() ) { $this->description = get_the_author_meta( 'description', get_query_var( 'author' ) ); } else { $this->description = get_bloginfo('description'); } } return $this->description; } /** * Generate Image * * @return string */ public function image() { if (!isset($this->image)) { if (is_front_page()) { $this->image = essb_option_value('sso_frontpage_image'); } else if (is_single () || is_page ()) { $this->image = get_post_meta ( get_the_ID(), 'essb_post_og_image', true ); if (empty($this->image) && essb_option_bool_value('activate_sw_bridge')) { $this->image = $this->sw_value('og_image'); } // import SEO details if (empty($this->image) && $this->wpseo_detected()) { $this->image = get_post_meta( get_the_ID(), '_yoast_wpseo_opengraph-image' , true ); } if (empty($this->image)) { $this->image = essb_core_get_post_featured_image(get_the_ID()); } } else { $this->image = essb_option_value('sso_frontpage_image'); } } if ($this->image == '') { $this->image = essb_option_value('sso_default_image'); } return $this->image; } /** * Generate additional images that customer can choose on post * @return array */ public function additional_images() { $image_list = array(); if (is_single () || is_page ()) { $fb_image1 = get_post_meta ( get_the_ID(), 'essb_post_og_image1', true ); $fb_image2 = get_post_meta ( get_the_ID(), 'essb_post_og_image2', true ); $fb_image3 = get_post_meta ( get_the_ID(), 'essb_post_og_image3', true ); $fb_image4 = get_post_meta ( get_the_ID(), 'essb_post_og_image4', true ); if (!empty($fb_image1) && is_string($fb_image1)) { $image_list[] = $fb_image1; } if (!empty($fb_image2) && is_string($fb_image2)) { $image_list[] = $fb_image2; } if (!empty($fb_image3) && is_string($fb_image3)) { $image_list[] = $fb_image3; } if (!empty($fb_image4) && is_string($fb_image4)) { $image_list[] = $fb_image4; } } return $image_list; } public function sw_value($key = '') { if (essb_option_bool_value('activate_sw_bridge') && function_exists('essb_sw_custom_data')) { $sw_setup = essb_sw_custom_data(); return isset($sw_setup[$key]) ? $sw_setup[$key] : ''; } else { return ''; } } }