Permalink
Browse files

Resilience / Kick calls to FWP API down from constructor to admin_ini…

…t to ensure that FWP has been loaded before we try to call out; check whether FeedWordPress classes exist before referring to them, so if we deactivate FWP before SIC 'Em, it doesn't blank-screen all of wp-admin with a fatal PHP error.
  • Loading branch information...
radgeek committed Apr 8, 2016
1 parent 7ecfff5 commit 60d1bd16d1bc7f2f6b071f9ea18e9e252787d939
Showing with 14 additions and 8 deletions.
  1. +14 −8 SicEm.php
View
@@ -38,11 +38,21 @@ public function __construct () {
// If user opts for it, put a gallery at the end of syndicated posts
add_filter('the_content', array(&$this, 'the_content'), 200000, 2);
+ if (WP_ADMIN) : // set up image picker through massive fuckery
+ add_action('admin_init', array($this, 'admin_init'), -10);
+ add_action('admin_init', array($this, 'fix_async_upload_image'), 10);
+ endif;
+ } /* SicEm::__construct() */
+
+ ////////////////////////////////////////////////////////////////////////////
+ // SETTINGS UI /////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+
+ public function admin_init () {
global $pagenow;
global $sicem_path;
- if (WP_ADMIN) : // set up image picker through massive fuckery
- add_action('admin_init', array(&$this, 'fix_async_upload_image'));
-
+
+ if (class_exists('FeedWordPressSettingsUI')) :
if ( FeedWordPressSettingsUI::is_admin() ) :
wp_enqueue_style( 'thickbox' );
wp_enqueue_script( 'sic-em-image-picker', WP_PLUGIN_URL.'/'.$sicem_path.'/image-picker.js',array('thickbox'), false, true );
@@ -52,12 +62,8 @@ public function __construct () {
add_filter( 'media_upload_tabs', array( $this, 'media_upload_tabs' ) );
endif;
endif;
- } /* SicEm::__construct() */
+ } /* SicEm::admin_init () */
- ////////////////////////////////////////////////////////////////////////////
- // SETTINGS UI /////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
-
public function diagnostics ($diag, $page) {
$diag['Syndicated Image Cacher']['sicem:capture'] = 'as syndicated images are captured or rejected for local copies';
$diag['Syndicated Image Cacher']['sicem:capture:error'] = 'when there is an error encountered when trying to capture a local copy of an image';

0 comments on commit 60d1bd1

Please sign in to comment.