makarandmane

Fix-sort-category-by-custom-order.-Added-new-dropdow

Jun 1st, 2020
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.23 KB | None | 0 0
  1. From 680925dc9c3147f052a574ad630b40d2f62fc56d Mon Sep 17 00:00:00 2001
  2. From: Makarand Mane <mane.makarand@gmail.com>
  3. Date: Sun, 31 May 2020 01:23:06 +0530
  4. Subject: [PATCH] Fix sort category by custom order. Added new dropdown for
  5.  orderby with correct options. Corrected code in callback function
  6.  
  7. ---
  8.  includes/elementor/widgets/vibe-courseCarousel.php | 12 +++++++++++-
  9.  metaboxes/library/vibe-editor.php                  |  5 ++++-
  10.  2 files changed, 15 insertions(+), 2 deletions(-)
  11.  
  12. diff --git a/includes/elementor/widgets/vibe-courseCarousel.php b/includes/elementor/widgets/vibe-courseCarousel.php
  13. index 23a0dd3..3c7ec48 100644
  14. --- a/includes/elementor/widgets/vibe-courseCarousel.php
  15. +++ b/includes/elementor/widgets/vibe-courseCarousel.php
  16. @@ -85,7 +85,17 @@ if ( ! defined( 'ABSPATH' ) ) {
  17.             [
  18.                 'label' => __('OrderBy', 'vibe-customtypes'),
  19.                 'type' => \Elementor\Controls_Manager::SELECT,
  20. -               'default' => 'rated',
  21. +               'default' => 'name',
  22. +               'options' => array('name'=>__('Alphabetical', 'vibe-customtypes'),'description'=>__('Description', 'vibe-customtypes'),'meta_value_num'=>__('Custom Order','vibe-customtypes')),
  23. +           ]
  24. +       );
  25. +
  26. +       $this->add_control(
  27. +           'order',
  28. +           [
  29. +               'label' => __('Order', 'vibe-customtypes'),
  30. +               'type' => \Elementor\Controls_Manager::SELECT,
  31. +               'default' => 'ASC',
  32.                 'options' => array(
  33.                     'DESC' => 'Decending',
  34.                     'ASC' => 'Ascending'
  35. diff --git a/metaboxes/library/vibe-editor.php b/metaboxes/library/vibe-editor.php
  36. index 1d9af86..c0df8fa 100644
  37. --- a/metaboxes/library/vibe-editor.php
  38. +++ b/metaboxes/library/vibe-editor.php
  39. @@ -500,7 +500,10 @@ function custom_post_carousel($atts, $content = null) {
  40.  
  41.              }
  42.              if(!empty($atts['orderby'])){
  43. -              $args['orderby']='name';$args['order']=$atts['orderby'];
  44. +              $args['order']= $atts['order'];
  45. +             $args['orderby']=$atts['orderby'];
  46. +             if( $atts['orderby'] == 'meta_value_num')
  47. +                 $args['meta_key']= 'course_cat_order';
  48.              }
  49.              if(empty($args['include'])){unset($args['include']);}
  50.              if(empty($args['orderby'])){unset($args['orderby']);unset($args['order']);unset($args['meta_key']);}
  51. --
  52. 2.19.1.windows.1
Add Comment
Please, Sign In to add comment