コード例 #1
1
ファイル: extras.php プロジェクト: nicoandrade/Coni
/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function coni_body_classes($classes)
{
    $coni_theme_data = wp_get_theme();
    $classes[] = sanitize_title($coni_theme_data['Name']);
    $classes[] = 'v' . $coni_theme_data['Version'];
    return $classes;
}
コード例 #2
0
ファイル: api-options-page.php プロジェクト: Garth619/Femi9
function acf_get_valid_options_page($page = '')
{
    // allow for string
    if (empty($page)) {
        $page = array('page_title' => __('Options', 'acf'), 'menu_title' => __('Options', 'acf'), 'menu_slug' => 'acf-options');
    } elseif (is_string($page)) {
        $page_title = $page;
        $page = array('page_title' => $page_title, 'menu_title' => $page_title);
    }
    // defaults
    $page = wp_parse_args($page, array('page_title' => '', 'menu_title' => '', 'menu_slug' => '', 'capability' => 'edit_posts', 'parent_slug' => '', 'position' => false, 'icon_url' => false, 'redirect' => true, 'post_id' => 'options', 'autoload' => false, 'update_button' => __('Update', 'acf')));
    // ACF4 compatibility
    $migrate = array('title' => 'page_title', 'menu' => 'menu_title', 'slug' => 'menu_slug', 'parent' => 'parent_slug');
    foreach ($migrate as $old => $new) {
        if (!empty($page[$old])) {
            $page[$new] = acf_extract_var($page, $old);
        }
    }
    // page_title (allows user to define page with just page_title or title)
    if (empty($page['menu_title'])) {
        $page['menu_title'] = $page['page_title'];
    }
    // menu_slug
    if (empty($page['menu_slug'])) {
        $page['menu_slug'] = 'acf-options-' . sanitize_title($page['menu_title']);
    }
    // return
    return $page;
}
コード例 #3
0
ファイル: slug.php プロジェクト: kosir/wp-pipes
 public static function process($data, $params)
 {
     if (isset($_GET['pal'])) {
         echo '<br /><br /><i><b>File</b> ' . __FILE__ . ' <b>Line</b> ' . __LINE__ . "</i><br />\n";
         echo '<pre>';
         echo 'Params: ';
         print_r($params);
         echo 'Data: ';
         print_r($data);
         echo '</pre>';
     }
     $res = new stdClass();
     $res->slug = '';
     if ($data->text == '') {
         return $res;
     }
     $slug = $data->text;
     $slug = self::replace_chars($slug, $params);
     if (isset($_GET['pslug'])) {
         echo '<br /><br /><i><b>File</b> ' . __FILE__ . ' <b>Line</b> ' . __LINE__ . "</i><br />\n";
         echo 'Alias: ' . $slug . '<br />';
     }
     $slug = wp_strip_all_tags($slug);
     /*$slug = preg_replace( '/[^a-zA-Z0-9\-\s]/', '', $slug );
     		$slug = preg_replace( '/\s+/', '-', $slug );
     		$slug = preg_replace( '/\-+/', '-', trim( $slug ) );*/
     $slug = sanitize_title($slug);
     $slug = strtolower($slug);
     if (isset($_GET['pslug'])) {
         echo '<br /><br /><i><b>File</b> ' . __FILE__ . ' <b>Line</b> ' . __LINE__ . "</i><br />\n";
         echo 'Alias: ' . $slug . '<br />';
     }
     $res->slug = $slug;
     return $res;
 }
コード例 #4
0
 /**
  * Construct Upload parameters.
  *
  * @since 2.3.0
  * @since 2.4.0 Add the $upload_dir_filter_args argument to the $arguments array
  *
  * @param array|string $args {
  *     @type int    $original_max_filesize  Maximum file size in kilobytes. Defaults to php.ini settings.
  *     @type array  $allowed_mime_types     List of allowed file extensions (eg: array( 'jpg', 'gif', 'png' ) ).
  *                                          Defaults to WordPress allowed mime types.
  *     @type string $base_dir               Component's upload base directory. Defaults to WordPress 'uploads'.
  *     @type string $action                 The upload action used when uploading a file, $_POST['action'] must be set
  *                                          and its value must equal $action {@link wp_handle_upload()} (required).
  *     @type string $file_input             The name attribute used in the file input. (required).
  *     @type array  $upload_error_strings   A list of specific error messages (optional).
  *     @type array  $required_wp_files      The list of required WordPress core files. Default: array( 'file' ).
  *     @type int    $upload_dir_filter_args 1 to receive the original Upload dir array in the Upload dir filter, 0 otherwise.
  *                                          Defaults to 0 (optional).
  * }
  */
 public function __construct($args = '')
 {
     // Upload action and the file input name are required parameters.
     if (empty($args['action']) || empty($args['file_input'])) {
         return false;
     }
     // Sanitize the action ID and the file input name.
     $this->action = sanitize_key($args['action']);
     $this->file_input = sanitize_key($args['file_input']);
     /**
      * Max file size defaults to php ini settings or, in the case of
      * a multisite config, the root site fileupload_maxk option
      */
     $this->default_args['original_max_filesize'] = (int) wp_max_upload_size();
     $params = bp_parse_args($args, $this->default_args, $this->action . '_upload_params');
     foreach ($params as $key => $param) {
         if ('upload_error_strings' === $key) {
             $this->{$key} = $this->set_upload_error_strings($param);
             // Sanitize the base dir.
         } elseif ('base_dir' === $key) {
             $this->{$key} = sanitize_title($param);
             // Sanitize the upload dir filter arg to pass.
         } elseif ('upload_dir_filter_args' === $key) {
             $this->{$key} = (int) $param;
             // Action & File input are already set and sanitized.
         } elseif ('action' !== $key && 'file_input' !== $key) {
             $this->{$key} = $param;
         }
     }
     // Set the path/url and base dir for uploads.
     $this->set_upload_dir();
 }
コード例 #5
0
 /**
  * Output the shortcode.
  *
  * @access public
  * @param array $atts
  * @return void
  */
 public static function output($atts)
 {
     global $wp;
     // Check cart class is loaded or abort
     if (is_null(WC()->cart)) {
         return;
     }
     if (!is_user_logged_in()) {
         $message = apply_filters('woocommerce_my_account_message', '');
         if (!empty($message)) {
             wc_add_notice($message);
         }
         if (isset($wp->query_vars['lost-password'])) {
             self::lost_password();
         } else {
             wc_get_template('myaccount/form-login.php');
         }
     } else {
         if (!empty($wp->query_vars['view-order'])) {
             self::view_order(absint($wp->query_vars['view-order']));
         } elseif (isset($wp->query_vars['edit-account'])) {
             self::edit_account();
         } elseif (isset($wp->query_vars['edit-address'])) {
             self::edit_address(wc_edit_address_i18n(sanitize_title($wp->query_vars['edit-address']), true));
         } elseif (isset($wp->query_vars['add-payment-method'])) {
             self::add_payment_method();
         } else {
             self::my_account($atts);
         }
     }
 }
コード例 #6
0
 public function prepare_items()
 {
     global $wpdb, $per_page;
     $per_page = $this->get_items_per_page('formidable_page_formidable_entries_per_page');
     $form_id = $this->params['form'];
     if (!$form_id) {
         $this->items = array();
         $this->set_pagination_args(array('total_items' => 0, 'per_page' => $per_page));
         return;
     }
     $default_orderby = 'id';
     $default_order = 'DESC';
     $s_query = array('it.form_id' => $form_id);
     $s = isset($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : '';
     if ($s != '' && FrmAppHelper::pro_is_installed()) {
         $fid = isset($_REQUEST['fid']) ? sanitize_title($_REQUEST['fid']) : '';
         $s_query = FrmProEntriesHelper::get_search_str($s_query, $s, $form_id, $fid);
     }
     $orderby = isset($_REQUEST['orderby']) ? sanitize_title($_REQUEST['orderby']) : $default_orderby;
     if (strpos($orderby, 'meta') !== false) {
         $order_field_type = FrmField::get_type(str_replace('meta_', '', $orderby));
         $orderby .= in_array($order_field_type, array('number', 'scale')) ? ' +0 ' : '';
     }
     $order = isset($_REQUEST['order']) ? sanitize_title($_REQUEST['order']) : $default_order;
     $order = ' ORDER BY ' . $orderby . ' ' . $order;
     $page = $this->get_pagenum();
     $start = (int) isset($_REQUEST['start']) ? absint($_REQUEST['start']) : ($page - 1) * $per_page;
     $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false);
     $total_items = FrmEntry::getRecordCount($s_query);
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
 }
