/** * Print scripts * * @since 1.0 */ function edd_wl_print_scripts() { global $edd_options; // Use minified libraries if SCRIPT_DEBUG is turned off $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; // register scripts wp_register_script('edd-wl', EDD_WL_PLUGIN_URL . 'includes/js/edd-wl' . $suffix . '.js', array('jquery'), EDD_WL_VERSION, true); wp_register_script('edd-wl-validate', EDD_WL_PLUGIN_URL . 'includes/js/jquery.validate' . $suffix . '.js', array('jquery'), EDD_WL_VERSION, true); wp_register_script('edd-wl-modal', EDD_WL_PLUGIN_URL . 'includes/js/modal' . $suffix . '.js', array('jquery'), EDD_WL_VERSION, true); // load scripts on single post type pages $post_types = edd_wl_allowed_post_types(); foreach ($post_types as $post_type) { if (is_singular($post_type)) { wp_enqueue_script('edd-wl'); wp_enqueue_script('edd-wl-modal'); } } // load validation if email sharing is present if (edd_wl_is_page('view') && edd_wl_sharing_is_enabled('email')) { wp_enqueue_script('edd-wl-validate'); } wp_localize_script('edd-wl', 'edd_wl_scripts', array('wish_list_page' => edd_wl_get_wish_list_uri(), 'wish_list_add' => edd_wl_get_wish_list_create_uri(), 'ajax_nonce' => wp_create_nonce('edd_wl_ajax_nonce'))); // CSS $file = 'edd-wl' . $suffix . '.css'; $templates_dir = edd_get_theme_template_dir_name(); $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()) . $templates_dir . $file; $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()) . $templates_dir . 'edd-wl.css'; $parent_theme_style_sheet = trailingslashit(get_template_directory()) . $templates_dir . $file; $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()) . $templates_dir . 'edd-wl.css'; $edd_plugin_style_sheet = trailingslashit(edd_wl_get_templates_dir()) . $file; // Look in the child theme directory first, followed by the parent theme, followed by the EDD core templates directory // Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled. // This allows users to copy just edd-wl.css to their theme if (file_exists($child_theme_style_sheet) || !empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2))) { if (!empty($nonmin)) { $url = trailingslashit(get_stylesheet_directory_uri()) . $templates_dir . 'edd-wl.css'; } else { $url = trailingslashit(get_stylesheet_directory_uri()) . $templates_dir . $file; } } elseif (file_exists($parent_theme_style_sheet) || !empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2))) { if (!empty($nonmin)) { $url = trailingslashit(get_template_directory_uri()) . $templates_dir . 'edd-wl.css'; } else { $url = trailingslashit(get_template_directory_uri()) . $templates_dir . $file; } } elseif (file_exists($edd_plugin_style_sheet) || file_exists($edd_plugin_style_sheet)) { $url = trailingslashit(edd_wl_get_templates_url()) . $file; } wp_enqueue_style('edd-wl-styles', $url, array(), EDD_WL_VERSION, 'screen'); }
/** * Create list link * @since 1.0.2 */ function edd_wl_create_list_link($args = array()) { // exit if page is not selected in options, or guest creation is not allowed if ('none' == edd_get_option('edd_wl_page_create') || !edd_wl_allow_guest_creation()) { return; } $defaults = apply_filters('edd_wl_create_list_link_defaults', array('text' => sprintf(__('Create new %s', 'edd-wish-lists'), edd_wl_get_label_singular(true)), 'wrapper_class' => '', 'wrapper' => 'p', 'class' => '')); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); $default_class = ' edd-wl-button edd-wl-action'; $class .= $class ? $default_class : trim($default_class); ob_start(); $html = ''; $link = '<a href="' . edd_wl_get_wish_list_create_uri() . '" class="' . $class . '" title="' . $text . '">' . $text . '</a>'; if ($wrapper) { $html = '<' . $wrapper . ' class="' . $wrapper_class . '"' . '>' . $link . '</' . $wrapper . '>'; } else { $html .= $link; } echo $html; $html = ob_get_clean(); return apply_filters('edd_wl_create_list_link', $html); }