Changeset 1339492
- Timestamp:
- 01/30/2016 07:02:45 AM (10 years ago)
- Location:
- woo-framework-shortcodes/trunk/functions
- Files:
-
- 3 edited
-
admin-shortcodes.php (modified) (1 diff)
-
js/shortcode-generator/dialog.php (modified) (1 diff)
-
js/shortcode-generator/js/dialog-js.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-framework-shortcodes/trunk/functions/admin-shortcodes.php
r1339477 r1339492 2360 2360 } // End woo_shortcode_pinterest_javascript() 2361 2361 2362 2363 2364 /*-----------------------------------------------------------------------------------*/ 2365 /* woo_get_posts_by_taxonomy() 2366 /* 2367 /* Selects posts based on specified taxonomies. 2368 /*-----------------------------------------------------------------------------------*/ 2369 2370 function woo_get_posts_by_taxonomy ( $args = null ) { 2371 global $wp_query; 2372 2373 $posts = array(); 2374 2375 /* Parse arguments, and declare individual variables for each. */ 2376 2377 $defaults = array( 2378 'limit' => 5, 2379 'post_type' => 'any', 2380 'taxonomies' => 'post_tag, category', 2381 'specific_terms' => '', 2382 'relationship' => 'OR', 2383 'order' => 'DESC', 2384 'orderby' => 'date', 2385 'operator' => 'IN', 2386 'exclude' => '' 2387 ); 2388 2389 $args = wp_parse_args( $args, $defaults ); 2390 2391 extract( $args, EXTR_SKIP ); 2392 2393 // Make sure the order value is safe. 2394 if ( ! in_array( $order, array( 'ASC', 'DESC' ) ) ) { $order = $defaults['order']; } 2395 2396 // Make sure the orderby value is safe. 2397 if ( ! in_array( $orderby, array( 'none', 'id', 'author', 'title', 'date', 'modified', 'parent', 'rand', 'comment_count', 'menu_order' ) ) ) { $orderby = $defaults['orderby']; } 2398 2399 // Make sure the operator value is safe. 2400 if ( ! in_array( $operator, array( 'IN', 'NOT IN', 'AND' ) ) ) { $orderby = $defaults['operator']; } 2401 2402 // Convert our post types to an array. 2403 if ( ! is_array( $post_type ) ) { $post_type = explode( ',', $post_type ); } 2404 2405 // Convert our taxonomies to an array. 2406 if ( ! is_array( $taxonomies ) ) { $taxonomies = explode( ',', $taxonomies ); } 2407 2408 // Convert exclude to an array. 2409 if ( ! is_array( $exclude ) && ( $exclude != '' ) ) { $exclude = explode( ',', $exclude ); } 2410 2411 if ( ! count( (array)$taxonomies ) ) { return; } 2412 2413 // Clean up our taxonomies for use in the query. 2414 if ( count( $taxonomies ) ) { 2415 foreach ( $taxonomies as $k => $v ) { 2416 $taxonomies[$k] = trim( $v ); 2417 } 2418 } 2419 2420 // Determine which terms we're going to relate to this entry. 2421 $related_terms = array(); 2422 2423 foreach ( $taxonomies as $t ) { 2424 $terms = get_terms( $t, 'orderby=id&hide_empty=1' ); 2425 2426 if ( ! empty( $terms ) ) { 2427 foreach ( $terms as $k => $v ) { 2428 $related_terms[$t][$v->term_id] = $v->slug; 2429 } 2430 } 2431 } 2432 2433 // If specific terms are available, use those. 2434 if ( ! is_array( $specific_terms ) ) { $specific_terms = explode( ',', $specific_terms ); } 2435 2436 if ( count( $specific_terms ) ) { 2437 foreach ( $specific_terms as $k => $v ) { 2438 $specific_terms[$k] = trim( $v ); 2439 } 2440 } 2441 2442 // Look for posts with the same terms. 2443 2444 // Setup query arguments. 2445 $query_args = array(); 2446 2447 if ( $post_type ) { $query_args['post_type'] = $post_type; } 2448 2449 if ( $limit ) { 2450 $query_args['posts_per_page'] = $limit; 2451 // $query_args['nopaging'] = true; 2452 } 2453 2454 // Setup specific posts to exclude. 2455 if ( count( $exclude ) > 0 ) { 2456 $query_args['post__not_in'] = $exclude; 2457 } 2458 2459 $query_args['order'] = $order; 2460 $query_args['orderby'] = $orderby; 2461 2462 $query_args['tax_query'] = array(); 2463 2464 // Setup for multiple taxonomies. 2465 2466 if ( count( $related_terms ) > 1 ) { 2467 $query_args['tax_query']['relation'] = $args['relationship']; 2468 } 2469 2470 // Add the taxonomies to the query arguments. 2471 2472 foreach ( (array)$related_terms as $k => $v ) { 2473 $terms_for_search = array_values( $v ); 2474 2475 if ( count( $specific_terms ) ) { 2476 $specific_terms_by_tax = array(); 2477 2478 foreach ( $specific_terms as $i => $j ) { 2479 if ( in_array( $j, array_values( $v ) ) ) { 2480 $specific_terms_by_tax[] = $j; 2481 } 2482 } 2483 2484 if ( count( $specific_terms_by_tax ) ) { 2485 $terms_for_search = $specific_terms_by_tax; 2486 } 2487 } 2488 2489 $query_args['tax_query'][] = array( 2490 'taxonomy' => $k, 2491 'field' => 'slug', 2492 'terms' => $terms_for_search, 2493 'operator' => $operator 2494 ); 2495 } 2496 2497 if ( empty( $query_args['tax_query'] ) ) { return; } 2498 2499 $query_saved = $wp_query; 2500 2501 $query = new WP_Query( $query_args ); 2502 2503 if ( $query->have_posts() ) { 2504 while( $query->have_posts() ) { 2505 $query->the_post(); 2506 2507 $posts[] = $query->post; 2508 } 2509 } 2510 2511 $query = $query_saved; 2512 2513 wp_reset_query(); 2514 2515 return $posts; 2516 } // End woo_get_posts_by_taxonomy() 2517 2362 2518 /*-----------------------------------------------------------------------------------*/ 2363 2519 /* THE END */ -
woo-framework-shortcodes/trunk/functions/js/shortcode-generator/dialog.php
r1339477 r1339492 24 24 $woo_framework_path = dirname(__FILE__) . '/../../'; 25 25 26 //$woo_framework_url = plugin_dir_url( __FILE__ ) . 'functions/'; 27 $woo_framework_url = plugins_url() . '/woocommerce-framework-shortcodes/functions/'; 26 $woo_framework_url = esc_url( plugin_dir_url( dirname(__FILE__) . '/../../' ) ) . 'functions/'; 28 27 29 28 $woo_shortcode_css = $woo_framework_path . 'css/shortcodes.css'; -
woo-framework-shortcodes/trunk/functions/js/shortcode-generator/js/dialog-js.php
r1339477 r1339492 16 16 $woo_framework_path = trailingslashit( '../wp-content' . substr( $path_bits[1], 0, -3 ) ); 17 17 18 //$woo_framework_url = plugin_dir_url( __FILE__ ) . 'functions/'; 19 $woo_framework_url = esc_url( 'http://woo-shortcode/wp-content/plugins/woocommerce-framework-shortcodes/functions/' ); 18 $woo_framework_url = esc_url( plugin_dir_url( __FILE__ . '../../../../' ) ); 20 19 21 20 // Check if this is a Windows server or not. … … 23 22 $dirname = wp_normalize_path( dirname( __FILE__ ) ); 24 23 25 //$woo_framework_functions_path = str_replace( 'js' . $delimiter . 'shortcode-generator' . $delimiter . 'js', '', $dirname ); 26 $woo_framework_functions_path = '/usr/home/anand/woo-shortcode/wp-content/plugins/woocommerce-framework-shortcodes/functions/'; 27 28 // Require admin functions. 29 //require_once( $woo_framework_functions_path . $delimiter . 'admin-functions.php' ); 24 $woo_framework_functions_path = dirname(__FILE__) . '/../../../'; 25 30 26 31 27 global $google_fonts; … … 70 66 $fonts = join( '|', $fonts_whitelist ); 71 67 ?> 72 var shortcode_generator_url = '<?php echo esc_url( $woo_framework_url ); ?> ' + 'js/shortcode-generator/';68 var shortcode_generator_url = '<?php echo esc_url( $woo_framework_url ); ?>/'; 73 69 74 70
Note: See TracChangeset
for help on using the changeset viewer.