p =& $plugin; if ( $this->p->debug->enabled ) { $this->p->debug->mark(); } /* * See WpssoAbstractWpMeta->get_document_sso_tabs(). */ $this->p->util->add_plugin_filters( $this, array( 'mb_sso_prev_social_rows' => 4, 'mb_sso_prev_oembed_rows' => 4, ), PHP_INT_MIN ); // Run before any add-on filters. } public function filter_mb_sso_prev_social_rows( $table_rows, $form, $head_info, $mod ) { $og_prev_width = 600; $og_prev_height = 315; $og_prev_img_html = ''; $image_url = SucomUtil::get_first_mt_media_url( $head_info ); $canonical_url = $this->p->util->get_canonical_url( $mod, $add_page = false ); $shortlink_url = $mod[ 'is_post' ] ? $this->p->util->get_shortlink( $mod, $context = 'post' ) : $this->p->util->shorten_url( $canonical_url, $mod ); $have_sizes = isset( $head_info[ 'og:image:width' ] ) && $head_info[ 'og:image:width' ] > 0 && isset( $head_info[ 'og:image:height' ] ) && $head_info[ 'og:image:height' ] > 0 ? true : false; $is_sufficient = true === $have_sizes && $head_info[ 'og:image:width' ] >= $og_prev_width && $head_info[ 'og:image:height' ] >= $og_prev_height ? true : false; if ( ! empty( $image_url ) ) { if ( $have_sizes ) { $og_prev_img_html .= '
'; if ( ! $is_sufficient ) { $og_prev_img_html .= '

' . sprintf( _x( 'Image Size Smaller
than Suggested Minimum
of %s', 'preview image error', 'wpsso' ), $og_prev_width . 'x' . $og_prev_height . 'px' ) . '

'; } $og_prev_img_html .= '
'; } else { $og_prev_img_html .= '
'; $og_prev_img_html .= '

' . _x( 'Image Size Unknown
or Not Available', 'preview image error', 'wpsso' ) . '

'; $og_prev_img_html .= '
'; } } else { $og_prev_img_html .= '
'; $og_prev_img_html .= '

' . _x( 'No Open Graph Image Found', 'preview image error', 'wpsso' ) . '

'; $og_prev_img_html .= '
'; } $table_rows[ 'prev_canonical_url' ] = '' . $form->get_th_html( _x( 'Canonical URL', 'option label', 'wpsso' ), $css_class = 'medium nowrap' ) . '' . $form->get_no_input_clipboard( $canonical_url ) . ''; $table_rows[ 'prev_shortlink_url' ] = '' . $form->get_th_html( _x( 'Shortlink URL', 'option label', 'wpsso' ), $css_class = 'medium nowrap' ) . '' . $form->get_no_input_clipboard( $shortlink_url ) . ''; $table_rows[ 'subsection_prev_og' ] = '

' . _x( 'Facebook / Open Graph Example', 'metabox title', 'wpsso' ) . '

'; $table_rows[ 'prev_og' ] = '' . '
' . $og_prev_img_html . '
' . ( empty( $head_info[ 'og:title' ] ) ? '' : $head_info[ 'og:title' ] ) . '
' . ( empty( $head_info[ 'og:description' ] ) ? '' : $head_info[ 'og:description' ] ) . '
' . $_SERVER[ 'SERVER_NAME' ] . ( empty( $this->p->options[ 'add_meta_property_article:author' ] ) || empty( $head_info[ 'article:author:name' ] ) ? '' : ' | By ' . $head_info[ 'article:author:name' ] ) . '
'; $table_rows[ 'prev_og_footer' ] = '' . $this->p->msgs->get( 'info-meta-social-preview' ) . ''; return $table_rows; } public function filter_mb_sso_prev_oembed_rows( $table_rows, $form, $head_info, $mod ) { $json_url = $this->p->util->get_oembed_url( $mod, 'json' ); $xml_url = $this->p->util->get_oembed_url( $mod, 'xml' ); $data = $this->p->util->get_oembed_data( $mod, $oembed_width = 600 ); // Returns false on error. $table_rows[ 'oembed_json_url' ] = '' . $form->get_th_html( _x( 'oEmbed JSON URL', 'option label', 'wpsso' ), $css_class = 'medium' ) . '' . $form->get_no_input_clipboard( $json_url ) . ''; $table_rows[ 'oembed_xml_url' ] = '' . $form->get_th_html( _x( 'oEmbed XML URL', 'option label', 'wpsso' ), $css_class = 'medium' ) . '' . $form->get_no_input_clipboard( $xml_url ) . ''; $table_rows[ 'subsection_oembed_html' ] = '

' . _x( 'oEmbed HTML', 'metabox title', 'wpsso' ) . '

'; if ( ! empty( $data[ 'html' ] ) ) { $table_rows[ 'oembed_html' ] = '' . $data[ 'html' ] . ''; $table_rows[ 'oembed_footer' ] = '' . $this->p->msgs->get( 'info-meta-oembed-footer' ) . ''; } else { $table_rows[ 'no_oembed_html' ] = '

' . __( 'oEmbed HTML Not Available.', 'wpsso' ) . '

'; } return $table_rows; } } }