function build_directory_list($roots, $option = array()) { global $WikiName, $BracketName; $list = $warnings = array(); $list['directory'] = $list['warning'] = array(); $pages = Auth::get_existpages(); foreach ($roots as $root) { $matched = FALSE; foreach ($pages as $page) { // $page = strip_bracket($page); // if (preg_match("/^$root.*$/", $page)){ if (strpos($page, $root) === 0) { if (isset($option['directory only']) && $option['directory only'] && strrpos($page, '/') >= strlen($root)) { $page = substr($page, 0, strrpos($page, '/')); } $list['directory'][] = $page; while (strrpos($page, '/') >= strlen($root)) { $page = substr($page, 0, strrpos($page, '/')); $list['directory'][] = $page; } $matched = TRUE; } } if (!$matched) { $list['directory'][] = $root; $warnings[] = '<p><span class="text-danger">' . sprintf(T_("#%s doesn't have the corresponding page. "), $root) . '</span>' . '(<a href="' . get_page_uri($root) . '">' . T_('making') . "</a>)</p>\n"; } } $list['directory'] = array_unique($list['directory']); natcasesort($list['directory']); if (isset($option['quiet']) && !$option['quiet']) { $list['warning'] = $warnings; } return $list; }
function wc_update_200_permalinks() { // Setup default permalinks if shop page is defined $permalinks = get_option('woocommerce_permalinks'); $shop_page_id = wc_get_page_id('shop'); if (empty($permalinks) && $shop_page_id > 0) { $base_slug = $shop_page_id > 0 && get_post($shop_page_id) ? get_page_uri($shop_page_id) : 'shop'; $category_base = get_option('woocommerce_prepend_shop_page_to_urls') == "yes" ? trailingslashit($base_slug) : ''; $category_slug = get_option('woocommerce_product_category_slug') ? get_option('woocommerce_product_category_slug') : _x('product-category', 'slug', 'woocommerce'); $tag_slug = get_option('woocommerce_product_tag_slug') ? get_option('woocommerce_product_tag_slug') : _x('product-tag', 'slug', 'woocommerce'); if ('yes' == get_option('woocommerce_prepend_shop_page_to_products')) { $product_base = trailingslashit($base_slug); } else { if (($product_slug = get_option('woocommerce_product_slug')) !== false && !empty($product_slug)) { $product_base = trailingslashit($product_slug); } else { $product_base = trailingslashit(_x('product', 'slug', 'woocommerce')); } } if (get_option('woocommerce_prepend_category_to_products') == 'yes') { $product_base .= trailingslashit('%product_cat%'); } $permalinks = array('product_base' => untrailingslashit($product_base), 'category_base' => untrailingslashit($category_base . $category_slug), 'attribute_base' => untrailingslashit($category_base), 'tag_base' => untrailingslashit($category_base . $tag_slug)); update_option('woocommerce_permalinks', $permalinks); } }
protected function pageParam($params) { global $post; $name = array_shift($params); $path = get_page_uri($post->ID) . '/' . $name; return get_page_by_path($path); }
function jobman_flush_rewrite_rules() { global $wp_rewrite; $wp_rewrite->feeds[] = 'jobman'; $options = get_option('jobman_options'); $root = get_page($options['main_page']); $url = get_page_uri($root->ID); if (!$url) { return; } $lang = ''; // Hack to support WPML languages in the nice URL if (defined('ICL_SITEPRESS_VERSION') && function_exists('icl_get_languages')) { $languages = icl_get_languages('skip_missing=0'); if (!empty($languages)) { $lang_arr = array(); foreach ($languages as $language) { $lang_arr[] = $language['language_code']; } $lang = '(' . implode('|', $lang_arr) . ')/'; } } if (empty($lang)) { $new_rules = array("{$url}/?([page]*/(\\d+)/?)?\$" => "index.php?jobman_root_id={$root->ID}" . '&page=$matches[2]', "{$url}/apply(/([^/]+))?/?\$" => "index.php?jobman_root_id={$root->ID}" . '&jobman_page=apply&jobman_data=$matches[2]', "{$url}/register(/([^/]+))?/?\$" => "index.php?jobman_root_id={$root->ID}" . '&jobman_page=register&jobman_data=$matches[2]', "{$url}/feed/?\$" => "index.php?feed=jobman", "{$url}/([^/]+)/?(page/(\\d+)/?)?\$" => 'index.php?jobman_data=$matches[1]' . '&page=$matches[3]'); } else { $new_rules = array("({$lang})?{$url}/?([page]*/(\\d+)/?)?\$" => "index.php?jobman_root_id={$root->ID}" . '&lang=$matches[1]' . '&page=$matches[3]', "({$lang})?{$url}/apply(/([^/]+))?/?\$" => "index.php?jobman_root_id={$root->ID}" . '&lang=$matches[1]' . '&jobman_page=apply&jobman_data=$matches[3]', "({$lang})?{$url}/register(/([^/]+))?/?\$" => "index.php?jobman_root_id={$root->ID}" . '&lang=$matches[1]' . '&jobman_page=register&jobman_data=$matches[3]', "({$lang})?{$url}/feed/?\$" => 'index.php?feed=jobman&lang=$matches[1]', "({$lang})?{$url}/([^/]+)/?(page/(\\d+)/?)?\$" => 'index.php?jobman_data=$matches[1]' . '&lang=$matches[2]' . '&page=$matches[4]'); } if (array_key_exists('rewrite_rules', $options) && $options['rewrite_rules'] == $new_rules) { return; } $options['rewrite_rules'] = $new_rules; update_option('jobman_options', $options); $wp_rewrite->flush_rules(false); }
function plugin_tooltip_inline() { $args = func_get_args(); $glossary = array_pop($args); $term = array_shift($args); // $glossary_page = count($args) ? array_shift($args) : ''; $glossary_page = ''; if ($glossary == '') { $glossary = plugin_tooltip_get_glossary($term, $glossary_page, FALSE); // $debug .= "B=$glossary/"; if ($glossary === FALSE) { $glossary = plugin_tooltip_get_page_title($term); if ($glossary === FALSE) { $glossary = ''; } } } $s_glossary = htmlspecialchars($glossary); $page = strip_bracket($term); if (is_page($page)) { $url = get_page_uri($page); $passage = get_pg_passage($page, FALSE); return <<<EOD <a href="{$url}" class="linktip" title="{$s_glossary}{$passage}">{$term}</a> EOD; } else { return <<<EOD <span class="tooltip" title="{$s_glossary}" onmouseover="javascript:this.style.backgroundColor='#ffe4e1';" onmouseout="javascript:this.style.backgroundColor='transparent';">{$term}</span> EOD; } }
/** * Custom Post Types **/ function jigoshop_post_type() { do_action('lox'); global $wpdb; $shop_page_id = get_option('jigoshop_shop_page_id'); $base_slug = get_post($shop_page_id) && get_page_uri($shop_page_id) ? get_page_uri($shop_page_id) : 'shop'; if (get_option('jigoshop_prepend_shop_page_to_urls') == "yes") { $category_base = trailingslashit($base_slug); } else { $category_base = ''; } register_taxonomy('product_cat', array('product'), array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'labels' => array('name' => __('Product Categories', 'jigoshop'), 'singular_name' => __('Product Category', 'jigoshop'), 'search_items' => __('Search Product Categories', 'jigoshop'), 'all_items' => __('All Product Categories', 'jigoshop'), 'parent_item' => __('Parent Product Category', 'jigoshop'), 'parent_item_colon' => __('Parent Product Category:', 'jigoshop'), 'edit_item' => __('Edit Product Category', 'jigoshop'), 'update_item' => __('Update Product Category', 'jigoshop'), 'add_new_item' => __('Add New Product Category', 'jigoshop'), 'new_item_name' => __('New Product Category Name', 'jigoshop')), 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $category_base . _x('product-category', 'slug', 'jigoshop'), 'with_front' => false))); register_taxonomy('product_tag', array('product'), array('hierarchical' => false, 'labels' => array('name' => __('Product Tags', 'jigoshop'), 'singular_name' => __('Product Tag', 'jigoshop'), 'search_items' => __('Search Product Tags', 'jigoshop'), 'all_items' => __('All Product Tags', 'jigoshop'), 'parent_item' => __('Parent Product Tag', 'jigoshop'), 'parent_item_colon' => __('Parent Product Tag:', 'jigoshop'), 'edit_item' => __('Edit Product Tag', 'jigoshop'), 'update_item' => __('Update Product Tag', 'jigoshop'), 'add_new_item' => __('Add New Product Tag', 'jigoshop'), 'new_item_name' => __('New Product Tag Name', 'jigoshop')), 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $category_base . _x('product-tag', 'slug', 'jigoshop'), 'with_front' => false))); $attribute_taxonomies = jigoshop::$attribute_taxonomies; if ($attribute_taxonomies) { foreach ($attribute_taxonomies as $tax) { $name = 'product_attribute_' . strtolower(sanitize_title($tax->attribute_name)); $hierarchical = true; if ($name) { register_taxonomy($name, array('product'), array('hierarchical' => $hierarchical, 'labels' => array('name' => $tax->attribute_name, 'singular_name' => $tax->attribute_name, 'search_items' => __('Search ', 'jigoshop') . $tax->attribute_name, 'all_items' => __('All ', 'jigoshop') . $tax->attribute_name, 'parent_item' => __('Parent ', 'jigoshop') . $tax->attribute_name, 'parent_item_colon' => __('Parent ', 'jigoshop') . $tax->attribute_name . ':', 'edit_item' => __('Edit ', 'jigoshop') . $tax->attribute_name, 'update_item' => __('Update ', 'jigoshop') . $tax->attribute_name, 'add_new_item' => __('Add New ', 'jigoshop') . $tax->attribute_name, 'new_item_name' => __('New ', 'jigoshop') . $tax->attribute_name), 'show_ui' => false, 'query_var' => true, 'show_in_nav_menus' => false, 'rewrite' => array('slug' => $category_base . strtolower(sanitize_title($tax->attribute_name)), 'with_front' => false, 'hierarchical' => $hierarchical))); } } } register_post_type("product", array('labels' => array('name' => __('Products', 'jigoshop'), 'singular_name' => __('Product', 'jigoshop'), 'add_new' => __('Add Product', 'jigoshop'), 'add_new_item' => __('Add New Product', 'jigoshop'), 'edit' => __('Edit', 'jigoshop'), 'edit_item' => __('Edit Product', 'jigoshop'), 'new_item' => __('New Product', 'jigoshop'), 'view' => __('View Product', 'jigoshop'), 'view_item' => __('View Product', 'jigoshop'), 'search_items' => __('Search Products', 'jigoshop'), 'not_found' => __('No Products found', 'jigoshop'), 'not_found_in_trash' => __('No Products found in trash', 'jigoshop'), 'parent' => __('Parent Product', 'jigoshop')), 'description' => __('This is where you can add new products to your store.', 'jigoshop'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'publicly_queryable' => true, 'exclude_from_search' => false, 'menu_position' => 57, 'hierarchical' => true, 'rewrite' => array('slug' => $base_slug, 'with_front' => false), 'query_var' => true, 'supports' => array('title', 'editor', 'thumbnail', 'comments'), 'has_archive' => $base_slug, 'show_in_nav_menus' => false)); register_taxonomy('product_type', array('product'), array('hierarchical' => false, 'show_ui' => false, 'query_var' => true, 'show_in_nav_menus' => false)); register_post_type("shop_order", array('labels' => array('name' => __('Orders', 'jigoshop'), 'singular_name' => __('Order', 'jigoshop'), 'add_new' => __('Add Order', 'jigoshop'), 'add_new_item' => __('Add New Order', 'jigoshop'), 'edit' => __('Edit', 'jigoshop'), 'edit_item' => __('Edit Order', 'jigoshop'), 'new_item' => __('New Order', 'jigoshop'), 'view' => __('View Order', 'jigoshop'), 'view_item' => __('View Order', 'jigoshop'), 'search_items' => __('Search Orders', 'jigoshop'), 'not_found' => __('No Orders found', 'jigoshop'), 'not_found_in_trash' => __('No Orders found in trash', 'jigoshop'), 'parent' => __('Parent Orders', 'jigoshop')), 'description' => __('This is where store orders are stored.', 'jigoshop'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'publicly_queryable' => false, 'exclude_from_search' => true, 'menu_position' => 58, 'hierarchical' => false, 'show_in_nav_menus' => false, 'rewrite' => false, 'query_var' => true, 'supports' => array('title', 'comments'), 'has_archive' => false)); register_taxonomy('shop_order_status', array('shop_order'), array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'labels' => array('name' => __('Order statuses', 'jigoshop'), 'singular_name' => __('Order status', 'jigoshop'), 'search_items' => __('Search Order statuses', 'jigoshop'), 'all_items' => __('All Order statuses', 'jigoshop'), 'parent_item' => __('Parent Order status', 'jigoshop'), 'parent_item_colon' => __('Parent Order status:', 'jigoshop'), 'edit_item' => __('Edit Order status', 'jigoshop'), 'update_item' => __('Update Order status', 'jigoshop'), 'add_new_item' => __('Add New Order status', 'jigoshop'), 'new_item_name' => __('New Order status Name', 'jigoshop')), 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => true, 'rewrite' => false)); if (get_option('jigowatt_update_rewrite_rules') == '1') { // Re-generate rewrite rules global $wp_rewrite; $wp_rewrite->flush_rules(); update_option('jigowatt_update_rewrite_rules', '0'); } }
function custom_init() { global $template_directory; require $template_directory . '/inc/classes/bfi-thumb.php'; require $template_directory . '/inc/classes/custom-post-type.php'; require $template_directory . '/inc/classes/category-dropdown-url-walker.php'; if (function_exists('get_field')) { $work_uri = get_page_uri(get_field('work_page', 'options')); $family_uri = get_page_uri(get_field('family_page', 'options')); //Works custom post type if ($work_uri) { $works = new Custom_Post_Type('Work', array('rewrite' => array('with_front' => false, 'slug' => $work_uri), 'capability_type' => 'post', 'publicly_queryable' => true, 'has_archive' => true, 'hierarchical' => true, 'menu_position' => null, 'menu_icon' => 'dashicons-admin-generic', 'supports' => array('title', 'editor', 'thumbnail'), 'plural' => "Work")); $works->register_taxonomy("Client", array('name' => 'client', 'rewrite' => array('slug' => 'clients')), array('plural' => "Clients")); $works->register_post_type(); } //Family custom post type if ($family_uri) { $family = new Custom_Post_Type('Family', array('rewrite' => array('with_front' => false, 'slug' => $family_uri), 'capability_type' => 'post', 'publicly_queryable' => true, 'has_archive' => false, 'hierarchical' => true, 'menu_position' => null, 'menu_icon' => 'dashicons-admin-users', 'supports' => array('title', 'editor', 'thumbnail'), 'plural' => "Family")); $family->register_taxonomy("Family Category", array('name' => 'family_cat', 'rewrite' => array('slug' => 'family-category')), array('plural' => "Family Categories")); $family->register_post_type(); } //Slides custom post type $slides = new Custom_Post_Type('Slides', array('rewrite' => array('with_front' => false, 'slug' => 'slides'), 'capability_type' => 'post', 'publicly_queryable' => true, 'has_archive' => true, 'hierarchical' => true, 'menu_position' => null, 'menu_icon' => 'dashicons-format-gallery', 'supports' => array('title', 'editor', 'thumbnail'), 'plural' => "Slides")); $slides->register_post_type(); } }
/** * @ticket 26284 */ function test_get_page_uri_without_argument() { $post_id = self::factory()->post->create(array('post_title' => 'Blood Orange announces summer tour dates', 'post_name' => 'blood-orange-announces-summer-tour-dates')); $post = get_post($post_id); $this->go_to(get_permalink($post_id)); $this->assertEquals('blood-orange-announces-summer-tour-dates', get_page_uri()); }
function save() { parent::save(); $course_permalink = $_POST['learn_press_course_base']; if ($course_permalink == 'custom') { // Get permalink without slashes $course_permalink = trim($_POST['course_permalink_structure'], '/'); // This is an invalid base structure and breaks pages if ('%course_category%' == $course_permalink) { $course_permalink = _x('courses', 'slug', 'learn_press') . '/' . $course_permalink; } // Prepending slash $course_permalink = '/' . $course_permalink; } elseif (empty($course_permalink)) { $course_permalink = false; } $course_base = untrailingslashit($course_permalink); update_option('learn_press_course_base', $course_base); // Shop base may require verbose page rules if nesting pages $courses_page_id = learn_press_get_page_id('courses'); $courses_permalink = $courses_page_id > 0 && get_post($courses_page_id) ? get_page_uri($courses_page_id) : _x('courses', 'default-slug', 'learn_press'); if ($courses_page_id && trim($course_base, '/') === $courses_permalink) { update_option('learn_press_use_verbose_page_rules', 'yes'); } else { delete_option('learn_press_use_verbose_page_rules'); } }
/** * Register Post Type * @since 1.0.0 */ public static function register_post_type() { $archive_page_id = documentate_get_option('archive_page_id'); $document_permalink = documentate_get_option('document_base'); $labels = array('name' => __('Documents', 'documentate'), 'singular_name' => __('Document', 'documentate'), 'all_items' => __('Documents', 'documentate'), 'add_new' => __('New Document', 'documentate'), 'add_new_item' => __('Add New Document', 'documentate'), 'edit_item' => __('Edit Document', 'documentate'), 'new_item' => __('New Document', 'documentate'), 'view_item' => __('View Document', 'documentate'), 'search_items' => __('Search Documents', 'documentate'), 'not_found' => __('Nothing found', 'documentate'), 'not_found_in_trash' => __('Nothing found in Trash', 'documentate'), 'parent_item_colon' => ''); $args = apply_filters('documentate_post_type_args', array('labels' => $labels, 'description' => __('This is where you can add new documents to your knowledgebase.', 'documentate'), 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'menu_icon' => 'dashicons-book-alt', 'capability_type' => 'post', 'hierarchical' => false, 'supports' => array('title', 'editor', 'thumbnail', 'tags', 'revisions', 'excerpt'), 'rewrite' => $document_permalink ? array('slug' => untrailingslashit($document_permalink), 'with_front' => false, 'feeds' => true) : false, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'can_export' => true, 'has_archive' => $archive_page_id && get_post($archive_page_id) ? get_page_uri($archive_page_id) : false, 'exclude_from_search' => true)); register_post_type('document', $args); }
function tb_blog_url() { if ($posts_page_id = get_option('page_for_posts')) { return home_url(get_page_uri($posts_page_id)); } else { return home_url(); } }
/** * init_taxonomy function. * * @access public */ function init_taxonomy() { global $woocommerce; $shop_page_id = woocommerce_get_page_id('shop'); $base_slug = $shop_page_id > 0 && get_page($shop_page_id) ? get_page_uri($shop_page_id) : 'shop'; $category_base = get_option('woocommerce_prepend_shop_page_to_urls') == "yes" ? trailingslashit($base_slug) : ''; register_taxonomy('product_brand', array('product'), apply_filters('register_taxonomy_product_brand', array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Brands', 'wc_brands'), 'labels' => array('name' => __('Brands', 'wc_brands'), 'singular_name' => __('Brand', 'wc_brands'), 'search_items' => __('Search Brands', 'wc_brands'), 'all_items' => __('All Brands', 'wc_brands'), 'parent_item' => __('Parent Brand', 'wc_brands'), 'parent_item_colon' => __('Parent Brand:', 'wc_brands'), 'edit_item' => __('Edit Brand', 'wc_brands'), 'update_item' => __('Update Brand', 'wc_brands'), 'add_new_item' => __('Add New Brand', 'wc_brands'), 'new_item_name' => __('New Brand Name', 'wc_brands')), 'show_ui' => true, 'show_in_nav_menus' => true, 'capabilities' => array('manage_terms' => 'manage_woocommerce_products', 'edit_terms' => 'manage_woocommerce_products', 'delete_terms' => 'manage_woocommerce_products', 'assign_terms' => 'manage_woocommerce_products'), 'rewrite' => array('slug' => $category_base . __('brand', 'wc_brands'), 'with_front' => false, 'hierarchical' => true)))); }
public function addBlogPage($default_title = null) { $show_on_front = get_option('show_on_front'); $blog_page = get_option('page_for_posts'); if ($show_on_front == 'page') { $posts_page = get_post($blog_page); $this->entries[] = array('title' => !is_null($default_title) ? $default_title : $posts_page->post_title, 'url' => get_home_url() . '/' . get_page_uri($blog_page)); } }
function gw_get_post_paths($post_type = "") { $results = array(); $query = new WP_Query(array('post_type' => $post_type, 'post_status' => 'publish', 'posts_per_page' => -1, 'update_post_term_cache' => false)); foreach ($query->posts as $post) { $results[$post->post_type . '/' . get_page_uri($post->ID)] = array('id' => $post->ID, 'checksum' => get_post_meta($post->ID, 'gwcs', true)); } return $results; }
public function front_page_url($lang) { if ($this->options['hide_default'] && $lang->slug == $this->options['default_lang']) { return trailingslashit($this->home); } $url = home_url($this->root . get_page_uri($lang->page_on_front)); $url = $this->use_trailing_slashes ? trailingslashit($url) : untrailingslashit($url); return $this->options['force_lang'] ? $this->add_language_to_link($url, $lang) : $url; }
function dhwc_init_taxonomy() { global $woocommerce; $permalinks = get_option('woocommerce_permalinks'); $shop_page_id = woocommerce_get_page_id('shop'); $base_slug = $shop_page_id > 0 && get_post($shop_page_id) ? get_page_uri($shop_page_id) : 'shop'; $product_brand_slug = empty($permalinks['brand_base']) ? _x('product-brand', 'slug', DHVC_WOO) : $permalinks['brand_base']; register_taxonomy('product_brand', apply_filters('dhwc_taxonomy_objects_product_brand', array('product')), apply_filters('dhwc_taxonomy_args_product_brand', array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Product Brands', DHVC_WOO), 'labels' => array('name' => __('Product Brands', DHVC_WOO), 'singular_name' => __('Product Brand', DHVC_WOO), 'menu_name' => _x('Brands', 'Admin menu name', DHVC_WOO), 'search_items' => __('Search Product Brands', DHVC_WOO), 'all_items' => __('All Product Brands', DHVC_WOO), 'parent_item' => __('Parent Product Brand', DHVC_WOO), 'parent_item_colon' => __('Parent Product Brand:', DHVC_WOO), 'edit_item' => __('Edit Product Brand', DHVC_WOO), 'update_item' => __('Update Product Brand', DHVC_WOO), 'add_new_item' => __('Add New Product Brand', DHVC_WOO), 'new_item_name' => __('New Product Brand Name', DHVC_WOO)), 'show_ui' => true, 'show_in_nav_menus' => 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' => $product_brand_slug, 'with_front' => false, 'hierarchical' => true)))); }
function plugin_back_convert() { $_msg_back_word = _('Back'); if (func_num_args() > 4) { return PLUGIN_BACK_USAGE; } list($word, $align, $hr, $href) = array_pad(func_get_args(), 4, ''); $word = trim($word); $word = $word == '' ? $_msg_back_word : htmlspecialchars($word); $align = strtolower(trim($align)); switch ($align) { case '': $align = 'center'; /*FALLTHROUGH*/ /*FALLTHROUGH*/ case 'center': /*FALLTHROUGH*/ /*FALLTHROUGH*/ case 'left': /*FALLTHROUGH*/ /*FALLTHROUGH*/ case 'right': break; default: return PLUGIN_BACK_USAGE; } $hr = trim($hr) != '0' ? '<hr class="full_hr" />' . "\n" : ''; $link = TRUE; $href = trim($href); if ($href != '') { if (PLUGIN_BACK_ALLOW_PAGELINK) { if (is_url($href)) { $href = rawurlencode($href); } else { $array = anchor_explode($href); $array[1] = $array[1] != '' ? '#' . rawurlencode($array[1]) : ''; $href = get_page_uri($array[0]) . $array[1]; $link = is_page($array[0]); } } else { $href = rawurlencode($href); } } else { if (!PLUGIN_BACK_ALLOW_JAVASCRIPT) { return PLUGIN_BACK_USAGE . ': Set a page name or an URI'; } $href = 'javascript:history.go(-1)'; } if ($link) { // Normal link return $hr . '<div style="text-align:' . $align . '">' . '[ <a href="' . $href . '">' . $word . '</a> ]</div>' . "\n"; } else { // Dangling link return $hr . '<div style="text-align:' . $align . '">' . '[ <span class="noexists">' . $word . '<a href="' . $href . '">?</a></span> ]</div>' . "\n"; } }
function bh_get_page_path(&$p = null, $current = false) { if (empty($p) && $current) { global $post, $bh_hierarchy; if (!empty($bh_hierarchy)) { $h = $bh_hierarchy; $p = array_pop($h); if (defined('DEBUG_PATHS') && DEBUG_PATHS) { do_action('log', 'get_page_path: Reverting to hierarchy top', $p); } } else { if (!is_search()) { $p = $post; if (defined('DEBUG_PATHS') && DEBUG_PATHS) { do_action('log', 'get_page_path: Reverting to global post', $post); } } } } if (is_object($p) && !empty($p->_page_path)) { if (defined('DEBUG_PATHS') && DEBUG_PATHS) { do_action('log', 'get_page_path: Stored page path', $p->_page_path); } return $p->_page_path; } if (!empty($p) && 'page' === $p->post_type) { $page_id = bh_select_post_id($p); $path = get_page_uri($page_id); if (defined('DEBUG_PATHS') && DEBUG_PATHS) { do_action('log', 'get_page_path: Page URI', $path); } } if (empty($path) || is_numeric($path)) { if (!empty($p) || !is_search()) { $permalink = get_permalink($p); $path = substr(get_permalink(bh_select_post_id($p)), strlen(get_option('home'))); $path = trim($path, '/'); if (defined('DEBUG_PATHS') && DEBUG_PATHS) { do_action('log', 'get_page_path: Permalink', $path); } } } if ($current && empty($path)) { $path = $_SERVER['REQUEST_URI']; $path = preg_replace('!^https?://[^/]+/!i', '', $path); $path = preg_replace('!\\?.*$!i', '', $path); $path = trim($path, '/'); if (defined('DEBUG_PATHS') && DEBUG_PATHS) { do_action('log', 'get_page_path: Hard URI', $path); } } if (is_object($p)) { $p->_page_path = $path; } return $path; }
/** * Prepare post data * * @param array $post The unprepared post data * @param array $fields The subset of post type fields to return * @return array The prepared post data */ protected function prepare_post($post, $context = 'view') { $_post = parent::prepare_post($post, $context); // Override entity meta keys with the correct links $_post['meta']['links']['self'] = json_url($this->base . '/' . get_page_uri($post['ID'])); if (!empty($post['post_parent'])) { $_post['meta']['links']['up'] = json_url($this->base . '/' . get_page_uri((int) $post['post_parent'])); } return apply_filters('json_prepare_page', $_post, $post, $context); }
function plugin_yetlist_action() { // global $_title_yetlist, $_err_notexist, $_symbol_noexists, $non_list; global $_symbol_noexists, $non_list, $whatsdeleted; $retval = array('msg' => 'yetlist', 'body' => T_('List of pages which have not yet been created.')); // Diff $pages = array_diff(Auth::get_existpages(CACHE_DIR, '.ref'), Auth::get_existpages()); if (empty($pages)) { $retval['body'] = T_('All pages have been created.'); return $retval; } $empty = TRUE; // Load .ref files and Output $refer_regex = '/' . $non_list . '|^' . preg_quote($whatsdeleted, '/') . '$/S'; asort($pages, SORT_STRING); foreach ($pages as $file => $page) { $refer = array(); foreach (file(CACHE_DIR . $file) as $line) { list($_page) = explode("\t", rtrim($line)); $refer[] = $_page; } // Diff $refer = array_diff($refer, preg_grep($refer_regex, $refer)); if (!empty($refer)) { $empty = FALSE; $refer = array_unique($refer); sort($refer, SORT_STRING); $r_refer = ''; $link_refs = array(); foreach ($refer as $_refer) { $r_refer = rawurlencode($_refer); $link_refs[] = '<a href="' . get_page_uri($_refer) . '">' . htmlsc($_refer) . '</a>'; } $link_ref = join(' ', $link_refs); unset($link_refs); $s_page = htmlsc($page); // if (PKWK_READONLY) { if (Auth::check_role('readonly')) { $href = $s_page; } else { // Dangling link $href = '<span class="noexists">' . $s_page . '<a href="' . get_cmd_uri('edit', $page, '', 'refer=' . $r_refer) . '">' . $_symbol_noexists . '</a></span>'; } $retval['body'] .= '<li>' . $href . ' <em>(' . $link_ref . ')</em></li>' . "\n"; } } if ($empty) { $retval['body'] = $_err_notexist; return $retval; } if ($retval['body'] != '') { $retval['body'] = '<ul>' . "\n" . $retval['body'] . '</ul>' . "\n"; } return $retval; }
function scripts() { if (is_page('contact')) { wp_enqueue_script('js-validate', get_template_directory_uri() . '/js/jquery.validate.min.js', array(), '1.14.0', TRUE); } // global $body_id; $body_id = get_page_uri('') == 'hello-world' ? 'index' : get_page_uri(''); $ar_body_id = explode('/', $body_id); $body_id = $ar_body_id[0]; }
/** * Register course post type */ function register_post_type() { $labels = array('name' => _x('Courses', 'Post Type General Name', 'learn_press'), 'singular_name' => _x('Course', 'Post Type Singular Name', 'learn_press'), 'menu_name' => __('Courses', 'learn_press'), 'parent_item_colon' => __('Parent Item:', 'learn_press'), 'all_items' => __('Courses', 'learn_press'), 'view_item' => __('View Course', 'learn_press'), 'add_new_item' => __('Add New Course', 'learn_press'), 'add_new' => __('Add New', 'learn_press'), 'edit_item' => __('Edit Course', 'learn_press'), 'update_item' => __('Update Course', 'learn_press'), 'search_items' => __('Search Course', 'learn_press'), 'not_found' => __('No course found', 'learn_press'), 'not_found_in_trash' => __('No course found in Trash', 'learn_press')); $args = array('labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'has_archive' => ($page_id = learn_press_get_page_id('courses')) && get_post($page_id) ? get_page_uri($page_id) : 'courses', 'capability_type' => LPR_COURSE_CPT, 'map_meta_cap' => true, 'show_in_menu' => 'learn_press', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'taxonomies' => array('course_category', 'course_tag'), 'supports' => array('title', 'editor', 'thumbnail', 'revisions', 'comments', 'author'), 'hierarchical' => true, 'rewrite' => array('slug' => 'courses', 'hierarchical' => true, 'with_front' => false)); register_post_type(LPR_COURSE_CPT, $args); register_taxonomy('course_category', array(LPR_COURSE_CPT), array('label' => __('Course Categories', 'learn_press'), 'labels' => array('name' => __('Course Categories', 'learn_press'), 'menu_name' => __('Category', 'learn_press'), 'singular_name' => __('Category', 'learn_press'), 'add_new_item' => __('Add New Course Category', 'learn_press'), 'all_items' => __('All Categories', 'learn_press')), 'query_var' => true, 'public' => true, 'hierarchical' => true, 'show_ui' => true, 'show_in_menu' => 'learn_press', 'show_admin_column' => true, 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'rewrite' => array('slug' => 'course_category', 'hierarchical' => true, 'with_front' => false))); register_taxonomy('course_tag', array(LPR_COURSE_CPT), array('labels' => array('name' => __('Course Tags', 'learn_press'), 'singular_name' => __('Tag', 'learn_press'), 'search_items' => __('Search Course Tags'), 'popular_items' => __('Popular Course Tags'), 'all_items' => __('All Course Tags'), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __('Edit Course Tag'), 'update_item' => __('Update Course Tag'), 'add_new_item' => __('Add New Course Tag'), 'new_item_name' => __('New Course Tag Name'), 'separate_items_with_commas' => __('Separate tags with commas'), 'add_or_remove_items' => __('Add or remove tags'), 'choose_from_most_used' => __('Choose from the most used tags'), 'menu_name' => __('Tags')), 'public' => true, 'hierarchical' => false, 'show_ui' => true, 'show_in_menu' => 'learn_press', 'update_count_callback' => '_update_post_term_count', 'query_var' => true)); if (!is_admin()) { LPR_Assets::enqueue_script('tipsy', LPR_PLUGIN_URL . '/assets/js/jquery.tipsy.js'); LPR_Assets::enqueue_style('tipsy', LPR_PLUGIN_URL . '/assets/css/tipsy.css'); } }
function plugin_diff_view($page) { global $script, $hr; // global $_msg_notfound, $_msg_goto, $_msg_deleted, $_msg_addline, $_msg_delline; // global $_title_diff, $_title_diff_delete; if (auth::check_role('safemode')) { die_message('PKWK_SAFE_MODE prohibits this'); } $_msg_notfound = _('The page was not found.'); $_msg_addline = _('The added line is <span class="diff_added">THIS COLOR</span>.'); $_msg_delline = _('The deleted line is <span class="diff_removed">THIS COLOR</span>.'); $_msg_goto = _('Go to $1.'); $_msg_deleted = _(' $1 has been deleted.'); $_title_diff = _('Diff of $1'); $_title_diff_delete = _('Deleting diff of $1'); $r_page = rawurlencode($page); $s_page = htmlspecialchars($page); $menu = array('<li>' . $_msg_addline . '</li>', '<li>' . $_msg_delline . '</li>'); $is_page = is_page($page); if ($is_page) { $menu[] = ' <li>' . str_replace('$1', '<a href="' . get_page_uri($page) . '">' . $s_page . '</a>', $_msg_goto) . '</li>'; } else { $menu[] = ' <li>' . str_replace('$1', $s_page, $_msg_deleted) . '</li>'; } $filename = DIFF_DIR . encode($page) . '.txt'; if (file_exists($filename)) { // if (! PKWK_READONLY) { if (!auth::check_role('readonly')) { $menu[] = '<li><a href="' . $script . '?cmd=diff&action=delete&page=' . $r_page . '">' . str_replace('$1', $s_page, $_title_diff_delete) . '</a></li>'; } $source = join('', file($filename)); auth::is_role_page($source); $msg = '<pre>' . diff_style_to_css(htmlspecialchars($source)) . '</pre>' . "\n"; } else { if ($is_page) { $source = join('', get_source($page)); auth::is_role_page($source); $diffdata = trim(htmlspecialchars($source)); $msg = '<pre><span class="diff_added">' . $diffdata . '</span></pre>' . "\n"; } else { return array('msg' => $_title_diff, 'body' => $_msg_notfound); } } $menu = join("\n", $menu); $body = <<<EOD <ul> {$menu} </ul> {$hr} EOD; return array('msg' => $_title_diff, 'body' => $body . $msg); }
/** * Register 'Recipe' Post Type. * * @package Recipe Hero * @author Captain Theme <*****@*****.**> * @since 1.0.8 */ public static function register_post_types() { if (post_type_exists('recipe')) { return; } $permalinks = get_option('recipe_hero_permalinks'); $recipe_permalink = empty($permalinks['recipe_base']) ? _x('recipe', 'slug', 'recipe-hero') : $permalinks['recipe_base']; $labels = array('name' => _x('Recipes', 'post type general name'), 'singular_name' => _x('Recipe', 'post type singular name'), 'all_items' => __('All Recipes'), 'add_new' => __('Add New'), 'add_new_item' => __('Add New Recipe'), 'edit_item' => __('Edit Recipe'), 'new_item' => __('New Recipe'), 'view_item' => __('View Recipe'), 'search_items' => __('Search Recipes'), 'not_found' => __('No Recipes found'), 'not_found_in_trash' => __('No Recipes found in the trash'), 'parent_item_colon' => '', 'menu_name' => __('Recipe Hero')); $taxonomies = array(); $supports = array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields', 'publicize', 'page-attributes'); $post_type_args = apply_filters('recipe_hero_recipe_post_type_args', array('labels' => $labels, 'singular_label' => __('Recipe'), 'public' => true, 'show_ui' => true, 'publicly_queryable' => true, 'query_var' => true, 'exclude_from_search' => false, 'show_in_nav_menus' => true, 'capability_type' => 'post', 'has_archive' => ($recipes_page_id = rh_get_page_id('recipes')) && get_post($recipes_page_id) ? get_page_uri($recipes_page_id) : 'recipes', 'hierarchical' => false, 'rewrite' => $recipe_permalink ? array('slug' => untrailingslashit($recipe_permalink), 'with_front' => false, 'feeds' => true) : false, 'supports' => $supports, 'menu_position' => 35, 'menu_icon' => 'dashicons-shield', 'taxonomies' => $taxonomies)); register_post_type('recipe', $post_type_args); }
/** * Register core post types */ public static function register_post_types() { if (post_type_exists('property')) { return; } do_action('propertyhive_register_post_type'); //$permalinks = get_option( 'property_permalinks' ); //$product_permalink = empty( $permalinks['property_base'] ) ? _x( 'property', 'slug', 'propertyhive' ) : $permalinks['property_base']; register_post_type("property", apply_filters('propertyhive_register_post_type_property', array('labels' => array('name' => __('Properties', 'propertyhive'), 'singular_name' => __('Property', 'propertyhive'), 'menu_name' => _x('Properties', 'Admin menu name', 'propertyhive'), 'add_new' => __('Add Property', 'propertyhive'), 'add_new_item' => __('Add New Property', 'propertyhive'), 'edit' => __('Edit', 'propertyhive'), 'edit_item' => __('Edit Property', 'propertyhive'), 'new_item' => __('New Property', 'propertyhive'), 'view' => __('View Property', 'propertyhive'), 'view_item' => __('View Property', 'propertyhive'), 'search_items' => __('Search Properties', 'propertyhive'), 'not_found' => __('No properties found', 'propertyhive'), 'not_found_in_trash' => __('No properties found in trash', 'propertyhive'), 'parent' => __('Parent Property', 'propertyhive')), 'description' => __('This is where you can add new properties to your site.', 'propertyhive'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'map_meta_cap' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'hierarchical' => false, 'query_var' => true, 'supports' => array('title', 'excerpt'), 'has_archive' => ($search_results_page_id = ph_get_page_id('search_results')) && get_page($search_results_page_id) ? get_page_uri($search_results_page_id) : 'search_results', 'show_in_nav_menus' => false, 'show_in_menu' => false, 'show_in_admin_bar' => true, 'show_in_rest' => true))); register_post_type("contact", apply_filters('propertyhive_register_post_type_contact', array('labels' => array('name' => __('Contacts', 'propertyhive'), 'singular_name' => __('Contact', 'propertyhive'), 'menu_name' => _x('Contacts', 'Admin menu name', 'propertyhive'), 'add_new' => __('Add Contact', 'propertyhive'), 'add_new_item' => __('Add New Contact', 'propertyhive'), 'edit' => __('Edit', 'propertyhive'), 'edit_item' => __('Edit Contact', 'propertyhive'), 'new_item' => __('New Contact', 'propertyhive'), 'view' => __('View Contact', 'propertyhive'), 'view_item' => __('View Contact', 'propertyhive'), 'search_items' => __('Search Contacts', 'propertyhive'), 'not_found' => __('No contacts found', 'propertyhive'), 'not_found_in_trash' => __('No contacts found in trash', 'propertyhive'), 'parent' => __('Parent Contact', 'propertyhive')), 'description' => __('This is where you can add new contacts to your site.', 'propertyhive'), 'public' => false, 'show_ui' => true, 'capability_type' => 'post', 'map_meta_cap' => true, 'publicly_queryable' => true, 'exclude_from_search' => true, 'hierarchical' => false, 'query_var' => true, 'supports' => array('title'), 'show_in_nav_menus' => false, 'show_in_menu' => false))); register_post_type("office", apply_filters('propertyhive_register_post_type_office', array('public' => true, 'show_ui' => false, 'capability_type' => 'post', 'map_meta_cap' => true, 'publicly_queryable' => true, 'exclude_from_search' => true, 'hierarchical' => false, 'query_var' => true, 'supports' => array('title'), 'show_in_nav_menus' => false, 'show_in_menu' => false))); register_post_type("enquiry", apply_filters('propertyhive_register_post_type_enquiry', array('labels' => array('name' => __('Enquiries', 'propertyhive'), 'singular_name' => __('Enquiry', 'propertyhive'), 'menu_name' => _x('Enquiries', 'Admin menu name', 'propertyhive'), 'add_new' => __('Add Enquiry', 'propertyhive'), 'add_new_item' => __('Add New Enquiry', 'propertyhive'), 'edit' => __('Edit', 'propertyhive'), 'edit_item' => __('Edit Enquiry', 'propertyhive'), 'new_item' => __('New Enquiry', 'propertyhive'), 'view' => __('View Enquiry', 'propertyhive'), 'view_item' => __('View Enquiry', 'propertyhive'), 'search_items' => __('Search Enquiries', 'propertyhive'), 'not_found' => __('No enquiries found', 'propertyhive'), 'not_found_in_trash' => __('No enquiries found in trash', 'propertyhive'), 'parent' => __('Parent Enquiry', 'propertyhive')), 'public' => false, 'show_ui' => true, 'capability_type' => 'post', 'map_meta_cap' => true, 'publicly_queryable' => false, 'exclude_from_search' => true, 'hierarchical' => false, 'query_var' => true, 'supports' => array('title'), 'show_in_nav_menus' => false, 'show_in_menu' => false))); do_action('propertyhive_after_register_post_types'); }
public static function createPageObject($getComments = false, $postObject = null) { global $post; if ($postObject != null) { setup_postdata($postObject); } $params = array('pageLink' => get_page_link(), 'post_title' => get_the_title(), 'time' => get_the_time(), 'post_content' => apply_filters('the_content', get_the_content()), 'post_excerpt' => get_the_excerpt(), 'post_author' => get_the_author(), 'author_link' => get_the_author_link(), 'thumbnails' => self::getThumbnails($post), 'pageUri' => get_page_uri($post), 'comments' => ''); if ($getComments != false) { $params['comments'] = self::getComments($post->ID); } $post_object_var = get_object_vars($post); $post_params = $params + $post_object_var; return new Page($post_params); }
/** * Get default robots rules for the calendar * * @param string $output Current robots rules * @param string $public Public flag * @return array */ public function rules($output, $public) { // Current rules $current_rules = array_map('trim', explode(PHP_EOL, $output)); // Get calendar page URI $calendar_page_id = $this->_registry->get('model.settings')->get('calendar_page_id'); $page_base = get_page_uri($calendar_page_id); // Custom rules $custom_rules = array(); if ($page_base) { $custom_rules += array("User-agent: *", "Disallow: /{$page_base}/action~posterboard/", "Disallow: /{$page_base}/action~agenda/", "Disallow: /{$page_base}/action~oneday/", "Disallow: /{$page_base}/action~month/", "Disallow: /{$page_base}/action~week/", "Disallow: /{$page_base}/action~stream/"); } $robots = array_merge($current_rules, $custom_rules); return implode(PHP_EOL, array_filter(array_unique($robots))); }
/** * Get settings array * * @return array */ public function get_settings($current_section = '') { if ($current_section == 'inventory') { return apply_filters('woocommerce_inventory_settings', array(array('title' => __('Inventory Options', 'woocommerce'), 'type' => 'title', 'desc' => '', 'id' => 'inventory_options'), array('title' => __('Manage Stock', 'woocommerce'), 'desc' => __('Enable stock management', 'woocommerce'), 'id' => 'woocommerce_manage_stock', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Hold Stock (minutes)', 'woocommerce'), 'desc' => __('Hold stock (for unpaid orders) for x minutes. When this limit is reached, the pending order will be cancelled. Leave blank to disable.', 'woocommerce'), 'id' => 'woocommerce_hold_stock_minutes', 'type' => 'number', 'custom_attributes' => array('min' => 0, 'step' => 1), 'css' => 'width:50px;', 'default' => '60', 'autoload' => false), array('title' => __('Notifications', 'woocommerce'), 'desc' => __('Enable low stock notifications', 'woocommerce'), 'id' => 'woocommerce_notify_low_stock', 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'start', 'autoload' => false), array('desc' => __('Enable out of stock notifications', 'woocommerce'), 'id' => 'woocommerce_notify_no_stock', 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'end', 'autoload' => false), array('title' => __('Notification Recipient', 'woocommerce'), 'desc' => '', 'id' => 'woocommerce_stock_email_recipient', 'type' => 'email', 'default' => get_option('admin_email'), 'autoload' => false), array('title' => __('Low Stock Threshold', 'woocommerce'), 'desc' => '', 'id' => 'woocommerce_notify_low_stock_amount', 'css' => 'width:50px;', 'type' => 'number', 'custom_attributes' => array('min' => 0, 'step' => 1), 'default' => '2', 'autoload' => false), array('title' => __('Out Of Stock Threshold', 'woocommerce'), 'desc' => '', 'id' => 'woocommerce_notify_no_stock_amount', 'css' => 'width:50px;', 'type' => 'number', 'custom_attributes' => array('min' => 0, 'step' => 1), 'default' => '0', 'autoload' => false), array('title' => __('Out Of Stock Visibility', 'woocommerce'), 'desc' => __('Hide out of stock items from the catalog', 'woocommerce'), 'id' => 'woocommerce_hide_out_of_stock_items', 'default' => 'no', 'type' => 'checkbox'), array('title' => __('Stock Display Format', 'woocommerce'), 'desc' => __('This controls how stock is displayed on the frontend.', 'woocommerce'), 'id' => 'woocommerce_stock_format', 'css' => 'min-width:150px;', 'default' => '', 'type' => 'select', 'options' => array('' => __('Always show stock e.g. "12 in stock"', 'woocommerce'), 'low_amount' => __('Only show stock when low e.g. "Only 2 left in stock" vs. "In Stock"', 'woocommerce'), 'no_amount' => __('Never show stock amount', 'woocommerce')), 'desc_tip' => true), array('type' => 'sectionend', 'id' => 'inventory_options'))); } else { // Get shop page $shop_page_id = wc_get_page_id('shop'); $base_slug = $shop_page_id > 0 && get_page($shop_page_id) ? get_page_uri($shop_page_id) : 'shop'; $woocommerce_prepend_shop_page_to_products_warning = ''; if ($shop_page_id > 0 && sizeof(get_pages("child_of={$shop_page_id}")) > 0) { $woocommerce_prepend_shop_page_to_products_warning = ' <mark class="notice">' . __('Note: The shop page has children - child pages will not work if you enable this option.', 'woocommerce') . '</mark>'; } return apply_filters('woocommerce_product_settings', array(array('title' => __('Product Listings', 'woocommerce'), 'type' => 'title', 'desc' => '', 'id' => 'catalog_options'), array('title' => __('Product Archive / Shop Page', 'woocommerce'), 'desc' => '<br/>' . sprintf(__('The base page can also be used in your <a href="%s">product permalinks</a>.', 'woocommerce'), admin_url('options-permalink.php')), 'id' => 'woocommerce_shop_page_id', 'type' => 'single_select_page', 'default' => '', 'class' => 'chosen_select_nostd', 'css' => 'min-width:300px;', 'desc_tip' => __('This sets the base page of your shop - this is where your product archive will be.', 'woocommerce')), array('title' => __('Shop Page Display', 'woocommerce'), 'desc' => __('This controls what is shown on the product archive.', 'woocommerce'), 'id' => 'woocommerce_shop_page_display', 'class' => 'chosen_select', 'css' => 'min-width:300px;', 'default' => '', 'type' => 'select', 'options' => array('' => __('Show products', 'woocommerce'), 'subcategories' => __('Show subcategories', 'woocommerce'), 'both' => __('Show both', 'woocommerce')), 'desc_tip' => true), array('title' => __('Default Category Display', 'woocommerce'), 'desc' => __('This controls what is shown on category archives.', 'woocommerce'), 'id' => 'woocommerce_category_archive_display', 'class' => 'chosen_select', 'css' => 'min-width:300px;', 'default' => '', 'type' => 'select', 'options' => array('' => __('Show products', 'woocommerce'), 'subcategories' => __('Show subcategories', 'woocommerce'), 'both' => __('Show both', 'woocommerce')), 'desc_tip' => true), array('title' => __('Default Product Sorting', 'woocommerce'), 'desc' => __('This controls the default sort order of the catalog.', 'woocommerce'), 'id' => 'woocommerce_default_catalog_orderby', 'class' => 'chosen_select', 'css' => 'min-width:300px;', 'default' => 'title', 'type' => 'select', 'options' => apply_filters('woocommerce_default_catalog_orderby_options', array('menu_order' => __('Default sorting (custom ordering + name)', 'woocommerce'), 'popularity' => __('Popularity (sales)', 'woocommerce'), 'rating' => __('Average Rating', 'woocommerce'), 'date' => __('Sort by most recent', 'woocommerce'), 'price' => __('Sort by price (asc)', 'woocommerce'), 'price-desc' => __('Sort by price (desc)', 'woocommerce'))), 'desc_tip' => true), array('title' => __('Add to cart', 'woocommerce'), 'desc' => __('Redirect to the cart page after successful addition', 'woocommerce'), 'id' => 'woocommerce_cart_redirect_after_add', 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'start'), array('desc' => __('Enable AJAX add to cart buttons on archives', 'woocommerce'), 'id' => 'woocommerce_enable_ajax_add_to_cart', 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'end'), array('type' => 'sectionend', 'id' => 'catalog_options'), array('title' => __('Product Data', 'woocommerce'), 'type' => 'title', 'id' => 'product_data_options'), array('title' => __('Weight Unit', 'woocommerce'), 'desc' => __('This controls what unit you will define weights in.', 'woocommerce'), 'id' => 'woocommerce_weight_unit', 'class' => 'chosen_select', 'css' => 'min-width:300px;', 'default' => 'kg', 'type' => 'select', 'options' => array('kg' => __('kg', 'woocommerce'), 'g' => __('g', 'woocommerce'), 'lbs' => __('lbs', 'woocommerce'), 'oz' => __('oz', 'woocommerce')), 'desc_tip' => true), array('title' => __('Dimensions Unit', 'woocommerce'), 'desc' => __('This controls what unit you will define lengths in.', 'woocommerce'), 'id' => 'woocommerce_dimension_unit', 'class' => 'chosen_select', 'css' => 'min-width:300px;', 'default' => 'cm', 'type' => 'select', 'options' => array('m' => __('m', 'woocommerce'), 'cm' => __('cm', 'woocommerce'), 'mm' => __('mm', 'woocommerce'), 'in' => __('in', 'woocommerce'), 'yd' => __('yd', 'woocommerce')), 'desc_tip' => true), array('title' => __('Product Ratings', 'woocommerce'), 'desc' => __('Enable ratings on reviews', 'woocommerce'), 'id' => 'woocommerce_enable_review_rating', 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'start', 'show_if_checked' => 'option', 'autoload' => false), array('desc' => __('Ratings are required to leave a review', 'woocommerce'), 'id' => 'woocommerce_review_rating_required', 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => '', 'show_if_checked' => 'yes', 'autoload' => false), array('desc' => __('Show "verified owner" label for customer reviews', 'woocommerce'), 'id' => 'woocommerce_review_rating_verification_label', 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => '', 'show_if_checked' => 'yes', 'autoload' => false), array('desc' => __('Only allow reviews from "verified owners"', 'woocommerce'), 'id' => 'woocommerce_review_rating_verification_required', 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => 'end', 'show_if_checked' => 'yes', 'autoload' => false), array('type' => 'sectionend', 'id' => 'product_data_options'), array('title' => __('Product Image Sizes', 'woocommerce'), 'type' => 'title', 'desc' => sprintf(__('These settings affect the actual dimensions of images in your catalog - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to <a href="%s">regenerate your thumbnails</a>.', 'woocommerce'), 'http://wordpress.org/extend/plugins/regenerate-thumbnails/'), 'id' => 'image_options'), array('title' => __('Catalog Images', 'woocommerce'), 'desc' => __('This size is usually used in product listings', 'woocommerce'), 'id' => 'shop_catalog_image_size', 'css' => '', 'type' => 'image_width', 'default' => array('width' => '150', 'height' => '150', 'crop' => true), 'desc_tip' => true), array('title' => __('Single Product Image', 'woocommerce'), 'desc' => __('This is the size used by the main image on the product page.', 'woocommerce'), 'id' => 'shop_single_image_size', 'css' => '', 'type' => 'image_width', 'default' => array('width' => '300', 'height' => '300', 'crop' => 1), 'desc_tip' => true), array('title' => __('Product Thumbnails', 'woocommerce'), 'desc' => __('This size is usually used for the gallery of images on the product page.', 'woocommerce'), 'id' => 'shop_thumbnail_image_size', 'css' => '', 'type' => 'image_width', 'default' => array('width' => '90', 'height' => '90', 'crop' => 1), 'desc_tip' => true), array('type' => 'sectionend', 'id' => 'image_options'), array('title' => __('Downloadable Products', 'woocommerce'), 'type' => 'title', 'id' => 'digital_download_options'), array('title' => __('File Download Method', 'woocommerce'), 'desc' => __('Forcing downloads will keep URLs hidden, but some servers may serve large files unreliably. If supported, <code>X-Accel-Redirect</code>/ <code>X-Sendfile</code> can be used to serve downloads instead (server requires <code>mod_xsendfile</code>).', 'woocommerce'), 'id' => 'woocommerce_file_download_method', 'type' => 'select', 'class' => 'chosen_select', 'css' => 'min-width:300px;', 'default' => 'force', 'desc_tip' => true, 'options' => array('force' => __('Force Downloads', 'woocommerce'), 'xsendfile' => __('X-Accel-Redirect/X-Sendfile', 'woocommerce'), 'redirect' => __('Redirect only', 'woocommerce')), 'autoload' => false), array('title' => __('Access Restriction', 'woocommerce'), 'desc' => __('Downloads require login', 'woocommerce'), 'id' => 'woocommerce_downloads_require_login', 'type' => 'checkbox', 'default' => 'no', 'desc_tip' => __('This setting does not apply to guest purchases.', 'woocommerce'), 'checkboxgroup' => 'start', 'autoload' => false), array('desc' => __('Grant access to downloadable products after payment', 'woocommerce'), 'id' => 'woocommerce_downloads_grant_access_after_payment', 'type' => 'checkbox', 'default' => 'yes', 'desc_tip' => __('Enable this option to grant access to downloads when orders are "processing", rather than "completed".', 'woocommerce'), 'checkboxgroup' => 'end', 'autoload' => false), array('type' => 'sectionend', 'id' => 'digital_download_options'))); } }
function get_page_link($id = false) { global $post, $wp_rewrite; if (!$id) { $id = $post->ID; } $pagestruct = $wp_rewrite->get_page_permastruct(); if ('' != $pagestruct) { $link = get_page_uri($id); $link = str_replace('%pagename%', $link, $pagestruct); $link = get_settings('home') . "/{$link}/"; } else { $link = get_settings('home') . "/?page_id={$id}"; } return apply_filters('page_link', $link, $id); }
/** * Register core post types. */ public static function register_post_types() { if (post_type_exists('product')) { return; } do_action('woocommerce_register_post_type'); $permalinks = get_option('woocommerce_permalinks'); $product_permalink = empty($permalinks['product_base']) ? _x('product', 'slug', 'woocommerce') : $permalinks['product_base']; register_post_type('product', apply_filters('woocommerce_register_post_type_product', array('labels' => array('name' => __('Products', 'woocommerce'), 'singular_name' => __('Product', 'woocommerce'), 'menu_name' => _x('Products', 'Admin menu name', 'woocommerce'), 'add_new' => __('Add Product', 'woocommerce'), 'add_new_item' => __('Add New Product', 'woocommerce'), 'edit' => __('Edit', 'woocommerce'), 'edit_item' => __('Edit Product', 'woocommerce'), 'new_item' => __('New Product', 'woocommerce'), 'view' => __('View Product', 'woocommerce'), 'view_item' => __('View Product', 'woocommerce'), 'search_items' => __('Search Products', 'woocommerce'), 'not_found' => __('No Products found', 'woocommerce'), 'not_found_in_trash' => __('No Products found in trash', 'woocommerce'), 'parent' => __('Parent Product', 'woocommerce'), 'featured_image' => __('Product Image', 'woocommerce'), 'set_featured_image' => __('Set product image', 'woocommerce'), 'remove_featured_image' => __('Remove product image', 'woocommerce'), 'use_featured_image' => __('Use as product image', 'woocommerce')), 'description' => __('This is where you can add new products to your store.', 'woocommerce'), 'public' => true, 'show_ui' => true, 'capability_type' => 'product', 'map_meta_cap' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'hierarchical' => false, 'rewrite' => $product_permalink ? array('slug' => untrailingslashit($product_permalink), 'with_front' => false, 'feeds' => true) : false, 'query_var' => true, 'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments', 'custom-fields', 'page-attributes', 'publicize', 'wpcom-markdown'), 'has_archive' => ($shop_page_id = wc_get_page_id('shop')) && get_post($shop_page_id) ? get_page_uri($shop_page_id) : 'shop', 'show_in_nav_menus' => true))); register_post_type('product_variation', apply_filters('woocommerce_register_post_type_product_variation', array('label' => __('Variations', 'woocommerce'), 'public' => false, 'hierarchical' => false, 'supports' => false, 'capability_type' => 'product'))); wc_register_order_type('shop_order', apply_filters('woocommerce_register_post_type_shop_order', array('labels' => array('name' => __('Orders', 'woocommerce'), 'singular_name' => __('Order', 'woocommerce'), 'add_new' => __('Add Order', 'woocommerce'), 'add_new_item' => __('Add New Order', 'woocommerce'), 'edit' => __('Edit', 'woocommerce'), 'edit_item' => __('Edit Order', 'woocommerce'), 'new_item' => __('New Order', 'woocommerce'), 'view' => __('View Order', 'woocommerce'), 'view_item' => __('View Order', 'woocommerce'), 'search_items' => __('Search Orders', 'woocommerce'), 'not_found' => __('No Orders found', 'woocommerce'), 'not_found_in_trash' => __('No Orders found in trash', 'woocommerce'), 'parent' => __('Parent Orders', 'woocommerce'), 'menu_name' => _x('Orders', 'Admin menu name', 'woocommerce')), 'description' => __('This is where store orders are stored.', 'woocommerce'), 'public' => false, 'show_ui' => true, 'capability_type' => 'shop_order', 'map_meta_cap' => true, 'publicly_queryable' => false, 'exclude_from_search' => true, 'show_in_menu' => current_user_can('manage_woocommerce') ? 'woocommerce' : true, 'hierarchical' => false, 'show_in_nav_menus' => false, 'rewrite' => false, 'query_var' => false, 'supports' => array('title', 'comments', 'custom-fields'), 'has_archive' => false))); wc_register_order_type('shop_order_refund', apply_filters('woocommerce_register_post_type_shop_order_refund', array('label' => __('Refunds', 'woocommerce'), 'capability_type' => 'shop_order', 'public' => false, 'hierarchical' => false, 'supports' => false, 'exclude_from_orders_screen' => false, 'add_order_meta_boxes' => false, 'exclude_from_order_count' => true, 'exclude_from_order_views' => false, 'exclude_from_order_reports' => false, 'exclude_from_order_sales_reports' => true, 'class_name' => 'WC_Order_Refund'))); if ('yes' == get_option('woocommerce_enable_coupons')) { register_post_type('shop_coupon', apply_filters('woocommerce_register_post_type_shop_coupon', array('labels' => array('name' => __('Coupons', 'woocommerce'), 'singular_name' => __('Coupon', 'woocommerce'), 'menu_name' => _x('Coupons', 'Admin menu name', 'woocommerce'), 'add_new' => __('Add Coupon', 'woocommerce'), 'add_new_item' => __('Add New Coupon', 'woocommerce'), 'edit' => __('Edit', 'woocommerce'), 'edit_item' => __('Edit Coupon', 'woocommerce'), 'new_item' => __('New Coupon', 'woocommerce'), 'view' => __('View Coupons', 'woocommerce'), 'view_item' => __('View Coupon', 'woocommerce'), 'search_items' => __('Search Coupons', 'woocommerce'), 'not_found' => __('No Coupons found', 'woocommerce'), 'not_found_in_trash' => __('No Coupons found in trash', 'woocommerce'), 'parent' => __('Parent Coupon', 'woocommerce')), 'description' => __('This is where you can add new coupons that customers can use in your store.', 'woocommerce'), 'public' => false, 'show_ui' => true, 'capability_type' => 'shop_coupon', 'map_meta_cap' => true, 'publicly_queryable' => false, 'exclude_from_search' => true, 'show_in_menu' => current_user_can('manage_woocommerce') ? 'woocommerce' : true, 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'supports' => array('title'), 'show_in_nav_menus' => false, 'show_in_admin_bar' => true))); } register_post_type('shop_webhook', apply_filters('woocommerce_register_post_type_shop_webhook', array('labels' => array('name' => __('Webhooks', 'woocommerce'), 'singular_name' => __('Webhook', 'woocommerce'), 'menu_name' => _x('Webhooks', 'Admin menu name', 'woocommerce'), 'add_new' => __('Add Webhook', 'woocommerce'), 'add_new_item' => __('Add New Webhook', 'woocommerce'), 'edit' => __('Edit', 'woocommerce'), 'edit_item' => __('Edit Webhook', 'woocommerce'), 'new_item' => __('New Webhook', 'woocommerce'), 'view' => __('View Webhooks', 'woocommerce'), 'view_item' => __('View Webhook', 'woocommerce'), 'search_items' => __('Search Webhooks', 'woocommerce'), 'not_found' => __('No Webhooks found', 'woocommerce'), 'not_found_in_trash' => __('No Webhooks found in trash', 'woocommerce'), 'parent' => __('Parent Webhook', 'woocommerce')), 'public' => false, 'show_ui' => false, 'capability_type' => 'shop_webhook', 'map_meta_cap' => true, 'publicly_queryable' => false, 'exclude_from_search' => true, 'show_in_menu' => false, 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'supports' => false, 'show_in_nav_menus' => false, 'show_in_admin_bar' => false))); }