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 | |
/* | |
Plugin Name: WP oEmbed Thumbnail | |
Version: 0.1-alpha | |
Description: WordPressが対応しているoEmbed対応サイトのURLを記事中に埋め込むとそのURLのサムネイルを取得してアイキャッチ画像に登録します。 | |
Author: kurozumi | |
Author URI: http://a-zumi.net | |
Plugin URI: http://a-zumi.net | |
Text Domain: wp-oembed-thumbnail |
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
/** | |
* 投稿済みメディアかチェックする | |
* @global type $post | |
* @global type $wp_embed | |
* @return type | |
*/ | |
add_action('wp_ajax_parse-embed', function() { | |
global $post, $wp_embed, $wpdb; | |
if ( ! $post = get_post( (int) $_POST['post_ID'] ) ) |
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
new WP_Check_Slug; | |
class WP_Check_Slug { | |
public function __construct() | |
{ | |
add_action('admin_footer-post-new.php', array($this, 'admin_footer')); | |
add_action('admin_footer-post.php', array($this, 'admin_footer')); | |
add_action('wp_ajax_check-slug', array($this, 'check_slug')); | |
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
if (!function_exists('get_rand_permalink')): | |
function get_rand_permalink() | |
{ | |
if($posts = get_posts(array('posts_per_page' => 1, 'orderby' => 'rand'))) | |
{ | |
$post = current($post); | |
return get_permalink($post->ID); | |
} | |
return home_url(); | |
} |
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
add_filter('single_post_title', function($post_title, $post){ | |
$categories = get_the_category( $post->ID ); | |
if($categories){ | |
return $post_title . sprintf("【%s】", implode("|", array_map(function($cat){ | |
return $cat->name; | |
}, $categories))); | |
}else{ | |
return $post_title; | |
} | |
}, 99, 2); |
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
wp_oembed_add_provider('#http://b\.hatena\.ne\.jp/.*#i', 'http://b.hatena.ne.jp/api/oembed', true); |
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
wp_oembed_add_provider('#http://.*\.hatenablog\.com/.*#i', 'http://hatenablog.com/oembed', true); |
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
add_action('create_term', function($term_id, $tt_id, $taxonomy){ | |
global $wpdb, $locale; | |
$term = get_term( $term_id, $taxonomy, ARRAY_A ); | |
$locale = strtolower($locale); | |
$slug = sprintf("%s-%s", $term['slug'], $locale); | |
if(preg_match("/-{$locale}$/i", $term['slug'])) | |
return; |
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
add_action('restrict_manage_posts', function() { | |
$selected = ( is_author() ) ? get_query_var( 'author' ) : 0; | |
$authors = get_users(array('fields' => 'ids')); | |
printf('<label class="screen-reader-text" for="author">%s</label>', __( 'Filter by author' )); | |
printf('<select id="filter-by-author" name="author">'); | |
printf('<option value="0">%s</option>', __('All author')); | |
foreach ( $authors as $author_id ) { | |
$author = get_userdata( $author_id ); | |
if($selected == $author->ID){ |
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
add_filter('widget_text', 'do_shortcode'); |
OlderNewer