From 95da0b97a45866aad3de14e3bfb79ad943421ebb Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Wed, 11 Mar 2015 22:36:27 +1100 Subject: [PATCH] Move widgets and importers to modules --- assets/css/menu.css | 6 +++ assets/fonts/sportspress.eot | Bin 6664 -> 6900 bytes assets/fonts/sportspress.svg | 2 + assets/fonts/sportspress.ttf | Bin 6484 -> 6720 bytes assets/fonts/sportspress.woff | Bin 6560 -> 6796 bytes includes/admin/class-sp-admin.php | 4 -- includes/class-sp-modules.php | 8 ++++ modules/sportspress-importers.php | 62 +++++++++++++++++++++++++++++ modules/sportspress-widgets.php | 63 ++++++++++++++++++++++++++++++ sportspress.php | 10 ----- 10 files changed, 141 insertions(+), 14 deletions(-) create mode 100644 modules/sportspress-importers.php create mode 100644 modules/sportspress-widgets.php diff --git a/assets/css/menu.css b/assets/css/menu.css index c087e7c5..bdadec72 100644 --- a/assets/css/menu.css +++ b/assets/css/menu.css @@ -113,6 +113,12 @@ .sp-icon-popup:before { content: "\f504"; } +.sp-icon-import:before { + content: "\f316"; +} +.sp-icon-export:before { + content: "\f317"; +} #adminmenu #toplevel_page_sportspress .toplevel_page_sportspress div.wp-menu-image:before, #adminmenu #menu-posts-sp_event .menu-icon-sp_event div.wp-menu-image:before, diff --git a/assets/fonts/sportspress.eot b/assets/fonts/sportspress.eot index 347aa9052a925c0cf34502010997cdc2dd33cb0a..22865901f349447b10aef002b780f4551356194f 100755 GIT binary patch delta 608 zcmeA$`C`iUMT&vJL24qK8H>^WUpFQ?OsP+Dv5#P2V3Yyj^u*!<1_lNJ1_mYzAkC4U zQ<)}gxOXX#@4&zys*;hKn8KWOua|*AJOwCkmH`xCe#FEAF;HL&&;gkR`Nbs+ z%s?pyDTT>7jMbVPK&Bmo0s{+!90MbR!bgsef*-{`N_=$v=>9R~W7EghPwJo9KXZN- zpUlT(&nPz8hsjp)H_tDgPdp!Z-tj!=dBXFE`vmu9?m67kxn;N|x&8r7XPmr|$z<{Y zChpBonFQGDnHY>2q!`aKZf1~RPz5?diA|PK(bPmu8N?6~GgdS*vt+ ztd_9@Ee6?Ztj=yMifP$d+?M%*ES;5>Hf!@2P9I*G8^87&#q-;IW#9(J3J_dWJ@*1e zPmU2cXH=d%MckXwc=8SL6cgrM%pX{$uzX-OVsm1f!LGud#y){Vi6f4ajWdAr2Mc&ODe3kv(5qX z9{~9+Ir+(nZjXHA7#PG;fP9zS#EJq2U4{cd{t6&pAulmkGIhZukz%0037`Wq3-XIg z7?^=l43Z|3a~P}DK};J41qK!d83slMg^wH`1wV>?l=$fS(fwn}$EJ_1pVU9If99Ml zz+^u;kjX~=2hRtdcRX)+p7K26dBA;)dn5NO?y1~T+~Qn+faWqz-pFLL`3;jG`{t`$ z-n=rvAgGJyxB1Gz4fFyKTvTwH2%{(4NSHG!PA-w~o_t&)R*gl2rG@1f>oqnVwjFH0 i*j3oKv47&2#qoqQf^!n*4K6jH>lhdmH~UF0V*~)mg=5 + + diff --git a/assets/fonts/sportspress.ttf b/assets/fonts/sportspress.ttf index afa503da31f4c6784f1dbacf26632f7a0c4a2a47..12159c3f9987f02bad449ae990b41e42f95fb9a1 100755 GIT binary patch delta 545 zcmca&biibSLVc2peFOsoqYMbACl(hlFfa%(FfdsFX^!-q$~0lay-R_72L=XFm5kKH z6y~gZy$lTEDL{F%44?q>BPJFge-4nZl95|dVYi))3CKSH~Ef5JfC^-c$q&T58I32ah^J^V?_&PIGKJ*>s}Y+M+YELU_B8eh97-HJDEg>QNv delta 324 zcmX?La>ZzZLVft3Fh2$cMj0R$Nlz>;U|?VnU|?V}0MZ=kIhASuc1;lm@+}w`M0_$* z6H}PukKSis5NiR-n`Hn6m>)4Q0r`7?e3gvck_xNstaE_;2S9#HPJVKt+an)21_tpI zAm1f7v7&%Mm*D`AzXHft$V<$XOkFTZq!=i00_cFug8bqV24k8yA0p2akm*n<77rA zi^&2^teY*F1lTt#a(VO0=p5Ini|4ob%D@eDEf8E(aGD6CCwGXOGb&C#AnrX`SRz)9 wMT4b<luD!Ctr7T*V~JUeCl}%pk>hmT@zK z1cNHj9wjzeMnzK-HDwS(M9f&x$jp`z$W?}kDT|vcGj8VM|96I;i<_UHn=uVU&gAFj z=J!cU^I>EFa%O^rfNJ=;HgogO<>ck%oSOy;MNGRQuv*3rv>0Tsu{yi4D5hm+aa-mK zvUFBj+N{kzoIboVH-7Cmis!fa%D~M83@!$Si>l{9F$AV3e-SfhRGzFO?#*aCxj;Nc zi+LCG2bL);A6SjpoY-cttFWiBPvB7Eh~s4A4B$M%`H#zmYZ5pWDR2HIzKjt7%XWcK delta 391 zcmeA%U0^I$?(gQtz{mguk_#BP!E^`%GTO-h;Q7Gwj^_=} zQ=UgW54ewUZ{(iEJ(XLETb%0;12fpuCX*AGI5)R439xU@ __( 'Tutorials', 'sportspress' ), 'icon' => 'dashicons dashicons-video-alt3', ), + 'widgets' => array( + 'label' => __( 'Widgets', 'sportspress' ), + 'icon' => 'dashicons dashicons-welcome-widgets-menus', + ), + 'importers' => array( + 'label' => __( 'Importers', 'sportspress' ), + 'icon' => 'sp-icon-import', + ), 'twitter' => array( 'label' => __( 'Twitter', 'sportspress' ), 'class' => 'SportsPress_Twitter', diff --git a/modules/sportspress-importers.php b/modules/sportspress-importers.php new file mode 100644 index 00000000..040148f8 --- /dev/null +++ b/modules/sportspress-importers.php @@ -0,0 +1,62 @@ +define_constants(); + + add_action( 'init', array( $this, 'includes' ) ); + } + + /** + * Define constants. + */ + private function define_constants() { + if ( !defined( 'SP_IMPORTERS_VERSION' ) ) + define( 'SP_IMPORTERS_VERSION', '1.7' ); + + if ( !defined( 'SP_IMPORTERS_URL' ) ) + define( 'SP_IMPORTERS_URL', plugin_dir_url( __FILE__ ) ); + + if ( !defined( 'SP_IMPORTERS_DIR' ) ) + define( 'SP_IMPORTERS_DIR', plugin_dir_path( __FILE__ ) ); + } + + /** + * Include importers. + */ + public function includes() { + if ( is_admin() && defined( 'WP_LOAD_IMPORTERS' ) ) { + include( SP()->plugin_path() . '/includes/admin/class-sp-admin-importers.php' ); + } + } +} + +endif; + +if ( get_option( 'sportspress_load_importers_module', 'yes' ) == 'yes' ) { + new SportsPress_Importers(); +} diff --git a/modules/sportspress-widgets.php b/modules/sportspress-widgets.php new file mode 100644 index 00000000..1ca7634b --- /dev/null +++ b/modules/sportspress-widgets.php @@ -0,0 +1,63 @@ +define_constants(); + + add_action( 'widgets_init', array( $this, 'includes' ) ); + } + + /** + * Define constants. + */ + private function define_constants() { + if ( !defined( 'SP_WIDGETS_VERSION' ) ) + define( 'SP_WIDGETS_VERSION', '1.7' ); + + if ( !defined( 'SP_WIDGETS_URL' ) ) + define( 'SP_WIDGETS_URL', plugin_dir_url( __FILE__ ) ); + + if ( !defined( 'SP_WIDGETS_DIR' ) ) + define( 'SP_WIDGETS_DIR', plugin_dir_path( __FILE__ ) ); + } + + /** + * Include widgets. + */ + public function includes() { + include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-sportspress.php' ); + include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-staff.php' ); + + do_action( 'sportspress_widgets' ); + } +} + +endif; + +if ( get_option( 'sportspress_load_widgets_module', 'yes' ) == 'yes' ) { + new SportsPress_Widgets(); +} diff --git a/sportspress.php b/sportspress.php index f8eb0de7..41ba84fb 100644 --- a/sportspress.php +++ b/sportspress.php @@ -117,7 +117,6 @@ final class SportsPress { // Hooks add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'action_links' ) ); - add_action( 'widgets_init', array( $this, 'include_widgets' ) ); add_action( 'init', array( $this, 'init' ), 0 ); add_action( 'init', array( 'SP_Shortcodes', 'init' ) ); add_action( 'after_setup_theme', array( $this, 'setup_environment' ) ); @@ -263,15 +262,6 @@ final class SportsPress { } } - /** - * Include core widgets. - */ - public function include_widgets() { - include_once( 'includes/widgets/class-sp-widget-staff.php' ); - - do_action( 'sportspress_widgets' ); - } - /** * Init SportsPress when WordPress Initialises. */