skipv1_0_0Init

The Facebook Fanpage Import skip v1 0 Init class.

Defined (1)

The class is defined in the following location(s).

/includes/skip/core/core.php  
  1. class Init{  
  2.  
  3. /** 
  4. * The plugin version 
  5. */ 
  6. const VERSION = '1.0.0'; 
  7.  
  8. /** 
  9. * Minimum required WP version 
  10. */ 
  11. const MIN_WP = '4.1.0'; 
  12.  
  13. /** 
  14. * Minimum required PHP version 
  15. */ 
  16. const MIN_PHP = '5.3.3'; 
  17.  
  18. /** 
  19. * Actual Layout 
  20. */ 
  21. var $layout; 
  22.  
  23. /** 
  24. * All layouts 
  25. */ 
  26. var $layouts = array(); 
  27.  
  28. /** 
  29. * Default Layout 
  30. */ 
  31. var $default_layout = 'bootstrap'; 
  32.  
  33. /** 
  34. * Starting up! 
  35. *  
  36. * This starts the Skip Framework. 
  37. *  
  38. * @param array $args Options for starting Skip. 
  39. * @since 1.0 
  40. */ 
  41. public function __construct( $args = array() ) { 
  42. global $skip_javascripts, $skip_used_dialog; 
  43.  
  44. $skip_javascripts = array(); 
  45. $skip_used_dialog = FALSE; 
  46.  
  47. $defaults = array( 
  48. 'components' => array(  
  49. 'tabs',  
  50. 'accordion',  
  51. 'autocomplete',  
  52. 'button',  
  53. 'checkbox',  
  54. 'color',  
  55. 'editor',  
  56. 'file',  
  57. 'wp-file',  
  58. 'radio',  
  59. 'select',  
  60. 'text',  
  61. 'textarea',  
  62. ),  
  63. ); 
  64.  
  65. $args = wp_parse_args( $args, $defaults ); 
  66. extract( $args , EXTR_SKIP ); 
  67.  
  68. $this->components = $components; 
  69.  
  70. $this->constants(); 
  71. $this->includes(); 
  72.  
  73. if( is_admin() ): 
  74. add_action( 'admin_head', array( $this, 'css' ), 100 ); 
  75. add_action( 'admin_footer', array( $this, 'js' ), 100 ); 
  76. add_action( 'admin_print_footer_scripts', array( $this, 'echo_javascripts' ), 100 ); 
  77. else: 
  78. add_action( 'wp_enqueue_scripts', array( $this, 'css' ), 100 ); 
  79. add_action( 'wp_footer', array( $this, 'echo_javascripts' ), 100 ); 
  80. add_action( 'wp_enqueue_scripts', array( $this, 'js' ), 100 ); 
  81. endif; 
  82.  
  83. /** 
  84. * Enqueue CSS 
  85. * @package Skip 
  86. * @since 1.0 
  87. */ 
  88. public function css() { 
  89. global $skip_used_dialog; 
  90.  
  91. wp_dequeue_style( 'wp-jquery-ui-dialog' ); 
  92.  
  93. wp_register_style( $this->layout[ 'name' ], $this->layout[ 'css' ] ); 
  94. wp_enqueue_style( $this->layout[ 'name' ] ); 
  95.  
  96.  
  97. wp_register_style( 'colorpicker', SKIP_URL_PATH . 'includes/js/jquery/colorpicker/jquery.colorpicker.css' ); 
  98. wp_enqueue_style( 'colorpicker' ); 
  99.  
  100. wp_register_style( 'skip-styles', SKIP_URL_PATH . 'includes/css/skip.css' ); 
  101. wp_enqueue_style( 'skip-styles' ); 
  102.  
  103. /** 
  104. * Enqueue JS 
  105. * @package Skip 
  106. * @since 1.0 
  107. */ 
  108. public function js() { 
  109. wp_enqueue_script( 'jquery' ); 
  110. wp_enqueue_script( 'jquery-ui-button' ); 
  111.  
  112. wp_enqueue_script( 
  113. 'skip',  
  114. SKIP_URL_PATH . 'includes/js/skip.js',  
  115. array('jquery'),  
  116. '1.0.0',  
  117. TRUE 
  118. ); 
  119.  
  120. // Accordion 
  121. if( in_array( 'accordion', $this->components ) ): 
  122. wp_register_script( 'jquery-cookies', SKIP_URL_PATH . 'includes/js/jquery/skip-cookies.js' ); 
  123. wp_enqueue_script( 'jquery-cookies' ); 
  124.  
  125. wp_enqueue_script( 'jquery-ui-accordion' ); 
  126. endif; 
  127.  
  128. // Tabs 
  129. if( in_array( 'tabs', $this->components ) ): 
  130. wp_register_script( 'jquery-cookies', SKIP_URL_PATH . 'includes/js/jquery/skip-cookies.js' ); 
  131. wp_enqueue_script( 'jquery-cookies' ); 
  132.  
  133. wp_enqueue_script( 'jquery-ui-tabs' ); 
  134. endif; 
  135.  
  136. // Autocomplete 
  137. if( in_array( 'color', $this->components ) ): 
  138. wp_enqueue_script( 'jquery-ui-autocomplete' ); 
  139. endif; 
  140.  
  141. // Color 
  142. if( in_array( 'color', $this->components ) ): 
  143. wp_register_script( 'jquery-colorpicker', SKIP_URL_PATH . 'includes/js/jquery/colorpicker/jquery.colorpicker.js' ); 
  144. wp_enqueue_script( 'jquery-colorpicker' ); 
  145. endif; 
  146.  
  147. // File  
  148. if( in_array( 'wp-file', $this->components ) ): 
  149. wp_enqueue_media(); 
  150. wp_enqueue_script( 'thickbox' ); 
  151. endif; 
  152.  
  153. /** 
  154. * Printing Skip Javascripts 
  155. * @since 1.0 
  156. */ 
  157. public function echo_javascripts() { 
  158. global $skip_javascripts; 
  159.  
  160. if( count( $skip_javascripts ) > 0 ): 
  161. echo '<!-- skip JS //-->'; 
  162. echo '<script type="text/javascript">'; 
  163. echo 'jQuery(document).ready(function($) {'; 
  164. echo implode( $skip_javascripts ); 
  165. echo '});'; 
  166. echo '</script>'; 
  167. echo '<!-- End skip JS //-->'; 
  168. endif; 
  169.  
  170.  
  171. /** 
  172. * Setting constants 
  173. * @since 1.0 
  174. */ 
  175. private function constants() { 
  176. if( !defined( 'SKIP_VERSION') ) define( 'SKIP_VERSION', self::VERSION ); 
  177. if( !defined( 'SKIP_PATH') ) define( 'SKIP_PATH', $this->get_path() ); 
  178. if( !defined( 'SKIP_URL_PATH') ) define( 'SKIP_URL_PATH', $this->get_url_path() ); 
  179. if( !defined( 'SKIP_DELIMITER') ) define( 'SKIP_DELIMITER', '&' ); 
  180.  
  181. /** 
  182. * Getting URL Path of Skip 
  183. * @since 1.0 
  184. */ 
  185. private function get_url_path() { 
  186. $sub_path = substr( SKIP_PATH, strlen( ABSPATH ), ( strlen( SKIP_PATH ) ) ); 
  187. $script_url = get_bloginfo( 'wpurl' ) . '/' . $sub_path; 
  188. return $script_url; 
  189.  
  190. /** 
  191. * Getting URL Path of Skip 
  192. * @since 1.0 
  193. */ 
  194. private function get_path() { 
  195. $sub_path = substr( dirname(__FILE__), strlen( ABSPATH ), ( strlen( dirname(__FILE__) ) - strlen( ABSPATH ) - 4 ) ); 
  196. $script_path = ABSPATH . $sub_path; 
  197. return $script_path; 
  198.  
  199. /** 
  200. * Includes files for Skip 
  201. * @since 1.0 
  202. */  
  203. private function includes() { 
  204.  
  205. /** 
  206. * General scripts 
  207. */ 
  208. require_once( SKIP_PATH . '/core/display.php' ); 
  209. require_once( SKIP_PATH . '/core/functions/collected.php' ); 
  210.  
  211. require_once( SKIP_PATH . '/elements/element.php' ); 
  212. require_once( SKIP_PATH . '/elements/html_element.php' ); 
  213.  
  214. /** 
  215. * Form Elements 
  216. */ 
  217. require_once( SKIP_PATH . '/elements/forms/form.php' ); 
  218. require_once( SKIP_PATH . '/elements/forms/form-element.php' ); 
  219. require_once( SKIP_PATH . '/elements/forms/values.php' ); 
  220.  
  221. // Text 
  222. if( in_array( 'text', $this->components ) ) 
  223. require_once( SKIP_PATH . '/elements/forms/textfield.php' ); 
  224.  
  225. // Textarea 
  226. if( in_array( 'textarea', $this->components ) ) 
  227. require_once( SKIP_PATH . '/elements/forms/textarea.php' ); 
  228.  
  229. // Text 
  230. if( in_array( 'textarea', $this->components ) ) 
  231. require_once( SKIP_PATH . '/elements/forms/editor.php' ); 
  232.  
  233. // Autocomplete 
  234. if( in_array( 'autocomplete', $this->components ) ) 
  235. require_once( SKIP_PATH . '/elements/forms/autocomplete.php' ); 
  236.  
  237. // Color 
  238. if( in_array( 'color', $this->components ) ) 
  239. require_once( SKIP_PATH . '/elements/forms/color.php' ); 
  240.  
  241. // File 
  242. if( in_array( 'file', $this->components ) ) 
  243. require_once( SKIP_PATH . '/elements/forms/file.php' ); 
  244.  
  245. // WP File 
  246. if( in_array( 'wp-file', $this->components ) ) 
  247. require_once( SKIP_PATH . '/elements/forms/wp-file.php' ); 
  248.  
  249. // Checkbox 
  250. if( in_array( 'checkbox', $this->components ) ) 
  251. require_once( SKIP_PATH . '/elements/forms/checkbox.php' ); 
  252.  
  253. // Radio 
  254. if( in_array( 'radio', $this->components ) ) 
  255. require_once( SKIP_PATH . '/elements/forms/radio.php' ); 
  256.  
  257. // Select 
  258. if( in_array( 'select', $this->components ) ) 
  259. require_once( SKIP_PATH . '/elements/forms/select.php' ); 
  260.  
  261. // Select 
  262. if( in_array( 'button', $this->components ) ) 
  263. require_once( SKIP_PATH . '/elements/forms/button.php' ); 
  264.  
  265. // Requies fields 
  266. require_once( SKIP_PATH . '/elements/forms/hidden.php' ); // Needed by other functions