Skip to content

Commit a2c5303

Browse files
committed
修改widget函数注册
解决与NGG冲突的白屏问题(回滚)
1 parent 0a6e212 commit a2c5303

2 files changed

Lines changed: 21 additions & 37 deletions

File tree

apip-widgets.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function widget( $args, $instance ) {
123123
}
124124

125125
}
126-
add_action( 'widgets_init', create_function( '', 'return register_widget( "APIP_Widget_Related" );' ) );
126+
//add_action( 'widgets_init', create_function( '', 'return register_widget( "APIP_Widget_Related" );' ) );
127127

128128

129129
class APIP_Widget_Sameday_Post extends WP_Widget {
@@ -213,7 +213,7 @@ public function widget( $args, $instance ) {
213213

214214
}
215215

216-
add_action( 'widgets_init', create_function( '', 'return register_widget( "APIP_Widget_Sameday_Post" );' ) );
216+
//add_action( 'widgets_init', create_function( '', 'return register_widget( "APIP_Widget_Sameday_Post" );' ) );
217217

218218
class APIP_Widget_Recent extends WP_Widget {
219219

@@ -290,7 +290,7 @@ public function widget( $args, $instance ) {
290290

291291
}
292292

293-
add_action( 'widgets_init', create_function( '', 'return register_widget( "APIP_Widget_Recent" );' ) );
293+
//add_action( 'widgets_init', create_function( '', 'return register_widget( "APIP_Widget_Recent" );' ) );
294294

295295
/**
296296
* Custom Meta class
@@ -358,7 +358,7 @@ public function form( $instance ) {
358358
}
359359
}
360360

361-
add_action( 'widgets_init', create_function( '', 'return register_widget( "APIP_Widget_Meta" );' ) );
361+
//add_action( 'widgets_init', create_function( '', 'return register_widget( "APIP_Widget_Meta" );' ) );
362362

363363
/**
364364
* 自定义显示当前页面上filter用class
@@ -441,4 +441,18 @@ public function form( $instance ) {
441441
}
442442
}
443443

444-
add_action( 'widgets_init', create_function( '', 'return register_widget( "APIP_Widget_Hook_List" );' ) );
444+
function apip_widget_register() {
445+
$names = array(
446+
"APIP_Widget_Related",
447+
"APIP_Widget_Sameday_Post",
448+
"APIP_Widget_Recent",
449+
"APIP_Widget_Meta",
450+
"APIP_Widget_Hook_List",
451+
);
452+
foreach ($names as $wd) {
453+
register_widget($wd);
454+
}
455+
}
456+
457+
//add_action( 'widgets_init', create_function( '', 'return register_widget( "APIP_Widget_Hook_List" );' ) );
458+
add_action( 'widgets_init', 'apip_widget_register' );

apip.php

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Description: Plugins used by pewae
88
* Author: lifishake
99
* Author URI: http://pewae.com
10-
* Version: 1.30.1
10+
* Version: 1.30.2
1111
* License: GNU General Public License 3.0+ http://www.gnu.org/licenses/gpl.html
1212
*/
1313

@@ -44,23 +44,6 @@ function apip_plugin_activation()
4444
GROUP BY year, month ORDER BY year, month DESC ; ";
4545
$wpdb->query($sql);
4646

47-
$sql = "CREATE OR REPLACE VIEW `{$wpdb->prefix}v_taxonomy_summary`
48-
AS SELECT rel.`term_taxonomy_id`, COUNT(rel.`term_taxonomy_id`) AS `term_count`, tax.`taxonomy`, {$wpdb->prefix}terms.`name` AS `term_name`,
49-
CASE WHEN tax.`taxonomy` = 'post_tag' THEN 10
50-
WHEN tax.`parent` = 0 THEN 0
51-
WHEN tax.`parent` IN (SELECT `term_taxonomy_id` FROM `{$wpdb->prefix}term_taxonomy` WHERE `parent` = 0 ) THEN 1
52-
WHEN tax.`parent` IN (SELECT `term_taxonomy_id` FROM `{$wpdb->prefix}term_taxonomy` WHERE `parent` IN (SELECT `term_taxonomy_id` FROM `{$wpdb->prefix}term_taxonomy` WHERE `parent` = 0 )) THEN 2
53-
ELSE 3 END AS `term_level`,
54-
CASE WHEN COUNT(rel.`term_taxonomy_id`) = 1 THEN 1024
55-
WHEN tax.`taxonomy` = 'post_tag' THEN FLOOR(4096/COUNT(rel.`term_taxonomy_id`))
56-
WHEN tax.`parent` = 0 THEN 10
57-
WHEN tax.`parent` = 2599 THEN 1024
58-
WHEN tax.`parent` IN (SELECT `term_taxonomy_id` FROM `{$wpdb->prefix}term_taxonomy` WHERE `parent` = 0 ) THEN CEIL(1024/COUNT(rel.`term_taxonomy_id`))
59-
WHEN tax.`parent` IN (SELECT `term_taxonomy_id` FROM `{$wpdb->prefix}term_taxonomy` WHERE `parent` IN (SELECT `term_taxonomy_id` FROM `{$wpdb->prefix}term_taxonomy` WHERE `parent` = 0 )) THEN 1000
60-
ELSE 1580 END AS `term_weight`
61-
FROM `{$wpdb->prefix}term_relationships` rel, `{$wpdb->prefix}term_taxonomy` tax, `{$wpdb->prefix}terms` WHERE rel.term_taxonomy_id = tax.term_taxonomy_id AND tax.taxonomy in ('category','post_tag') AND `{$wpdb->prefix}terms`.`term_id` = rel.term_taxonomy_id GROUP BY rel.term_taxonomy_id ORDER BY term_count DESC";
62-
$wpdb->query($sql);
63-
6447
$sql = "CREATE OR REPLACE VIEW `{$wpdb->prefix}v_boring_summary`
6548
AS SELECT `comment_author_email`, SUM(`meta_value`) AS `boring_value`
6649
FROM `{$wpdb->prefix}comments`
@@ -117,8 +100,6 @@ function apip_plugin_deactivation()
117100
$wpdb->query($sql);
118101
$sql = "DROP VIEW IF EXISTS `{$wpdb->prefix}v_posts_count_monthly` ; ";
119102
$wpdb->query($sql);
120-
$sql = "DROP VIEW IF EXISTS `{$wpdb->prefix}v_taxonomy_summary` ; ";
121-
$wpdb->query($sql);
122103
$sql = "DROP VIEW IF EXISTS `{$wpdb->prefix}v_boring_summary` ; ";
123104
$wpdb->query($sql);
124105
}
@@ -408,13 +389,6 @@ function apip_init_actions()
408389
////0A.1屏蔽ngg带来的无用钩子
409390
if( class_exists('M_Third_Party_Compat') ) {
410391
apip_remove_anonymous_object_hook( 'the_content', 'M_Third_Party_Compat', 'check_weaverii' );
411-
apip_remove_anonymous_object_hook( 'the_post', 'M_Third_Party_Compat', 'add_ngg_pro_page_parameter' );
412-
apip_remove_anonymous_object_hook( 'wp', 'M_Third_Party_Compat', 'check_for_jquery_lightbox' );
413-
apip_remove_anonymous_object_hook( 'wp', 'M_Third_Party_Compat', 'bjlazyload' );
414-
apip_remove_anonymous_object_hook( 'plugins_loaded', 'M_Third_Party_Compat', 'wpml' );
415-
apip_remove_anonymous_object_hook( 'plugins_loaded', 'M_Third_Party_Compat', 'wpml_translation_management' );
416-
apip_remove_anonymous_object_hook( 'init', 'M_Third_Party_Compat', 'colorbox' );
417-
apip_remove_anonymous_object_hook( 'init', 'M_Third_Party_Compat', 'flattr' );
418392
}
419393
if( class_exists('C_NextGen_Shortcode_Manager') ) {
420394
apip_remove_anonymous_object_hook( 'the_content', 'C_NextGen_Shortcode_Manager', 'fix_nested_shortcodes' );
@@ -438,14 +412,10 @@ function apip_init_actions()
438412
apip_remove_anonymous_object_hook( 'the_content', 'M_Attach_To_Post', 'substitute_placeholder_imgs' );
439413
apip_remove_anonymous_object_hook( 'media_buttons', 'M_Attach_To_Post', 'add_media_button' );
440414
}
441-
if (class_exists('M_WordPress_Routing')) {
442-
apip_remove_anonymous_object_hook( 'template_redirect', 'M_WordPress_Routing', 'restore_request_uri' );
443-
}
444415
if( class_exists('C_NextGEN_Bootstrap') ) {
445416
//20180320删除。好像插件更新,这个钩子的参数发生了变化,php有错误产生。
446417
//apip_remove_anonymous_object_hook( 'wp_enqueue_scripts', 'C_NextGEN_Bootstrap', 'fix_jquery' );
447418
//apip_remove_anonymous_object_hook( 'wp_print_scripts', 'C_NextGEN_Bootstrap', 'fix_jquery' );
448-
apip_remove_anonymous_object_hook( 'wp', 'C_NextGEN_Bootstrap', 'schedule_cron_jobs' );
449419
}
450420
if( class_exists('C_Lightbox_Library_Manager') ) {
451421
//20180320删除。好像插件更新,这个钩子的参数发生了变化,php有错误产生。
@@ -3045,7 +3015,7 @@ function apip_heweather_retrieve($postid)
30453015

30463016
if (!isset($_POST)) return false;
30473017

3048-
if(empty($postid) || $_POST['post_type'] != 'post' ) return false;
3018+
if(empty($postid) || !isset($_POST['post_type']) || $_POST['post_type'] != 'post' ) return false;
30493019

30503020
if(isset($_POST['apip_heweather'])){
30513021
delete_post_meta($postid, 'apip_heweather');

0 commit comments

Comments
 (0)