'Products' , 'singular_name' => 'Product', 'add_new' => 'Voeg product toe', 'add_new_item' => 'Nieuwe product', 'edit_item' => 'Bewerk product', 'new_item' => 'Nieuwe product', 'view_item' => 'Bekijk product', 'search_items' => 'Zoek producten', 'not_found' => 'Geen producten gevonden', 'not_found_in_trash' => 'Geen producten gevonden in de prullenbak', 'parent_item_colon' => 'Product groep:', 'menu_name' => 'FA Catalog', ); $args = array( 'labels' => $labels, 'hierarchical' => true, 'description' => 'Een producten lijst', 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'revisions' ), 'taxonomies' => array( 'product_category' ), 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_icon' => 'dashicons-id-alt', 'show_in_nav_menus' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'has_archive' => false, 'query_var' => true, 'can_export' => true, 'rewrite' => array('slug','products','with_front',true), 'capability_type' => 'post' ); register_post_type( 'product', $args ); //flush_rewrite_rules(); } public function admin_init() { if (class_exists('FAHelpers')) { $this->FAHelpers = new FAHelpers; for ($i=0;$i<3;$i++) : $args = array( "id" => "_image".$i, "title" => "Product image ".($i+1), "post_type" => "product" ); if ($i==0) { $args["required"] = true; $args['required_message'] = __('Please add minimal one image.','fa_helpers'); } $this->FAHelpers->add_image_box($args); endfor; /*$this->FAHelpers->add_singleline_multi_box(array( array( "title" => "Product gegevens", "id" => "_product_address", "label" => "Adresgegevens", "post_type" => "product", "context" => "side", "priority" => "high", "field_type"=> "textarea", ), array( "id" => "_product_telephone", "label" => "Telefoon", "field_type"=> "telephone", ), array( "id" => "_product_website", "label" => "Website url", "field_type"=> "url" ), array( "id" => "_product_email", "label" => "E-mail", "field_type"=> "email" ) ),true);*/ }else { add_action( 'admin_notices', array($this,'client_helper_not_found') ); } } public function save_post($post_id) { if (isset($this->FAHelpers)) $this->FAHelpers->save_post($post_id); } public function client_helper_not_found() { printf( '

%s

', esc_html__( 'Fa helper plugin is required for the plugin '.FACATALOG_PLUGIN_NAME.' to work properly.', 'fa_helpders' ) ); } } 0, 'parent' => '', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => 'faproductcategories', 'pad_counts' => false ); $args = wp_parse_args($args,$defaults); $categories = get_categories( $args ); return $categories; } function get_products($args=array()) { global $wp_query; $categories = get_product_categories(); $posts_per_page = isset($args['posts_per_page'])?intval($args['posts_per_page']):11; $paged = isset($args['paged'])?intval($args['paged']):0; $defaults = array( 'template_part' => 'post-summary-home', 'posts_per_page' => $posts_per_page, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type'=>'product', 'post_status' => ' publish', 'taxonomy' => 'faproductcategories', //'ignore_sticky_posts' => 1, 'offset' => ($posts_per_page*($paged)) ); $args = wp_parse_args($args,$defaults); if (isset($args['category_id'])) { $args['tax_query'] = array( array( 'taxonomy' => 'faproductcategories', 'field' => 'id', 'terms' => intval($args['category_id']) )); } if (isset($args['category_slug'])) { $args['tax_query'] = array( array( 'taxonomy' => 'faproductcategories', 'field' => 'slug', 'terms' => sanitize_text_field($args['category_slug']) )); } $products = query_posts( $args ); // add productcategories for($i=0;$iID,'faproductcategories'); $products[$i]->categories = $terms; endfor; return $products; } function get_product_images($post_id=false) { if (!$post_id) { global $post; $post_id=$post->ID; } $images = array(); for ($i=0;$i<5;$i++) : $thumb = json_decode(get_post_meta($post_id, '_image'.$i, true)); if (!empty($thumb)) { $image = get_post($thumb->id); if ($image->post_type == 'attachment') { $images[] = $image; } } endfor; return !empty($images)?$images:false; }