Ornek WP-CLI komutu
This file contains 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 | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly. | |
} | |
if ( defined( 'WP_CLI' ) && WP_CLI ) { | |
class WPH_CLI_Command extends WP_CLI_Command { | |
function __construct() { | |
} | |
function son_yazilar( $args, $assoc_args ) { | |
if ( ! ( $count = $assoc_args['count'] ) ) { | |
$count = 10; | |
} | |
$args = array( | |
'numberposts' => $count, | |
'orderby' => 'post_date', | |
'order' => 'DESC', | |
'post_type' => 'post', | |
'post_status' => 'publish', | |
'suppress_filters' => true, | |
); | |
$recent_posts = wp_get_recent_posts( $args, OBJECT ); | |
foreach ( $recent_posts as $post ) { | |
$title = str_pad( $post->post_title, 30, "." ); | |
echo WP_CLI::colorize( "%b$title%n " ) . "\n"; | |
} | |
} | |
} | |
WP_CLI::add_command( 'getir', 'WPH_CLI_Command' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment