{ $columns['seopress_alt_text'] = __('Alt text', 'wp-seopress'); return $columns; } /** * @since 4.4.0 * @see manage_' . $postType . '_posts_custom_column * * @param string $column * @param int $post_id * * @return void */ public function displayColumn($column, $post_id) { switch ($column) { case 'seopress_title': $metaPostTitle = get_post_meta($post_id, '_seopress_titles_title', true); $context = seopress_get_service('ContextPage')->buildContextWithCurrentId($post_id)->getContext(); $title = $this->tagsToStringService->replace($metaPostTitle, $context); if (empty($title)) { $title = $metaPostTitle; } printf('
%s
', esc_attr($post_id), $title); printf('', esc_attr($post_id), $metaPostTitle); break; case 'seopress_desc': $metaDescription = get_post_meta($post_id, '_seopress_titles_desc', true); $context = seopress_get_service('ContextPage')->buildContextWithCurrentId($post_id)->getContext(); $description = $this->tagsToStringService->replace($metaDescription, $context); if (empty($description)) { $description = $metaDescription; } printf('
%s
', esc_attr($post_id), $description); printf('', esc_attr($post_id), $metaDescription); break; case 'seopress_redirect_enable': if ('yes' == get_post_meta($post_id, '_seopress_redirections_enabled', true)) { echo ''; } break; case 'seopress_redirect_url': echo '
' . esc_html(get_post_meta($post_id, '_seopress_redirections_value', true)) . '
'; break; case 'seopress_canonical': echo '
' . esc_html(get_post_meta($post_id, '_seopress_robots_canonical', true)) . '
'; break; case 'seopress_tkw': echo '
' . esc_html(get_post_meta($post_id, '_seopress_analysis_target_kw', true)) . '
'; break; case 'seopress_noindex': if ('yes' == get_post_meta($post_id, '_seopress_robots_index', true)) { echo '' . __('noindex is on!', 'wp-seopress') . ''; } break; case 'seopress_nofollow': if ('yes' == get_post_meta($post_id, '_seopress_robots_follow', true)) { echo '' . __('nofollow is on!', 'wp-seopress') . ''; } break; case 'seopress_inbound': $dataApiAnalysis = get_post_meta($post_id, '_seopress_content_analysis_api', true); if (isset($dataApiAnalysis['internal_links']) && $dataApiAnalysis['internal_links'] !== null) { $count = $dataApiAnalysis['internal_links']; echo '
' . esc_html($count) . '
'; } elseif (get_post_meta($post_id, '_seopress_analysis_data')) { $data = get_post_meta($post_id, '_seopress_analysis_data', true); if (! empty($data['internal_links'])) { $count = $data['internal_links']['count']; echo '
' . esc_html($count) . '
'; } } break; case 'seopress_outbound': $dataApiAnalysis = get_post_meta($post_id, '_seopress_content_analysis_api', true); if (isset($dataApiAnalysis['outbound_links']) && $dataApiAnalysis['outbound_links'] !== null) { $count = $dataApiAnalysis['outbound_links']; echo '
' . esc_html($count) . '
'; } elseif (get_post_meta($post_id, '_seopress_analysis_data')) { $data = get_post_meta($post_id, '_seopress_analysis_data', true); if (! empty($data['outbound_links'])) { $count = count($data['outbound_links']); echo '
' . esc_html($count) . '
'; } } break; case 'seopress_score': $dataApiAnalysis = get_post_meta($post_id, '_seopress_content_analysis_api', true); if (isset($dataApiAnalysis['score']) && $dataApiAnalysis['score'] !== null) { echo '
'; if ($dataApiAnalysis['score'] === 'good') { echo '

' . __('Good', 'wp-seopress') . '

'; } else { echo '

' . __('Should be improved', 'wp-seopress') . '

'; } echo '
'; } else { if (get_post_meta($post_id, '_seopress_analysis_data')) { $ca = get_post_meta($post_id, '_seopress_analysis_data'); echo '
'; if (isset($ca[0]['score']) && 1 == $ca[0]['score']) { echo '

' . __('Good', 'wp-seopress') . '

'; } elseif (isset($ca[0]['score']) && '' == $ca[0]['score']) { echo '

' . __('Should be improved', 'wp-seopress') . '

'; } echo '
'; } } break; } } /** * @since 7.2.0 * @see manage_media_custom_column * * @param string $column * @param int $post_id * * @return void */ public function displayMediaColumn($column, $post_id) { switch ($column) { case 'seopress_alt_text': echo get_post_meta($post_id, '_wp_attachment_image_alt', true); } } /** * @since 6.5.0 * @see manage_edit' . $postType . '_sortable_columns * * @param string $columns * * @return array $columns */ public function sortableColumn($columns) { $columns['seopress_noindex'] = 'seopress_noindex'; $columns['seopress_nofollow'] = 'seopress_nofollow'; return $columns; } /** * @since 7.2.0 * @see manage_edit-media_sortable_columns * * @param string $columns * * @return array $columns */ public function sortableMediaColumn($columns) { $columns['seopress_alt_text'] = 'seopress_alt_text'; return $columns; } /** * @since 6.5.0 * @see pre_get_posts * * @param string $query * * @return void */ public function sortColumnsBy($query) { if (! is_admin()) { return; } $orderby = $query->get('orderby'); if ('seopress_noindex' == $orderby) { $query->set('meta_key', '_seopress_robots_index'); $query->set('orderby', 'meta_value'); } if ('seopress_nofollow' == $orderby) { $query->set('meta_key', '_seopress_robots_follow'); $query->set('orderby', 'meta_value'); } } /** * @since 7.2.0 * @see pre_get_posts * * @param string $query * * @return void */ public function sortMediaColumnsBy($query) { if (! is_admin()) { return; } $orderby = $query->get('orderby'); if ('seopress_alt_text' == $orderby) { $query->set('meta_key', '_wp_attachment_image_alt'); $query->set('orderby', 'meta_value'); } } } actions and filters registered with WordPress. */ private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { $hooks[] = array( 'hook' => $hook, 'component' => $component, 'callback' => $callback, 'priority' => $priority, 'accepted_args' => $accepted_args ); return $hooks; } /** * Register the filters and actions with WordPress. * * @since 1.0.0 */ public function run() { foreach ( $this->filters as $hook ) { add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); } foreach ( $this->actions as $hook ) { add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); } } }