コード例 #7
0
 /**
  * Register core taxonomies.
  */
 public static function register_taxonomies()
 {
     if (taxonomy_exists('product_type')) {
         return;
     }
     do_action('woocommerce_register_taxonomy');
     $permalinks = get_option('woocommerce_permalinks');
     register_taxonomy('product_type', apply_filters('woocommerce_taxonomy_objects_product_type', array('product')), apply_filters('woocommerce_taxonomy_args_product_type', array('hierarchical' => false, 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => is_admin(), 'rewrite' => false, 'public' => false)));
     register_taxonomy('product_cat', apply_filters('woocommerce_taxonomy_objects_product_cat', array('product')), apply_filters('woocommerce_taxonomy_args_product_cat', array('hierarchical' => true, 'update_count_callback' => '_wc_term_recount', 'label' => __('Product Categories', 'woocommerce'), 'labels' => array('name' => __('Product Categories', 'woocommerce'), 'singular_name' => __('Product Category', 'woocommerce'), 'menu_name' => _x('Categories', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Product Categories', 'woocommerce'), 'all_items' => __('All Product Categories', 'woocommerce'), 'parent_item' => __('Parent Product Category', 'woocommerce'), 'parent_item_colon' => __('Parent Product Category:', 'woocommerce'), 'edit_item' => __('Edit Product Category', 'woocommerce'), 'update_item' => __('Update Product Category', 'woocommerce'), 'add_new_item' => __('Add New Product Category', 'woocommerce'), 'new_item_name' => __('New Product Category Name', 'woocommerce')), 'show_ui' => true, 'query_var' => true, 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => array('slug' => empty($permalinks['category_base']) ? _x('product-category', 'slug', 'woocommerce') : $permalinks['category_base'], 'with_front' => false, 'hierarchical' => true))));
     register_taxonomy('product_tag', apply_filters('woocommerce_taxonomy_objects_product_tag', array('product')), apply_filters('woocommerce_taxonomy_args_product_tag', array('hierarchical' => false, 'update_count_callback' => '_wc_term_recount', 'label' => __('Product Tags', 'woocommerce'), 'labels' => array('name' => __('Product Tags', 'woocommerce'), 'singular_name' => __('Product Tag', 'woocommerce'), 'menu_name' => _x('Tags', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Product Tags', 'woocommerce'), 'all_items' => __('All Product Tags', 'woocommerce'), 'edit_item' => __('Edit Product Tag', 'woocommerce'), 'update_item' => __('Update Product Tag', 'woocommerce'), 'add_new_item' => __('Add New Product Tag', 'woocommerce'), 'new_item_name' => __('New Product Tag Name', 'woocommerce'), 'popular_items' => __('Popular Product Tags', 'woocommerce'), 'separate_items_with_commas' => __('Separate Product Tags with commas', 'woocommerce'), 'add_or_remove_items' => __('Add or remove Product Tags', 'woocommerce'), 'choose_from_most_used' => __('Choose from the most used Product tags', 'woocommerce'), 'not_found' => __('No Product Tags found', 'woocommerce')), 'show_ui' => true, 'query_var' => true, 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => array('slug' => empty($permalinks['tag_base']) ? _x('product-tag', 'slug', 'woocommerce') : $permalinks['tag_base'], 'with_front' => false))));
     register_taxonomy('product_shipping_class', apply_filters('woocommerce_taxonomy_objects_product_shipping_class', array('product', 'product_variation')), apply_filters('woocommerce_taxonomy_args_product_shipping_class', array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Shipping Classes', 'woocommerce'), 'labels' => array('name' => __('Shipping Classes', 'woocommerce'), 'singular_name' => __('Shipping Class', 'woocommerce'), 'menu_name' => _x('Shipping Classes', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Shipping Classes', 'woocommerce'), 'all_items' => __('All Shipping Classes', 'woocommerce'), 'parent_item' => __('Parent Shipping Class', 'woocommerce'), 'parent_item_colon' => __('Parent Shipping Class:', 'woocommerce'), 'edit_item' => __('Edit Shipping Class', 'woocommerce'), 'update_item' => __('Update Shipping Class', 'woocommerce'), 'add_new_item' => __('Add New Shipping Class', 'woocommerce'), 'new_item_name' => __('New Shipping Class Name', 'woocommerce')), 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => is_admin(), 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => false)));
     global $wc_product_attributes;
     $wc_product_attributes = array();
     if ($attribute_taxonomies = wc_get_attribute_taxonomies()) {
         foreach ($attribute_taxonomies as $tax) {
             if ($name = wc_attribute_taxonomy_name($tax->attribute_name)) {
                 $tax->attribute_public = absint(isset($tax->attribute_public) ? $tax->attribute_public : 1);
                 $label = !empty($tax->attribute_label) ? $tax->attribute_label : $tax->attribute_name;
                 $wc_product_attributes[$name] = $tax;
                 $taxonomy_data = array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'labels' => array('name' => $label, 'singular_name' => $label, 'search_items' => sprintf(__('Search %s', 'woocommerce'), $label), 'all_items' => sprintf(__('All %s', 'woocommerce'), $label), 'parent_item' => sprintf(__('Parent %s', 'woocommerce'), $label), 'parent_item_colon' => sprintf(__('Parent %s:', 'woocommerce'), $label), 'edit_item' => sprintf(__('Edit %s', 'woocommerce'), $label), 'update_item' => sprintf(__('Update %s', 'woocommerce'), $label), 'add_new_item' => sprintf(__('Add New %s', 'woocommerce'), $label), 'new_item_name' => sprintf(__('New %s', 'woocommerce'), $label)), 'show_ui' => false, 'query_var' => 1 === $tax->attribute_public, 'rewrite' => false, 'sort' => false, 'public' => 1 === $tax->attribute_public, 'show_in_nav_menus' => 1 === $tax->attribute_public && apply_filters('woocommerce_attribute_show_in_nav_menus', false, $name), 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'));
                 if (1 === $tax->attribute_public) {
                     $taxonomy_data['rewrite'] = array('slug' => empty($permalinks['attribute_base']) ? '' : trailingslashit($permalinks['attribute_base']) . sanitize_title($tax->attribute_name), 'with_front' => false, 'hierarchical' => true);
                 }
                 register_taxonomy($name, apply_filters("woocommerce_taxonomy_objects_{$name}", array('product')), apply_filters("woocommerce_taxonomy_args_{$name}", $taxonomy_data));
             }
         }
         do_action('woocommerce_after_register_taxonomy');
     }
 }
コード例 #8
0
 function add_menu($args = array())
 {
     $defaults = array('title' => false, 'href' => false, 'parent' => false, 'id' => false, 'meta' => false);
     $r = wp_parse_args($args, $defaults);
     extract($r, EXTR_SKIP);
     if (empty($title)) {
         return false;
     }
     /* Make sure we have a valid ID */
     if (empty($id)) {
         $id = esc_attr(sanitize_title(trim($title)));
     }
     if (!empty($parent)) {
         /* Add the menu to the parent item */
         $child = array('id' => $id, 'title' => $title, 'href' => $href);
         if (!empty($meta)) {
             $child['meta'] = $meta;
         }
         $this->add_node($parent, $this->menu, $child);
     } else {
         /* Add the menu item */
         $this->menu->{$id} = array('title' => $title, 'href' => $href);
         if (!empty($meta)) {
             $this->menu->{$id}['meta'] = $meta;
         }
     }
 }
コード例 #9
0
ファイル: class-settings.php プロジェクト: WP-Panda/m.video
 /**
  * Settings page.
  *
  * Handles the display of the main woocommerce settings page in admin.
  *
  * @access public
  * @return void
  */
 public static function output()
 {
     global $current_section, $current_tab;
     do_action('be_compare_settings_start');
     wp_enqueue_script('woocommerce_settings', WC()->plugin_url() . '/assets/js/admin/settings.min.js', array('jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'chosen'), WC()->version, true);
     wp_localize_script('woocommerce_settings', 'woocommerce_settings_params', array('i18n_nav_warning' => __('The changes you made will be lost if you navigate away from this page.', 'be-compare-products')));
     // Include settings pages
     self::get_settings_pages();
     // Get current tab/section
     $current_tab = empty($_GET['tab']) ? 'settings' : sanitize_title($_GET['tab']);
     $current_section = empty($_REQUEST['section']) ? '' : sanitize_title($_REQUEST['section']);
     // Save settings if data has been posted
     if (!empty($_POST)) {
         self::save();
     }
     // Add any posted messages
     if (!empty($_GET['wc_error'])) {
         self::add_error(stripslashes($_GET['wc_error']));
     }
     if (!empty($_GET['wc_message'])) {
         self::add_message(stripslashes($_GET['wc_message']));
     }
     self::show_messages();
     // Get tabs for the settings page
     $tabs = apply_filters('be_compare_settings_tabs_array', array());
     include 'html-settings.php';
 }
コード例 #10
0
 /**
  * Add Contextual help tabs.
  */
 public function add_tabs()
 {
     $screen = get_current_screen();
     if (!$screen || !in_array($screen->id, wc_get_screen_ids())) {
         return;
     }
     $video_map = array('wc-settings' => array('title' => __('General Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/mz2l10u5f6?videoFoam=true'), 'wc-settings-general' => array('title' => __('General Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/mz2l10u5f6?videoFoam=true'), 'wc-settings-products' => array('title' => __('Product Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/lolkan4fxf?videoFoam=true'), 'wc-settings-tax' => array('title' => __('Tax Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/qp1v19dwrh?videoFoam=true'), 'wc-settings-shipping' => array('title' => __('Shipping Zones', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/95yiocro6p?videoFoam=true'), 'wc-settings-shipping-options' => array('title' => __('Shipping Options', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/9c9008dxnr?videoFoam=true'), 'wc-settings-shipping-classes' => array('title' => __('Shipping Classes', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/tpqg17aq99?videoFoam=true'), 'wc-settings-checkout' => array('title' => __('Checkout Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/65yjv96z51?videoFoam=true'), 'wc-settings-checkout-bacs' => array('title' => __('Bank Transfer (BACS) Payments', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/dh4piy3sek?videoFoam=true'), 'wc-settings-checkout-cheque' => array('title' => __('Check Payments', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/u2m2kcakea?videoFoam=true'), 'wc-settings-checkout-cod' => array('title' => __('Cash on Delivery', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/8hyli8wu5f?videoFoam=true'), 'wc-settings-checkout-paypal' => array('title' => __('PayPal Standard', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/rbl7e7l4k2?videoFoam=true'), 'wc-settings-checkout-paypalbraintree_cards' => array('title' => __('PayPal by Braintree', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/oyksirgn40?videoFoam=true'), 'wc-settings-checkout-stripe' => array('title' => __('Stripe', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/mf975hx5de?videoFoam=true'), 'wc-settings-checkout-simplify_commerce' => array('title' => __('Simplify Commerce', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/jdfzjiiw61?videoFoam=true'), 'wc-settings-account' => array('title' => __('Account Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/35mazq7il2?videoFoam=true'), 'wc-settings-email' => array('title' => __('Email Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/svcaftq4xv?videoFoam=true'), 'wc-settings-api' => array('title' => __('Webhook Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/1q0ny74vvq?videoFoam=true'), 'product' => array('title' => __('Simple Products', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/ziyjmd4kut?videoFoam=true'), 'edit-product_cat' => array('title' => __('Product Categories', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/f0j5gzqigg?videoFoam=true'), 'edit-product_tag' => array('title' => __('Product Categories, Tags, Shipping Classes, &amp; Attributes', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/f0j5gzqigg?videoFoam=true'), 'product_attributes' => array('title' => __('Product Categories, Tags, Shipping Classes, &amp; Attributes', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/f0j5gzqigg?videoFoam=true'), 'wc-status' => array('title' => __('System Status', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/xdn733nnhi?videoFoam=true'), 'wc-reports' => array('title' => __('Reports', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/6aasex0w99?videoFoam=true'), 'edit-shop_coupon' => array('title' => __('Coupons', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/gupd4h8sit?videoFoam=true'), 'shop_coupon' => array('title' => __('Coupons', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/gupd4h8sit?videoFoam=true'), 'edit-shop_order' => array('title' => __('Managing Orders', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/n8n0sa8hee?videoFoam=true'), 'shop_order' => array('title' => __('Managing Orders', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/n8n0sa8hee?videoFoam=true'));
     $page = empty($_GET['page']) ? '' : sanitize_title($_GET['page']);
     $tab = empty($_GET['tab']) ? '' : sanitize_title($_GET['tab']);
     $section = empty($_REQUEST['section']) ? '' : sanitize_title($_REQUEST['section']);
     $video_key = $page ? implode('-', array_filter(array($page, $tab, $section))) : $screen->id;
     // Fallback for sections
     if (!isset($video_map[$video_key])) {
         $video_key = $page ? implode('-', array_filter(array($page, $tab))) : $screen->id;
     }
     // Fallback for tabs
     if (!isset($video_map[$video_key])) {
         $video_key = $page ? $page : $screen->id;
     }
     if (isset($video_map[$video_key])) {
         $screen->add_help_tab(array('id' => 'woocommerce_101_tab', 'title' => __('WooCommerce 101', 'woocommerce'), 'content' => '<h2><a href="https://docs.woocommerce.com/document/woocommerce-101-video-series/?utm_source=helptab&utm_medium=product&utm_content=videos&utm_campaign=woocommerceplugin">' . __('WooCommerce 101', 'woocommerce') . '</a> &ndash; ' . esc_html($video_map[$video_key]['title']) . '</h2>' . '<iframe data-src="' . esc_url($video_map[$video_key]['url']) . '" src="" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen width="480" height="298"></iframe>'));
     }
     $screen->add_help_tab(array('id' => 'woocommerce_support_tab', 'title' => __('Help &amp; Support', 'woocommerce'), 'content' => '<h2>' . __('Help &amp; Support', 'woocommerce') . '</h2>' . '<p>' . sprintf(__('Should you need help understanding, using, or extending WooCommerce, %splease read our documentation%s. You will find all kinds of resources including snippets, tutorials and much more.', 'woocommerce'), '<a href="https://docs.woocommerce.com/documentation/plugins/woocommerce/?utm_source=helptab&utm_medium=product&utm_content=docs&utm_campaign=woocommerceplugin">', '</a>') . '</p>' . '<p>' . sprintf(__('For further assistance with WooCommerce core you can use the %scommunity forum%s. If you need help with premium add-ons sold by WooThemes, please %suse our helpdesk%s.', 'woocommerce'), '<a href="https://wordpress.org/support/plugin/woocommerce">', '</a>', '<a href="https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin">', '</a>') . '</p>' . '<p>' . __('Before asking for help we recommend checking the system status page to identify any problems with your configuration.', 'woocommerce') . '</p>' . '<p><a href="' . admin_url('admin.php?page=wc-status') . '" class="button button-primary">' . __('System Status', 'woocommerce') . '</a> <a href="' . 'https://wordpress.org/support/plugin/woocommerce' . '" class="button">' . __('Community Forum', 'woocommerce') . '</a> <a href="' . 'https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin' . '" class="button">' . __('WooThemes Helpdesk', 'woocommerce') . '</a></p>'));
     $screen->add_help_tab(array('id' => 'woocommerce_bugs_tab', 'title' => __('Found a bug?', 'woocommerce'), 'content' => '<h2>' . __('Found a bug?', 'woocommerce') . '</h2>' . '<p>' . sprintf(__('If you find a bug within WooCommerce core you can create a ticket via <a href="%s">Github issues</a>. Ensure you read the <a href="%s">contribution guide</a> prior to submitting your report. To help us solve your issue, please be as descriptive as possible and include your <a href="%s">system status report</a>.', 'woocommerce'), 'https://github.com/woothemes/woocommerce/issues?state=open', 'https://github.com/woothemes/woocommerce/blob/master/.github/CONTRIBUTING.md', admin_url('admin.php?page=wc-status')) . '</p>' . '<p><a href="' . 'https://github.com/woothemes/woocommerce/issues?state=open' . '" class="button button-primary">' . __('Report a bug', 'woocommerce') . '</a> <a href="' . admin_url('admin.php?page=wc-status') . '" class="button">' . __('System Status', 'woocommerce') . '</a></p>'));
     $screen->add_help_tab(array('id' => 'woocommerce_education_tab', 'title' => __('Education', 'woocommerce'), 'content' => '<h2>' . __('Education', 'woocommerce') . '</h2>' . '<p>' . __('If you would like to learn about using WooCommerce from an expert, consider following a WooCommerce course ran by one of our educational partners.', 'woocommerce') . '</p>' . '<p><a href="' . 'https://woocommerce.com/educational-partners/?utm_source=helptab&utm_medium=product&utm_content=edupartners&utm_campaign=woocommerceplugin' . '" class="button button-primary">' . __('View Education Partners', 'woocommerce') . '</a></p>'));
     $screen->add_help_tab(array('id' => 'woocommerce_onboard_tab', 'title' => __('Setup Wizard', 'woocommerce'), 'content' => '<h2>' . __('Setup Wizard', 'woocommerce') . '</h2>' . '<p>' . __('If you need to access the setup wizard again, please click on the button below.', 'woocommerce') . '</p>' . '<p><a href="' . admin_url('index.php?page=wc-setup') . '" class="button button-primary">' . __('Setup Wizard', 'woocommerce') . '</a></p>'));
     $screen->set_help_sidebar('<p><strong>' . __('For more information:', 'woocommerce') . '</strong></p>' . '<p><a href="' . 'https://woocommerce.com/?utm_source=helptab&utm_medium=product&utm_content=about&utm_campaign=woocommerceplugin' . '" target="_blank">' . __('About WooCommerce', 'woocommerce') . '</a></p>' . '<p><a href="' . 'https://wordpress.org/extend/plugins/woocommerce/' . '" target="_blank">' . __('WordPress.org Project', 'woocommerce') . '</a></p>' . '<p><a href="' . 'https://github.com/woothemes/woocommerce' . '" target="_blank">' . __('Github Project', 'woocommerce') . '</a></p>' . '<p><a href="' . 'https://woocommerce.com/product-category/themes/woocommerce/?utm_source=helptab&utm_medium=product&utm_content=wcthemes&utm_campaign=woocommerceplugin' . '" target="_blank">' . __('Official Themes', 'woocommerce') . '</a></p>' . '<p><a href="' . 'https://woocommerce.com/product-category/woocommerce-extensions/?utm_source=helptab&utm_medium=product&utm_content=wcextensions&utm_campaign=woocommerceplugin' . '" target="_blank">' . __('Official Extensions', 'woocommerce') . '</a></p>');
 }
コード例 #11
0
 function awp_sanitize_data($input)
 {
     if (!isset($input['stylesheet_load']) || $input['stylesheet_load'] != '1') {
         $input['stylesheet_load'] = 0;
     } else {
         $input['stylesheet_load'] = 1;
     }
     // check to make sure the fields are not empty - if they are - fill with defaults
     if (empty($input['singular_name'])) {
         $input['singular_name'] = 'Community';
     }
     if (empty($input['plural_name'])) {
         $input['plural_name'] = 'Communities';
     }
     if (empty($input['slug'])) {
         $input['slug'] = 'communities';
     }
     if (empty($input['num_posts']) || !is_numeric($input['num_posts'])) {
         $input['num_posts'] = '8';
     }
     //if ( $input['order_by'] =='rand')  $input['num_posts'] = '999';
     // sanitize the fields
     $input['singular_name'] = wp_strip_all_tags($input['singular_name']);
     $input['plural_name'] = wp_strip_all_tags($input['plural_name']);
     $input['slug'] = sanitize_title($input['slug']);
     return $input;
 }
コード例 #12
0
 /**
  * get_product function.
  *
  * @access public
  * @param bool $the_product (default: false)
  * @param array $args (default: array())
  * @return WC_Product_Simple
  */
 public function get_product($the_product = false, $args = array())
 {
     global $post;
     if (false === $the_product) {
         $the_product = $post;
     } elseif (is_numeric($the_product)) {
         $the_product = get_post($the_product);
     }
     if (!$the_product) {
         return false;
     }
     $product_id = absint($the_product->ID);
     $post_type = $the_product->post_type;
     if (in_array($post_type, array('product', 'product_variation'))) {
         if (isset($args['product_type'])) {
             $product_type = $args['product_type'];
         } elseif ('product_variation' == $post_type) {
             $product_type = 'variation';
         } else {
             $terms = get_the_terms($product_id, 'product_type');
             $product_type = !empty($terms) && isset(current($terms)->name) ? sanitize_title(current($terms)->name) : 'simple';
         }
         // Create a WC coding standards compliant class name e.g. WC_Product_Type_Class instead of WC_Product_type-class
         $classname = 'WC_Product_' . preg_replace('/-(.)/e', "'_' . strtoupper( '\$1' )", ucfirst($product_type));
     } else {
         $classname = false;
         $product_type = false;
     }
     // Filter classname so that the class can be overridden if extended.
     $classname = apply_filters('woocommerce_product_class', $classname, $product_type, $post_type, $product_id);
     if (!class_exists($classname)) {
         $classname = 'WC_Product_Simple';
     }
     return new $classname($the_product, $args);
 }
コード例 #13
0
 /** 
  * Function for add/ update playlist data.
  * 
  */
 public function add_playlist()
 {
     global $wpdb;
     if (isset($this->_status)) {
         $this->status_update($this->_playListId, $this->_status);
     }
     if (isset($this->_addnewPlaylist)) {
         $playlistName = filter_input(INPUT_POST, 'playlistname');
         $playlist_slugname = sanitize_title($playlistName);
         $playlistPublish = filter_input(INPUT_POST, 'ispublish');
         $playlist_slug = $this->_wpdb->get_var('SELECT COUNT(playlist_slugname) FROM ' . $wpdb->prefix . 'hdflvvideoshare_playlist WHERE playlist_slugname LIKE "' . $playlist_slugname . '%"');
         if ($playlist_slug > 0) {
             $playlist_slugname = $playlist_slugname . '-' . intval($playlist_slug + 1);
         }
         $playlsitData = array('playlist_name' => $playlistName, 'playlist_slugname' => $playlist_slugname, 'is_publish' => $playlistPublish);
         if ($this->_playListId) {
             $updateflag = $this->playlist_update($playlsitData, $this->_playListId);
             if ($updateflag) {
                 $this->admin_redirect('admin.php?page=newplaylist&playlistId=' . $this->_playListId . '&update=1');
             } else {
                 $this->admin_redirect('admin.php?page=newplaylist&playlistId=' . $this->_playListId . '&update=0');
             }
         } else {
             $ordering = $wpdb->get_var('SELECT COUNT( pid ) FROM ' . $wpdb->prefix . 'hdflvvideoshare_playlist');
             $ordering = $wpdb->get_var("SELECT MAX(playlist_order) FROM " . $wpdb->prefix . "hdflvvideoshare_playlist");
             $playlsitData['playlist_order'] = $ordering + 1;
             $addflag = $this->insert_playlist($playlsitData);
             if (!$addflag) {
                 $this->admin_redirect('admin.php?page=playlist&add=0');
             } else {
                 $this->admin_redirect('admin.php?page=playlist&add=1');
             }
         }
     }
 }
コード例 #14
0
 public static function save_name($post_id)
 {
     // Refuse without valid nonce:
     if (!isset($_POST['scholar_name_nonce']) || !wp_verify_nonce($_POST['scholar_name_nonce'], plugin_basename(__FILE__))) {
         return;
     }
     //sanitize user input
     $prefix = sanitize_text_field($_POST['scholar_name_prefix']);
     $first = sanitize_text_field($_POST['scholar_name_first']);
     $middle = sanitize_text_field($_POST['scholar_name_middle']);
     $last = sanitize_text_field($_POST['scholar_name_last']);
     $gender = sanitize_text_field($_POST['scholar_name_gender']);
     $suffix = sanitize_text_field($_POST['scholar_name_suffix']);
     // Save the data:
     add_post_meta($post_id, 'scholar_prefix', $prefix, true) or update_post_meta($post_id, 'scholar_prefix', $prefix);
     add_post_meta($post_id, 'scholar_first_name', $first, true) or update_post_meta($post_id, 'scholar_first_name', $first);
     add_post_meta($post_id, 'scholar_last_name', $last, true) or update_post_meta($post_id, 'scholar_last_name', $last);
     add_post_meta($post_id, 'scholar_middle_name', $middle, true) or update_post_meta($post_id, 'scholar_middle_name', $middle);
     add_post_meta($post_id, 'scholar_gender', $gender, true) or update_post_meta($post_id, 'scholar_gender', $gender);
     add_post_meta($post_id, 'scholar_suffix', $suffix, true) or update_post_meta($post_id, 'scholar_suffix', $suffix);
     // Update the post slug:
     // unhook this function to prevent infinite looping
     remove_action('save_post', 'ScholarPerson::save_name');
     $post_name = implode(' ', compact('prefix', 'first', 'middle', 'last'));
     if (!empty($suffix)) {
         $post_name .= ', ' . $suffix;
     }
     // update the post slug
     wp_update_post(array('ID' => $post_id, 'post_name' => sanitize_title($post_name)));
     // re-hook this function
     add_action('save_post', 'ScholarPerson::save_name');
 }
 function translated_attribute_label($label, $name)
 {
     global $sitepress;
     if (is_admin() && !wpml_is_ajax()) {
         global $wpdb, $sitepress_settings;
         $string_id = icl_get_string_id('taxonomy singular name: ' . $label, 'WordPress');
         if (defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '3.2', '>=')) {
             $strings_language = icl_st_get_string_language($string_id);
         } else {
             $strings_language = $sitepress_settings['st']['strings_language'];
         }
         if ($string_id && $sitepress_settings['admin_default_language'] != $strings_language) {
             $string = $wpdb->get_var($wpdb->prepare("SELECT value FROM {$wpdb->prefix}icl_string_translations WHERE string_id = %s and language = %s", $string_id, $sitepress_settings['admin_default_language']));
             if ($string) {
                 return $string;
             }
         } else {
             return $label;
         }
     }
     $name = sanitize_title($name);
     $lang = $sitepress->get_current_language();
     $trnsl_labels = get_option('wcml_custom_attr_translations');
     if (isset($trnsl_labels[$lang][$name])) {
         return $trnsl_labels[$lang][$name];
     }
     return icl_t('WordPress', 'taxonomy singular name: ' . $label, $label);
 }
コード例 #16
0
ファイル: functions.php プロジェクト: oscaru/WP-PluginFactory
function add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null)
{
    global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages;
    $menu_slug = plugin_basename($menu_slug);
    $admin_page_hooks[$menu_slug] = sanitize_title($menu_title);
    $hookname = get_plugin_page_hookname($menu_slug, '');
    if (!empty($function) && !empty($hookname) && current_user_can($capability)) {
        add_action($hookname, $function);
    }
    if (empty($icon_url)) {
        $icon_url = 'dashicons-admin-generic';
        $icon_class = 'menu-icon-generic ';
    } else {
        $icon_url = set_url_scheme($icon_url);
        $icon_class = '';
    }
    $new_menu = array($menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url);
    if (null === $position) {
        $menu[] = $new_menu;
    } else {
        $menu = insertInArray($menu, $position, $new_menu);
    }
    $_registered_pages[$hookname] = true;
    // No parent as top level
    $_parent_pages[$menu_slug] = false;
    return $hookname;
}
コード例 #17
0
 function init()
 {
     if (!class_exists('WooCommerce') && !class_exists('Woocommerce')) {
         add_action('admin_notices', array('WooCommerce_Gateways_Country_Limiter', 'woocommerce_inactive_notice'));
         return;
     }
     $woocommerce = function_exists('WC') ? WC() : $GLOBALS['woocommerce'];
     //// Before WC 2.1.x
     $payment_gateways = $woocommerce->payment_gateways->payment_gateways();
     $current_section = empty($_GET['section']) ? '' : sanitize_title($_GET['section']);
     foreach ($payment_gateways as $id => $gateway) {
         $title = empty($gateway->method_title) ? ucfirst($gateway->id) : $gateway->method_title;
         $this->sections[strtolower(get_class($gateway))] = array('title' => esc_html($title), 'id' => $id);
     }
     if (is_admin() && !empty($current_section)) {
         add_action('woocommerce_settings_checkout', array($this, 'country_options_output'), 1000);
         add_action('woocommerce_update_options_checkout', array($this, 'country_options_update'), 1000);
     }
     add_filter('woocommerce_available_payment_gateways', array($this, 'filter_by_country'), 1000);
     //defaults
     foreach ($payment_gateways as $gateway_id => $gateway) {
         if (!isset($this->settings[$gateway_id]['option'])) {
             $this->settings[$gateway_id]['option'] = 'all';
         }
         if (!isset($this->settings[$gateway_id]['countries']) || !is_array($this->settings[$gateway_id]['countries'])) {
             $this->settings[$gateway_id]['countries'] = array();
         }
     }
     if (is_admin() && !empty($current_section)) {
         if (isset($this->sections[$current_section])) {
             $gateway_id = $this->sections[$current_section]['id'];
             wc_enqueue_js("\r\n                    \r\n                    jQuery(document).ready(function(){\r\n                        var current_option = jQuery('input[name={$gateway_id}_option]:checked');\r\n                        if(current_option.val() == 'all_except' || current_option.val() == 'selected'){\r\n                            jQuery('#pgcl_countries_list').show();\r\n                            current_option.parent().parent().append(jQuery('#pgcl_countries_list'));                    \r\n                        }\r\n                        \r\n                        jQuery('input[name={$gateway_id}_option]').change(function(){\r\n                        \r\n                            if(jQuery(this).val() == 'all_except' || jQuery(this).val() == 'selected'){\r\n                                jQuery(this).parent().parent().append(jQuery('#pgcl_countries_list'));                   \r\n                                jQuery('#pgcl_countries_list').show();\r\n                            }else{\r\n                                jQuery('#pgcl_countries_list').hide();\r\n                            }\r\n                        \r\n                        })\r\n                    })\r\n                    \r\n                ");
         }
     }
 }
コード例 #18
0
 /**
  * Payment redirect URL fitler.
  *
  * @since 1.0.1
  * @param string               $url
  * @param Pronamic_Pay_Payment $payment
  * @return string
  */
 public static function redirect_url($url, $payment)
 {
     global $transaction;
     $transaction_id = $payment->get_source_id();
     $transaction = new MeprTransaction($transaction_id);
     switch ($payment->get_status()) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
         case Pronamic_WP_Pay_Statuses::EXPIRED:
         case Pronamic_WP_Pay_Statuses::FAILURE:
             $product = $transaction->product();
             $url = add_query_arg(array('action' => 'payment_form', 'txn' => $transaction->trans_num, '_wpnonce' => wp_create_nonce('mepr_payment_form')), $product->url());
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             // @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprOptions.php#L768-782
             $mepr_options = MeprOptions::fetch();
             $product = new MeprProduct($transaction->product_id);
             $sanitized_title = sanitize_title($product->post_title);
             $url = $mepr_options->thankyou_page_url('membership=' . $sanitized_title . '&trans_num=' . $transaction->trans_num);
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
         default:
             break;
     }
     return $url;
 }
コード例 #19
0
 function __construct($meta_box)
 {
     $this->_meta_box = $meta_box;
     if (empty($this->_meta_box['id'])) {
         $this->_meta_box['id'] = sanitize_title($this->_meta_box['title']);
     }
     $upload = false;
     foreach ($meta_box['fields'] as $field) {
         if ($field['type'] == 'file' || $field['type'] == 'file_list') {
             $upload = true;
             break;
         }
     }
     add_action('dbx_post_advanced', array(&$this, 'init_fields_for_post'));
     add_action('cmb_init_fields', array(&$this, 'init_fields'));
     global $pagenow;
     if ($upload && in_array($pagenow, array('page.php', 'page-new.php', 'post.php', 'post-new.php'))) {
         add_action('admin_head', array(&$this, 'add_post_enctype'));
     }
     add_action('admin_menu', array(&$this, 'add'));
     add_action('save_post', array(&$this, 'save_for_post'));
     add_action('cmb_save_fields', array(&$this, 'save'));
     add_action('admin_enqueue_scripts', array(&$this, 'enqueue_scripts'));
     add_action('admin_enqueue_scripts', array(&$this, 'enqueue_styles'));
     add_filter('cmb_show_on', array(&$this, 'add_for_id'), 10, 2);
     add_filter('cmb_show_on', array(&$this, 'add_for_page_template'), 10, 2);
 }
コード例 #20
0
function qtranxf_slug_update_translations($name, &$qfields, $default_lang)
{
    global $wpdb;
    //$name = $qfields[$default_lang];
    unset($qfields['qtranslate-original-value']);
    unset($qfields[$default_lang]);
    //use $post->post_name instead since it may have been adjusted by WP
    if (qtranxf_slug_translate_name($default_lang, $name)) {
        qtranxf_slug_del_translation($default_lang, $name);
    }
    foreach ($qfields as $lang => $slug) {
        $slug = sanitize_title($slug);
        //qtranxf_dbg_log('qtranxf_slug_update_translations: origin $slug: ', $slug);
        $slug = qtranxf_slug_unique($slug, $lang, $name);
        //qtranxf_dbg_log('qtranxf_slug_update_translations: unique $slug: ',$slug);
        $sql = null;
        if (qtranxf_slug_translate_name($lang, $name)) {
            if ($name != $slug) {
                $sql = 'UPDATE ' . $wpdb->prefix . 'i18n_slugs SET slug = %s WHERE lang = %s AND name = %s';
            } else {
                $sql = 'DELETE FROM ' . $wpdb->prefix . 'i18n_slugs WHERE slug = %s AND lang = %s AND name = %s';
            }
        } else {
            if ($name != $slug) {
                $sql = 'INSERT INTO ' . $wpdb->prefix . 'i18n_slugs (slug, lang, name) VALUES (%s, %s, %s)';
            }
        }
        if ($sql) {
            $query = $wpdb->prepare($sql, $slug, $lang, $name);
            $wpdb->query($query);
        }
    }
}
コード例 #21
0
 /**
  * Process this field after being posted
  * @return array on success, WP_ERROR on failure
  */
 public function get_cart_item_data()
 {
     $cart_item_data = array();
     foreach ($this->addon['options'] as $key => $option) {
         $option_key = empty($option['label']) ? $key : sanitize_title($option['label']);
         $posted = isset($this->value[$option_key]) ? $this->value[$option_key] : '';
         if ($posted === '') {
             continue;
         }
         $label = $this->get_option_label($option);
         $price = $this->get_option_price($option);
         switch ($this->addon['type']) {
             case "custom_price":
                 $price = floatval(sanitize_text_field($posted));
                 if ($price >= 0) {
                     $cart_item_data[] = array('name' => $label, 'value' => $price, 'price' => $price, 'display' => strip_tags(woocommerce_price($price)));
                 }
                 break;
             case "input_multiplier":
                 $posted = absint($posted);
                 $cart_item_data[] = array('name' => $label, 'value' => $posted, 'price' => $posted * $price);
                 break;
             default:
                 $cart_item_data[] = array('name' => $label, 'value' => wp_kses_post($posted), 'price' => $price);
                 break;
         }
     }
     return $cart_item_data;
 }
コード例 #22
0
 /**
  * Add Contextual help tabs
  */
 public function add_tabs()
 {
     $screen = get_current_screen();
     if (!in_array($screen->id, wc_get_screen_ids())) {
         return;
     }
     $video_map = array('wc-settings' => array('title' => __('General Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/mz2l10u5f6?videoFoam=true'), 'wc-settings-general' => array('title' => __('General Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/mz2l10u5f6?videoFoam=true'), 'wc-settings-products' => array('title' => __('Product Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/lolkan4fxf?videoFoam=true'), 'wc-settings-tax' => array('title' => __('Tax Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/qp1v19dwrh?videoFoam=true'), 'wc-settings-checkout' => array('title' => __('Checkout Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/65yjv96z51?videoFoam=true'), 'wc-settings-shipping' => array('title' => __('Shipping Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/9c9008dxnr?videoFoam=true'), 'wc-settings-account' => array('title' => __('Account Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/35mazq7il2?videoFoam=true'), 'wc-settings-email' => array('title' => __('Email Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/svcaftq4xv?videoFoam=true'), 'wc-settings-api' => array('title' => __('Webhook Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/1q0ny74vvq?videoFoam=true'), 'wc-settings-checkout-wc_gateway_paypal' => array('title' => __('PayPal Standard', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/rbl7e7l4k2?videoFoam=true'), 'wc-settings-checkout-wc_gateway_simplify_commerce' => array('title' => __('Simplify Commerce', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/jdfzjiiw61?videoFoam=true'), 'wc-settings-shipping' => array('title' => __('Shipping Settings', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/9c9008dxnr?videoFoam=true'), 'wc-settings-shipping-wc_shipping_free_shipping' => array('title' => __('Free Shipping', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/po191fmvy9?videoFoam=true'), 'wc-settings-shipping-wc_shipping_local_delivery' => array('title' => __('Local Delivery', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/5qjepx9ozj?videoFoam=true'), 'wc-settings-shipping-wc_shipping_local_pickup' => array('title' => __('Local Pickup', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/pe95ph0apb?videoFoam=true'), 'edit-product_cat' => array('title' => __('Product Categories, Tags, Shipping Classes, &amp; Attributes', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/f0j5gzqigg?videoFoam=true'), 'edit-product_tag' => array('title' => __('Product Categories, Tags, Shipping Classes, &amp; Attributes', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/f0j5gzqigg?videoFoam=true'), 'edit-product_shipping_class' => array('title' => __('Product Categories, Tags, Shipping Classes, &amp; Attributes', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/f0j5gzqigg?videoFoam=true'), 'product_attributes' => array('title' => __('Product Categories, Tags, Shipping Classes, &amp; Attributes', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/f0j5gzqigg?videoFoam=true'), 'product' => array('title' => __('Simple Products', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/ziyjmd4kut?videoFoam=true'), 'wc-status' => array('title' => __('System Status', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/xdn733nnhi?videoFoam=true'), 'wc-reports' => array('title' => __('Reports', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/6aasex0w99?videoFoam=true'), 'edit-shop_coupon' => array('title' => __('Coupons', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/gupd4h8sit?videoFoam=true'), 'shop_coupon' => array('title' => __('Coupons', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/gupd4h8sit?videoFoam=true'), 'edit-shop_order' => array('title' => __('Managing Orders', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/n8n0sa8hee?videoFoam=true'), 'shop_order' => array('title' => __('Managing Orders', 'woocommerce'), 'url' => '//fast.wistia.net/embed/iframe/n8n0sa8hee?videoFoam=true'));
     $page = empty($_GET['page']) ? '' : sanitize_title($_GET['page']);
     $tab = empty($_GET['tab']) ? '' : sanitize_title($_GET['tab']);
     $section = empty($_REQUEST['section']) ? '' : sanitize_title($_REQUEST['section']);
     $video_key = $page ? implode('-', array_filter(array($page, $tab, $section))) : $screen->id;
     // Fallback for sections
     if (!isset($video_map[$video_key])) {
         $video_key = $page ? implode('-', array_filter(array($page, $tab))) : $screen->id;
     }
     // Fallback for tabs
     if (!isset($video_map[$video_key])) {
         $video_key = $page ? $page : $screen->id;
     }
     if (isset($video_map[$video_key])) {
         $screen->add_help_tab(array('id' => 'woocommerce_101_tab', 'title' => __('WooCommerce 101', 'woocommerce'), 'content' => '<h2><a href="http://docs.woothemes.com/document/woocommerce-101-video-series/?utm_source=WooCommerce&utm_medium=Wizard&utm_content=Videos&utm_campaign=Onboarding">' . __('WooCommerce 101', 'woocommerce') . '</a> &ndash; ' . esc_html($video_map[$video_key]['title']) . '</h2>' . '<iframe src="' . esc_url($video_map[$video_key]['url']) . '" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen width="480" height="298"></iframe>'));
     }
     $screen->add_help_tab(array('id' => 'woocommerce_docs_tab', 'title' => __('Documentation', 'woocommerce'), 'content' => '<h2>' . __('Documentation', 'woocommerce') . '</h2>' . '<p>' . __('Should you need help understanding, using, or extending WooCommerce, please read our documentation. You will find all kinds of resources including snippets, tutorials and much more.', 'woocommerce') . '</p>' . '<p><a href="' . 'http://docs.woothemes.com/documentation/plugins/woocommerce/' . '" class="button button-primary">' . __('WooCommerce Documentation', 'woocommerce') . '</a> <a href="' . 'http://docs.woothemes.com/wc-apidocs/' . '" class="button">' . __('Developer API Docs', 'woocommerce') . '</a></p>'));
     $screen->add_help_tab(array('id' => 'woocommerce_support_tab', 'title' => __('Support', 'woocommerce'), 'content' => '<h2>' . __('Support', 'woocommerce') . '</h2>' . '<p>' . sprintf(__('After %sreading the documentation%s, for further assistance you can use the %scommunity forums%s on WordPress.org to talk with other users. If however you are a WooThemes customer, or need help with premium add-ons sold by WooThemes, please %suse our helpdesk%s.', 'woocommerce'), '<a href="http://docs.woothemes.com/documentation/plugins/woocommerce/">', '</a>', '<a href="https://wordpress.org/support/plugin/woocommerce">', '</a>', '<a href="http://support.woothemes.com">', '</a>') . '</p>' . '<p>' . __('Before asking for help we recommend checking the system status page to identify any problems with your configuration.', 'woocommerce') . '</p>' . '<p><a href="' . admin_url('admin.php?page=wc-status') . '" class="button button-primary">' . __('System Status', 'woocommerce') . '</a> <a href="' . 'https://wordpress.org/support/plugin/woocommerce' . '" class="button">' . __('WordPress.org Forums', 'woocommerce') . '</a> <a href="' . 'http://support.woothemes.com' . '" class="button">' . __('WooThemes Customer Support', 'woocommerce') . '</a></p>'));
     $screen->add_help_tab(array('id' => 'woocommerce_education_tab', 'title' => __('Education', 'woocommerce'), 'content' => '<h2>' . __('Education', 'woocommerce') . '</h2>' . '<p>' . __('If you would like to learn about using WooCommerce from an expert, consider following a WooCommerce course ran by one of our educational partners.', 'woocommerce') . '</p>' . '<p><a href="' . 'http://www.woothemes.com/educational-partners/?utm_source=WooCommerce&utm_medium=Wizard&utm_content=Partners&utm_campaign=Onboarding' . '" class="button button-primary">' . __('View Education Partners', 'woocommerce') . '</a></p>'));
     $screen->add_help_tab(array('id' => 'woocommerce_bugs_tab', 'title' => __('Found a bug?', 'woocommerce'), 'content' => '<h2>' . __('Found a bug?', 'woocommerce') . '</h2>' . '<p>' . sprintf(__('If you find a bug within WooCommerce core you can create a ticket via <a href="%s">Github issues</a>. Ensure you read the <a href="%s">contribution guide</a> prior to submitting your report. To help us solve your issue, please be as descriptive as possible and include your <a href="%s">system status report</a>.', 'woocommerce'), 'https://github.com/woothemes/woocommerce/issues?state=open', 'https://github.com/woothemes/woocommerce/blob/master/CONTRIBUTING.md', admin_url('admin.php?page=wc-status')) . '</p>' . '<p><a href="' . 'https://github.com/woothemes/woocommerce/issues?state=open' . '" class="button button-primary">' . __('Report a bug', 'woocommerce') . '</a> <a href="' . admin_url('admin.php?page=wc-status') . '" class="button">' . __('System Status', 'woocommerce') . '</a></p>'));
     $screen->set_help_sidebar('<p><strong>' . __('For more information:', 'woocommerce') . '</strong></p>' . '<p><a href="' . 'http://www.woothemes.com/woocommerce/' . '" target="_blank">' . __('About WooCommerce', 'woocommerce') . '</a></p>' . '<p><a href="' . 'http://wordpress.org/extend/plugins/woocommerce/' . '" target="_blank">' . __('WordPress.org Project', 'woocommerce') . '</a></p>' . '<p><a href="' . 'https://github.com/woothemes/woocommerce' . '" target="_blank">' . __('Github Project', 'woocommerce') . '</a></p>' . '<p><a href="' . 'http://www.woothemes.com/product-category/themes/woocommerce/' . '" target="_blank">' . __('Official Themes', 'woocommerce') . '</a></p>' . '<p><a href="' . 'http://www.woothemes.com/product-category/woocommerce-extensions/' . '" target="_blank">' . __('Official Extensions', 'woocommerce') . '</a></p>');
 }
コード例 #23
0
ファイル: import.php プロジェクト: Beutiste/wordpress
function add_demo_templates()
{
    $dir = dirname(__FILE__) . '/templates';
    if ($handle = opendir($dir)) {
        while (false !== ($entry = readdir($handle))) {
            if ($entry != "." && $entry != ".." && $entry != ".DS_Store") {
                $template_name = str_replace('.php', '', $entry);
                $template_name = str_replace('-', ' ', $template_name);
                $template_name = ucwords($template_name);
                $template = file_get_contents($dir . '/' . $entry);
                $template_arr = array("name" => stripslashes($template_name), "template" => stripslashes($template));
                $option_name = 'wpb_js_templates';
                $saved_templates = get_option($option_name);
                $template_id = sanitize_title($template_name) . "_" . rand();
                if ($saved_templates == false) {
                    $deprecated = '';
                    $autoload = 'no';
                    //
                    $new_template = array();
                    $new_template[$template_id] = $template_arr;
                    //
                    add_option($option_name, $new_template, $deprecated, $autoload);
                } else {
                    $saved_templates[$template_id] = $template_arr;
                    update_option($option_name, $saved_templates);
                }
            }
        }
        closedir($handle);
    }
    return true;
}
コード例 #24
0
ファイル: 1.5.php プロジェクト: nxtclass/NXTClass-Plugin
/**
 * In BuddyPress 1.1 - 1.2.x, this function provided a better version of add_menu_page()
 * that allowed positioning of menus. Deprecated in 1.5 in favour of a nxt core function.
 *
 * @deprecated 1.5
 * @deprecated Use add_menu_page().
 * @since 1.1
 */
function bp_core_add_admin_menu_page($args = '')
{
    global $_registered_pages, $admin_page_hooks, $menu;
    _deprecated_function(__FUNCTION__, '1.5', 'Use add_menu_page()');
    $defaults = array('access_level' => 2, 'file' => false, 'function' => false, 'icon_url' => false, 'menu_title' => '', 'page_title' => '', 'position' => 100);
    $r = nxt_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $file = plugin_basename($file);
    $hookname = get_plugin_page_hookname($file, '');
    $admin_page_hooks[$file] = sanitize_title($menu_title);
    if (!empty($function) && !empty($hookname)) {
        add_action($hookname, $function);
    }
    if (empty($icon_url)) {
        $icon_url = 'images/generic.png';
    } elseif (is_ssl() && 0 === strpos($icon_url, 'http://')) {
        $icon_url = 'https://' . substr($icon_url, 7);
    }
    do {
        $position++;
    } while (!empty($menu[$position]));
    $menu[$position] = array($menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url);
    $_registered_pages[$hookname] = true;
    return $hookname;
}
コード例 #25
0
 /**
  * @inheritdoc
  *
  * @param array $arguments
  */
 public function process_call($arguments)
 {
     $am = $this->get_am();
     $am->ajax_begin(array('nonce' => $am->get_action_js_name(Types_Ajax::CALLBACK_SETTINGS_ACTION)));
     $setting = sanitize_text_field(wpcf_getpost('setting'));
     $setting_value = wpcf_getpost('setting_value');
     if (!is_array($setting_value)) {
         parse_str($setting_value, $setting_value);
         $setting_value = array_pop($setting_value);
     }
     $sanitized_value = array();
     foreach ($setting_value as $key => $value) {
         $sanitized_key = sanitize_title($key);
         $sanitized_value[$sanitized_key] = sanitize_text_field($value);
     }
     // use toolset settings if available
     if (class_exists('Toolset_Settings') && method_exists('Toolset_Settings', 'get_instance')) {
         $toolset_settings = Toolset_Settings::get_instance();
         if (method_exists($toolset_settings, 'save')) {
             $toolset_settings[$setting] = $sanitized_value;
             $toolset_settings->save();
             $am->ajax_finish('success', true);
         }
     } else {
         update_option($setting, $sanitized_value);
         $am->ajax_finish('success', true);
     }
     // default toolset setting error will be used
     // todo throw specific error
     $am->ajax_finish(array('error'), false);
 }
コード例 #26
0
function AtD_print_option($name, $value, $options)
{
    // Attribute-safe version of $name
    $attr_name = sanitize_title($name);
    // Using sanitize_title since there's no comparable function for attributes
    ?>
   <input type="checkbox" id="atd_<?php 
    echo $attr_name;
    ?>
" name="<?php 
    echo $options['name'];
    ?>
[<?php 
    echo $name;
    ?>
]" value="1" <?php 
    checked('1', $options[$name]);
    ?>
> <label for="atd_<?php 
    echo $attr_name;
    ?>
"><?php 
    echo $value;
    ?>
</label>
<?php 
}
コード例 #27
0
ファイル: class-mla-ajax.php プロジェクト: jonpetersen/PHTC
 /**
  * Add flat taxonomy term from "checklist" meta box on the Media Manager Modal Window
  *
  * Adapted from the WordPress post_categories_meta_box() in /wp-admin/includes/meta-boxes.php.
  *
  * @since 2.20
  *
  * @param string The taxonomy name, from $_POST['action']
  *
  * @return void Sends JSON response with updated HTML for the checklist
  */
 private static function _mla_ajax_add_flat_term($key)
 {
     $taxonomy = get_taxonomy($key);
     check_ajax_referer($_POST['action'], '_ajax_nonce-add-' . $key, true);
     if (!current_user_can($taxonomy->cap->edit_terms)) {
         wp_die(-1);
     }
     $new_names = explode(',', $_POST['new' . $key]);
     $new_terms_markup = '';
     foreach ($new_names as $name) {
         if ('' === sanitize_title($name)) {
             continue;
         }
         if (!($id = term_exists($name, $key))) {
             $id = wp_insert_term($name, $key);
         }
         if (is_wp_error($id)) {
             continue;
         }
         if (is_array($id)) {
             $id = absint($id['term_id']);
         } else {
             continue;
         }
         $term = get_term($id, $key);
         $name = $term->name;
         $new_terms_markup .= "<li id='{$key}-{$id}'><label class='selectit'><input value='{$name}' type='checkbox' name='tax_input[{$key}][]' id='in-{$key}-{$id}' checked='checked' />{$name}</label></li>\n";
     }
     // foreach new_name
     $input_new_parent_name = "new{$key}_parent";
     $supplemental = "<input type='hidden' name='{$input_new_parent_name}' id='{$input_new_parent_name}' value='-1' />";
     $add = array('what' => $key, 'id' => $id, 'data' => $new_terms_markup, 'position' => -1, 'supplemental' => array('newcat_parent' => $supplemental));
     $x = new WP_Ajax_Response($add);
     $x->send();
 }
コード例 #28
0
 public function save()
 {
     $template_name = vc_post_param('template_name');
     $template = vc_post_param('template');
     if (!isset($template_name) || trim($template_name) == "" || !isset($template) || trim($template) == "") {
         echo 'Error: TPL-01';
         die;
     }
     $template_arr = array("name" => stripslashes($template_name), "template" => stripslashes($template));
     $saved_templates = get_option($this->option_name);
     $template_id = sanitize_title($template_name) . "_" . rand();
     if ($saved_templates === false) {
         $deprecated = '';
         $autoload = 'no';
         //
         $new_template = array();
         $new_template[$template_id] = $template_arr;
         add_option($this->option_name, $new_template, $deprecated, $autoload);
     } else {
         $saved_templates[$template_id] = $template_arr;
         update_option($this->option_name, $saved_templates);
     }
     $this->renderMenu(true);
     die;
 }
コード例 #29
0
/**
 * Get a product attributes orderby setting.
 *
 * @param mixed $name
 * @return string
 */
function wc_attribute_orderby($name)
{
    global $wpdb;
    $name = str_replace('pa_', '', sanitize_title($name));
    $orderby = $wpdb->get_var($wpdb->prepare("SELECT attribute_orderby FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_name = %s;", $name));
    return apply_filters('woocommerce_attribute_orderby', $orderby, $name);
}
コード例 #30
0
ファイル: widgets.php プロジェクト: websideas/aquila
 function kt_register_sidebars()
 {
     register_sidebar(array('name' => esc_html__('Primary Widget Area', 'adroit'), 'id' => 'primary-widget-area', 'description' => esc_html__('The primary widget area', 'adroit'), 'before_widget' => '<div id="%1$s" class="widget-container %2$s"><div class="widget-inner">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
     register_sidebar(array('name' => esc_html__('Blog Widget Area', 'adroit'), 'id' => 'blog-widget-area', 'description' => esc_html__('The blog widget area', 'adroit'), 'before_widget' => '<div id="%1$s" class="widget-container %2$s"><div class="widget-inner">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
     register_sidebar(array('name' => esc_html__('Side Area', 'adroit'), 'id' => 'side-widget-area', 'description' => esc_html__('The side widget area', 'adroit'), 'before_widget' => '<div id="%1$s" class="widget-container %2$s"><div class="widget-inner">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
     register_sidebar(array('name' => esc_html__('Promo Area', 'adroit'), 'id' => 'promo-area', 'description' => esc_html__('IMPORTANT: For best result select set number of widget to 3.', 'adroit'), 'before_widget' => '<div id="%1$s" class="widget-container %2$s"><div class="widget-inner">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
     $count = 5;
     for ($i = 1; $i <= $count; $i++) {
         register_sidebar(array('name' => sprintf(esc_html__('Sidebar %s', 'adroit'), $i), 'id' => 'sidebar-column-' . $i, 'description' => sprintf(esc_html__('The sidebar column %s widget area', 'adroit'), $i), 'before_widget' => '<div class="widget-container %2$s"><div class="widget-inner">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
     }
     register_sidebar(array('name' => esc_html__('Instagram Footer', 'adroit'), 'id' => 'instagram-footer', 'before_widget' => '<div id="%1$s" class="instagram-widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<!--', 'after_title' => '-->', 'description' => esc_html__('Use the Instagram widget here. IMPORTANT: For best result select "Small" under "Photo Size" and set number of photos to 6.', 'adroit')));
     register_sidebar(array('name' => esc_html__('Footer top', 'adroit'), 'id' => 'footer-top', 'description' => esc_html__('The footer top widget area', 'adroit'), 'before_widget' => '<div id="%1$s" class="widget-container %2$s"><div class="widget-inner">', 'after_widget' => '</div></div>', 'before_title' => '<h4 class="widget-title">', 'after_title' => '</h4>'));
     $count = 4;
     for ($i = 1; $i <= $count; $i++) {
         register_sidebar(array('name' => sprintf(esc_html__('Footer column %s', 'adroit'), $i), 'id' => 'footer-column-' . $i, 'description' => sprintf(esc_html__('The footer column %s widget area', 'adroit'), $i), 'before_widget' => '<div id="%1$s" class="widget-container %2$s"><div class="widget-inner">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
     }
     register_sidebar(array('name' => esc_html__('Footer bottom column 1', 'adroit'), 'id' => 'footer-bottom-1', 'description' => esc_html__('The footer bottom widget area', 'adroit'), 'before_widget' => '<div id="%1$s" class="widget-footer-bottom %2$s">', 'after_widget' => '</div>', 'before_title' => '<!--', 'after_title' => '-->'));
     register_sidebar(array('name' => esc_html__('Footer bottom column 2', 'adroit'), 'id' => 'footer-bottom-2', 'description' => esc_html__('The footer bottom widget area', 'adroit'), 'before_widget' => '<div id="%1$s" class="widget-footer-bottom %2$s">', 'after_widget' => '</div>', 'before_title' => '<!--', 'after_title' => '-->'));
     $sidebars = kt_option('custom_sidebars');
     if (!empty($sidebars) && is_array($sidebars)) {
         foreach ($sidebars as $sidebar) {
             $sidebar = wp_parse_args($sidebar, array('title' => '', 'description' => ''));
             if ($sidebar['title'] != '') {
                 $id = sanitize_title($sidebar['title']);
                 register_sidebar(array('name' => $sidebar['title'], 'id' => $id, 'description' => $sidebar['description'], 'before_widget' => '<div id="%1$s" class="widget-container %2$s"><div class="widget-inner">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
             }
         }
     }
 }