/** * Enqueue scripts and styles * * @since 1.0.0 * @access public */ public function enqueue_scripts() { global $TF, $TF_Layout; if (TF_Model::is_tf_editor_active()) { wp_enqueue_style('tf-icons', $TF->framework_uri() . '/assets/css/themify-icons/themify-icons.css', array(), $TF->get_version()); wp_enqueue_style('tf-admin-ui', $TF->framework_uri() . '/assets/css/tf-admin.css', array(), $TF->get_version()); wp_enqueue_style('tf-minicolors-css', $TF->framework_uri() . '/assets/css/jquery.minicolors.css', array(), $TF->get_version()); } /* FontAwesome library * uses the same handle as used by Themify Builder to prevent double loading the fonts */ wp_enqueue_style('tf-icon-font', $TF->framework_uri() . '/assets/css/fontawesome/css/font-awesome.min.css', array(), '4.3'); if (!TF_Model::is_tf_editor_active()) { // Load styling stylesheets. Doesn't use framework_uri() because it's placed in the theme root. // Enqueue stylesheet based in global styling, templates, template parts and custom CSS. if (TF_Model::is_readable_and_not_empty(TF_Model::get_global_stylesheet('bydir'))) { wp_enqueue_style('tf-global-styling', TF_Model::get_global_stylesheet('byurl'), array(), get_option('tf_stylesheet_global_timestamp')); } // Enqueue atomic stylesheet based in builder content in this entry. if (is_singular()) { if (TF_Model::is_readable_and_not_empty(TF_Model::get_atomic_stylesheet('bydir', get_the_ID()))) { wp_enqueue_style('tf-atomic-styling', TF_Model::get_atomic_stylesheet('byurl', get_the_ID()), array(), get_option('tf_stylesheet_atomic_timestamp')); } } } if (TF_Model::is_tf_editor_active()) { $load_depend_scripts = array('underscore', 'backbone', 'wp-util', 'jquery-ui-core', 'jquery-ui-tabs', 'jquery-ui-droppable', 'jquery-ui-sortable', 'media-upload', 'jquery-ui-dialog', 'wpdialogs', 'wpdialogs-popup', 'wplink', 'editor', 'quicktags'); // Include jQuery UI Touch if (wp_is_mobile()) { array_push($load_depend_scripts, 'jquery-touch-punch'); } $load_vendor_scripts = array('tf-nicescroll-js' => '/jquery.nicescroll.js', 'tf-minicolors-js' => '/jquery.minicolors.js', 'tf-tipsy-js' => '/jquery.tipsy.js'); $load_app_scripts = array('tf-app-js' => '/tf.js', 'tf-util-js' => '/utils.js', 'tf-utility-js' => '/models/utility.js', 'tf-model-template-js' => '/models/template.js', 'tf-model-style-js' => '/models/style.js', 'tf-model-control-js' => '/models/control.js', 'tf-model-element-style-js' => '/models/elementstyle.js', 'tf-collection-control-js' => '/collections/controls.js', 'tf-collection-element-styles-js' => '/collections/elementstyles.js', 'tf-view-lightbox-js' => '/views/lightbox.js', 'tf-view-loader-js' => '/views/loader.js', 'tf-view-template-part-js' => '/views/templatepart.js', 'tf-mixins-builder-js' => '/mixins/builder.js', 'tf-view-builder-js' => '/views/builder.js', 'tf-view-builder-element-js' => '/views/builderelement.js', 'tf-mixins-styling-control-js' => '/mixins/stylingcontrolfield.js', 'tf-view-styling-control-js' => '/views/stylingcontrol.js', 'tf-setup-js' => '/setup.js'); if (function_exists('wp_enqueue_media')) { wp_enqueue_media(); } foreach ($load_depend_scripts as $script) { wp_enqueue_script($script); } foreach ($load_vendor_scripts as $handle => $script) { wp_enqueue_script($handle, $TF->framework_uri() . '/assets/js/vendor' . $script, array('jquery'), $TF->get_version(), true); } foreach ($load_app_scripts as $handle => $script) { wp_enqueue_script($handle, $TF->framework_uri() . '/assets/js/tf' . $script, array('jquery'), $TF->get_version(), true); if ('tf-app-js' == $handle) { $region = isset($_GET['tf_region']) ? $_GET['tf_region'] : ''; $parent_template_id = isset($_GET['parent_template_id']) ? $_GET['parent_template_id'] : ''; wp_localize_script('tf-app-js', '_tf_app', array('post_id' => get_the_ID(), 'template_part_delete' => __('Are you sure to remove this template part?', 'themify-flow'), 'module_delete' => __('Are you sure to delete this module?', 'themify-flow'), 'sub_row_delete' => __('Are you sure to delete this sub row?', 'themify-flow'), 'row_delete' => __('Are you sure to delete this row?', 'themify-flow'), 'drop_module_text' => __('drop module here', 'themify-flow'), 'row_option_title' => __('Row Options', 'themify-flow'), 'region' => $region, 'template_type' => $TF_Layout->type, 'layout_id' => $TF_Layout->layout_id, 'parent_template_id' => $parent_template_id, 'nonce' => wp_create_nonce('tf_nonce'), 'is_global_styling' => TF_Model::is_tf_styling_active(), 'is_custom_css' => TF_Model::is_tf_custom_css_active(), 'clear_style_text' => __('Do you want to clear all Styling data in this panel?', 'themify-flow'), 'base_path' => $TF->framework_path(), 'base_uri' => $TF->framework_uri(), 'beforeunload' => __('You have unsaved changes. Please save the builder data.', 'themify-flow'), 'isTouch' => wp_is_mobile(), 'leaving_template_lightbox' => __('Close editor without saving the changes ?', 'themify-flow'))); $plupload_settings = $TF->get_plupload_settings(); wp_localize_script('tf-app-js', '_tf_app_plupload', $plupload_settings); } } } }