Skip to content

Instantly share code, notes, and snippets.

@lvwzhen
Last active July 4, 2018 02:37
Show Gist options
  • Save lvwzhen/c1470c61c6c8c440a01c to your computer and use it in GitHub Desktop.
Save lvwzhen/c1470c61c6c8c440a01c to your computer and use it in GitHub Desktop.
wordpress function
//增强编辑器开始
function add_editor_buttons($buttons)
{
$buttons[] = 'fontselect';
$buttons[] = 'fontsizeselect';
$buttons[] = 'cleanup';
$buttons[] = 'styleselect';
$buttons[] = 'hr';
$buttons[] = 'del';
$buttons[] = 'sub';
$buttons[] = 'sup';
$buttons[] = 'copy';
$buttons[] = 'paste';
$buttons[] = 'cut';
$buttons[] = 'undo';
$buttons[] = 'image';
$buttons[] = 'anchor';
$buttons[] = 'backcolor';
$buttons[] = 'wp_page';
$buttons[] = 'charmap';
return $buttons;
}
add_filter('mce_buttons_3', 'add_editor_buttons');
//增强编辑器结束
/* 访问计数 */
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0";
}
return $count.'';
}
function setPostViews($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
//删除 google 字体
add_filter('gettext_with_context', 'wpjam_disable_google_fonts', 888, 4);
function wpjam_disable_google_fonts($translations, $text, $context, $domain)
{
$google_fonts_contexts = array('Open Sans font: on or off','Lato font: on or off','Source Sans Pro font: on or off','Bitter font: on or off');
if ($text == 'on' && in_array($context, $google_fonts_contexts)) {
$translations = 'off';
}
return $translations;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment