'顶部导航菜单',
'footer_menu' => '底部导航菜单',
));
}
//侧边栏注册
function geekpress_sidebar_reg()
{
register_sidebar(array(
'id' => 'index_sidebar',
'name' => '首页边栏',
'before_title' => '
CorePress主题,当前版本:" . THEME_VERSIONNAME . ",最新版本:{$set['info']['newversionname']}{$url}
";
}
add_filter('admin_footer_text', 'copay_footer_admin');
function corepress_dashboard_help()
{
global $set;
?>
感谢使用Corepress主题,这些信息可能对您有帮助
主题官网:https://www.lovestu.com
当前版本:
60 * 60) {
$url = 'http://theme.lovestu.com/version.php?site=' . get_bloginfo('siteurl') . '&n=1&v=' . THEME_VERSION;
$request = new WP_Http;
$result = $request->request($url);
if (!is_wp_error($result)) {
$json = json_decode($result['body'], true);
if (isset($json)) {
$set['info']['newversionname'] = $json['versionname'];
$set['info']['newversion'] = $json['version'];
$setdata['option'] = json_encode($set);
options::getInstance()->saveData($setdata);
}
}
update_option('corepress_updatetheme', time());
}
}
function corepress_comment_face($incoming_comment)
{
$pattern = '/\[f=(.*?)\]/';
$isMatched = preg_match_all($pattern, $incoming_comment, $match);
if ($isMatched == 0) {
return $incoming_comment;
}
$path = THEME_PATH . "/static/img/face/";
foreach ($match[1] as $facename) {
if (file_exists($path . $facename . '.gif')) {
$incoming_comment = str_replace("[f={$facename}]", '
', $incoming_comment);
}
}
return $incoming_comment;
}
function corepress_loginurl($url)
{
global $set;
$query = parse_url($url);
parse_str($query['query'], $output);
if ($set['user']['loginpage'] == 1) {
return $set['user']['lgoinpageurl'] . '?re=' . $output['redirect_to'];
}
return $url;
}
function corepress_addbutton()
{
//判断用户是否有编辑文章和页面的权限
if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
return;
}
//判断用户是否使用可视化编辑器
if (get_user_option('rich_editing') == 'true') {
file_load_js('jquery.min.js');
file_load_js('vue.min.js');
file_load_css('admin.css');
file_load_lib('element/index.css', 'css');
file_load_lib('element/index.js', 'js');
file_load_js('tools.js');
file_load_css('editor-window.css');
file_load_lib('layer/layer.js', 'js');
file_load_js('editor-functions.js');
add_filter('mce_external_plugins', 'corepress_add_editor_plugin');
}
}
function corepress_add_editor_plugin($plugin_array)
{
$plugin_array['gh-addShortCode'] = THEME_JS_PATH . '/editorButton.js';
return $plugin_array;
}
function corepress_add_media_button()
{
echo 'CorePress编辑器增强';
}
add_action('media_buttons', 'corepress_add_media_button');
add_action('edit_form_top', 'corepress_addbutton');
add_filter('comment_text', 'corepress_comment_face');
add_filter('comment_text_rss', 'corepress_comment_face');
add_filter('login_url', 'corepress_loginurl', 1);
/** 编辑器取消屏蔽功能
* @param $initArray
* @return mixed
*/
function mod_mce($initArray)
{
$initArray['verify_html'] = false;
return $initArray;
}
add_filter('tiny_mce_before_init', 'mod_mce');
add_action('add_meta_boxes', 'corepress_add_meta_box');
function corepress_add_meta_box()
{
add_meta_box('corepress_post_meta', 'CorePress文章设置', 'corepress_meta_box_form', 'page', 'advanced', 'high');
add_meta_box('corepress_post_meta', 'CorePress文章设置', 'corepress_meta_box_form', 'post', 'advanced', 'high');
}
function corepress_meta_box_form($post)
{
// 创建临时隐藏表单,为了安全
wp_nonce_field('corepress_meta_box', 'corepress_meta_box_nonce');
// 获取之前存储的值
$corepress_post_meta['set'] = json_decode(get_post_meta($post->ID, 'corepress_post_meta', true), true);
if (!isset($corepress_post_meta['set']['catalog'])) {
$corepress_post_meta['set']['catalog'] = 0;
}
if (!isset($corepress_post_meta['set']['seo']['open'])) {
$corepress_post_meta['set']['seo']['open'] = 0;
}
if (!isset($corepress_post_meta['set']['seo']['keywords'])) {
$corepress_post_meta['set']['seo']['keywords'] = '';
}
if (!isset($corepress_post_meta['set']['seo']['description'])) {
$corepress_post_meta['set']['seo']['description'] = '';
}
if (!isset($corepress_post_meta['set']['postshow'])) {
$corepress_post_meta['set']['postshow'] = '0';
}
?>
/', $content, $images);
print_r($images);
for ($i = 0; $i < count($images[1]); $i++) {
$replacestr = str_replace($images[1][$i], $images[1][$i] . ' img-lazyload', $images[0][$i]);
$replacestr = str_replace('src="' . $images[2][$i] . '"', 'data-original="' . $images[2][$i] . '"', $replacestr);
$content = str_replace($images[0][$i], $replacestr, $content);
}
return $content;*/
preg_match_all('/
/', $content, $images);
foreach ($images[0] as $item) {
//跳过base64图片
if (preg_match('/src="data:(.*?)"/', $item)==1) {
continue;
}
preg_match('/class="(.*?)"/', $item, $class);
$need_replace_str = $class[1];
$replace_str = $class[1] . ' img-lazyload';
$replace_str = str_replace($need_replace_str, $replace_str, $item);
$need_replace_str = $item;
$content = str_replace($need_replace_str, $replace_str, $content);
preg_match('/src="(.*?)"/', $replace_str, $class);
$need_replace_str ='src="'. $class[1].'"';
$need_replace_str2 = $replace_str;
$replace_str = str_replace($need_replace_str, 'data-original="'. $class[1].'"'.'src="'.file_get_img_url('loading.png').'"', $replace_str);
$content = str_replace($need_replace_str2, $replace_str, $content);
}
return $content;
}
add_filter('the_content', 'corePress_lazyload');
//禁止响应式图片
add_filter('wp_calculate_image_srcset', create_function('', 'return false;'));