Created
October 4, 2023 07:46
-
-
Save adczk/9f9663bd68f52796f311fccf3dbf55b4 to your computer and use it in GitHub Desktop.
SmartCrawl - Show Description & Focus Keywords on Posts/Pages list tables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: SmartCrawl - Show Description & Focus Keywords on Posts/Pages list tables. | |
* Plugin URI: https://wpmudev.com/ | |
* Description: SmartCrawl - Show Description & Focus Keywords on Posts/Pages list tables. | |
* Author: Konstantinos Xenos @ WPMUDEV | |
* | |
* Author URI: https://wpmudev.com/ | |
* License: GPLv2 or later | |
* | |
* Modified on Oct 4th 2023 to handle Focus keywords | |
* by adczk | |
* | |
* tested with Smartcrawl 3.7.2 | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
if ( ! class_exists( 'WPMUDEV_WDS_C_COLUMNS' ) ) { | |
class WPMUDEV_WDS_C_COLUMNS { | |
private static $_instance = null; | |
public static function get_instance() { | |
if ( is_null( self::$_instance ) ) { | |
self::$_instance = new WPMUDEV_WDS_C_COLUMNS(); | |
} | |
return self::$_instance; | |
} | |
/** | |
* Class constructor. | |
*/ | |
private function __construct() { | |
add_filter( 'manage_posts_columns', array( $this, 'wds_c_columns' ) ); | |
add_filter( 'manage_pages_columns', array( $this, 'wds_c_columns' ) ); | |
add_action( 'manage_posts_custom_column', array( $this, 'wds_c_columns_data' ), 10, 2 ); | |
add_action( 'manage_pages_custom_column', array( $this, 'wds_c_columns_data' ), 10, 2 ); | |
} | |
/** | |
* Add new columns. | |
*/ | |
public function wds_c_columns( $columns ) { | |
$columns['wds_c_description'] = 'Description'; | |
$columns['wds_c_keywords'] = 'Focus Keywords'; | |
return $columns; | |
} | |
/** | |
* Show column data. | |
*/ | |
public function wds_c_columns_data( $column_name, $post_ID ) { | |
if ( function_exists( 'smartcrawl_get_value' ) ) { | |
if ( 'wds_c_description' === $column_name ) { | |
echo smartcrawl_get_value( 'metadesc', $post_ID ); | |
} | |
if ( 'wds_c_keywords' === $column_name ) { | |
echo smartcrawl_get_value( 'focus-keywords', $post_ID ); | |
} | |
} | |
} | |
} | |
if ( ! function_exists( 'wpmudev_wds_c_columns' ) ) { | |
function wpmudev_wds_c_columns() { | |
return WPMUDEV_WDS_C_COLUMNS::get_instance(); | |
}; | |
add_action( 'plugins_loaded', 'wpmudev_wds_c_columns', 10 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment