YITH WooCommerce Ajax Search - Version 1.3.6

Version Description

  • Added: Support to WooCommerce 2.4.2
  • Updated: Plugin Core Framework
Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Ajax Search
Version 1.3.6
Comparing to
See all releases

Code changes from version 1.3.5 to 1.3.6

README.txt CHANGED
@@ -1,10 +1,10 @@
1
  === YITH WooCommerce Ajax Search ===
2
 
3
  Contributors: yithemes
4
- Tags: ajax, search, woocommerce, products, themes, yit, e-commerce, shop, yith, ajax search, instant search, premium, yithemes, autocomplete, autosuggest, better search, category search, custom search, highlight terms, Live Search, Predictive Search, product search, relevant search, search highlight, search product, suggest, typeahead, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress ecommerce
5
  Requires at least: 3.5.1
6
  Tested up to: 4.2
7
- Stable tag: 1.3.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,59 +12,131 @@ YITH WooCommerce Ajax Search allows your users to search products in real time.
12
 
13
  == Description ==
14
 
15
- = Improve the user experience, improve your sales =
16
 
17
- YITH WooCommerce Ajax Search is a really easy-to-use plugin. You just need to install it and it's ready to work.
18
- It creates a simple search box in which, when you start to type your keyword, the plugin will suggest you the products that matching your searching criteria.
19
- It is very useful to provide assistance to your users while they are trying to search any products in your website.
20
 
21
- Did you ever forget the name of a product? Just start to write your keyphrase. A list with useful suggestion will be shown to you, and the more you write, the more accurate it will be. At that point, you'll only need to choose what you need.
22
 
23
- It works just like Google Suggest, but on your website, using your database.
24
 
25
- **Plugin's features:**
26
 
27
- * Widget and shortcodes to show the searchform in every part of the site
28
- * Options for the customization of the searchform
29
- * Options for the visualization of the search results
30
 
31
- For a more detailed list of options and features of the plugin, please look at the [official documentation](http://yithemes.com/docs-plugins/yith-woocommerce-ajax-search/ "YITH Woocommerce Ajax Search official documentation").
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  == Installation ==
35
- Important: First of all, you have to download and activate WooCommerce plugin, which is mandatory for YITH WooCommerce Ajax Search to be working.
36
 
37
- 1. Unzip the downloaded zip file.
38
- 2. Upload the plugin folder into the `wp-content/plugins/` directory of your WordPress site.
39
  3. Activate `YITH WooCommerce Ajax Search` from Plugins page
40
 
 
41
  = Configuration =
42
- YITH WooCommerce Ajax Search will add a new tab called "Ajax Search" in "YIT Plugins" menu item. There, you will find all Yithemes plugins with quick access to plugin setting page.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  == Suggestions ==
45
- If you have any suggestions concerning how to improve YITH WooCommerce Ajax Search, you can [write to us](mailto:plugins@yithemes.com "Your Inspiration Themes"), so that we can improve YITH WooCommerce Ajax Search.
46
 
47
  == Translators ==
48
 
49
  = Available Languages =
50
  * English (Default)
51
- * Italiano
52
 
53
- If you have created your own language pack, or have an update for an existing one, you can send [gettext PO and MO file](http://codex.wordpress.org/Translating_WordPress "Translating WordPress")
54
  [to us](mailto:plugins@yithemes.com "Your Inspiration Themes") so we can bundle it into YITH WooCommerce Ajax Search.
55
 
56
 
57
 
58
  == Screenshots ==
59
 
60
- 1. The Ajax Search settings page
61
- 2. The plugin at work displaying the ajax search results
62
 
63
  == Changelog ==
64
 
 
 
 
65
 
66
  = 1.3.5 =
67
- * Added: Support most search elements on a page
68
 
69
  = 1.3.4 =
70
  * Fixed: Support to WPML
@@ -85,7 +157,7 @@ If you have created your own language pack, or have an update for an existing on
85
 
86
  * Added: Wordpress 4.2 compatibility
87
  * Fixed: Shorcode output
88
- * Fixed: Wp security issue
89
 
90
  = 1.2.7 =
91
 
@@ -94,7 +166,7 @@ If you have created your own language pack, or have an update for an existing on
94
  = 1.2.6 =
95
 
96
  * Updated: Plugin Core Framework
97
- * Fixed: Loader image not hided after search
98
  * Fixed: Disabled submit when search string is empty
99
  * Fixed: Support to WPML in query string
100
 
1
  === YITH WooCommerce Ajax Search ===
2
 
3
  Contributors: yithemes
4
+ Tags: woocommerce search by sku, woocommerce search results, woocommerce search shortcode, woocommerce search page, woocommerce search form, woocommerce search filter, woocommerce search products, woocommerce search content, woocommerce search autocomplete, woocommerce advanced search, woocommerce search category, woocommerce search product attributes, woocommerce search by tag, woocommerce search by brand, woocommerce predictive, woocommerce live search, woocommerce single product search, woocommerce site search, woocommerce search tex, tajax, search, woocommerce, products, themes, yit, e-commerce, shop, yith, ajax search, instant search, premium, yithemes, autocomplete, autosuggest, better search, category search, custom search, highlight terms, Live Search, Predictive Search, product search, relevant search, search highlight, search product, suggest, typeahead, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress ecommerce
5
  Requires at least: 3.5.1
6
  Tested up to: 4.2
7
+ Stable tag: 1.3.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ = Improve user experience, improve your sales =
16
 
17
+ YITH WooCommerce Ajax Search is a very easy-to-use plugin for WooCommerce. You just need to install it and it's ready to work.
 
 
18
 
19
+ It creates a simple search box that shows you instant search results, by suggesting you products from your WooCommerce store that match your searching criteria.
20
 
21
+ It is very useful to assist your users while they are trying to search any product in your website. They can just enter a keyword for the WooCommerce product they are looking for and YITH WooCommerce Ajax Search will spare them the nuisance to browse all WooCommerce categories one at a time.
22
 
23
+ Did you ever forget the name of a WooCommerce product? Just start to write your keyphrase. A list of useful suggestion will be shown to you and the more you write, the more accurate search results will be. At that point, you'll only need to choose what you need.
24
 
25
+ It works just like Google Suggest, but this tool will be available on your WooCommerce site and will be using your database.
 
 
26
 
27
+ = Features of YITH WooCommerce Ajax Search: =
28
 
29
+ * Widget and shortcodes to show your WooCommerce searchform in anywhere you want in your WooCommerce site.
30
+ * Options for customization of your WooCommerce searchform:
31
+ * Customize WooCommerce input label
32
+ * Customise WooCommerce search submit
33
+ * Options for displaying of WooCommerce search results.
34
+ * Set minimum number of characters for WooCommerce search
35
+ * Set maximum number of WooCommerce results
36
+
37
+ If you want to boost your YITH WooCommerce Ajax Search, you can also visit YIThemes page and explore the [live demo](http://plugins.yithemes.com/yith-woocommerce-ajax-search/) of the premium version, which includes all the following features to improve at the best your WooCommerce site search.
38
+
39
+ = Premium features of YITH WooCommerce Ajax Search: =
40
+
41
+ * All features of the free version of YITH WooCommerce Ajax Search
42
+ * Show filter for WooCommerce search fields
43
+ * Show list of WooCommerce categories (main categories/all categories)
44
+ * Extend search in WooCommerce product excerpt
45
+ * Extend search in WooCommerce product content
46
+ * Extend search in WooCommerce product categories
47
+ * Extend search in WooCommerce product tags
48
+ * Extend search also to WooCommerce product SKU
49
+ * Extend SKU search including WooCommerce variable products
50
+ * Show WooCommerce thumbnails in the list of search suggestions
51
+ * Show WooCommerce product price in the list of search suggestions
52
+ * Show WooCommerce sale badge (customization options available too)
53
+ * Show WooCommerce featured badge (customization options available too)
54
+ * Show excerpt of WooCommerce product (set the text to show as WooCommerce product excerpt)
55
+ * Customize WooCommerce search loader .gif image
56
+
57
+
58
+ For a more detailed list of options and features of YITH WooCommerce Ajax Search, please read the [official documentation](http://yithemes.com/docs-plugins/yith-woocommerce-ajax-search/ "YITH Woocommerce Ajax Search official documentation").
59
+
60
+ YITH WooCommerce Ajax Search is available in combination with many other plugins in [**YITH Essential Kit for WooCommerce #1**](https://wordpress.org/plugins/yith-essential-kit-for-woocommerce-1/), a bundle of indispensable tools to make your WooCommerce site look more professional and be more user-friendly. Learn more about all of WooCommerce plugins included and boost your WooCommerce site with a simple click!
61
+
62
+
63
+ = Compatibility with WooCommerce plugins =
64
+
65
+ YITH WooCommerce Ajax Search has been tested and compatibility is certain with the following WooCommerce plugins that you can add to your site:
66
+
67
+ * [**YITH Woocommerce Quick view**](https://wordpress.org/plugins/yith-woocommerce-quick-view/)
68
+ * [**YITH Woocommerce magnifier**](https://wordpress.org/plugins/yith-woocommerce-zoom-magnifier/)
69
+ * [**YITH Woocommerce Ajax Product Filter**](http://it.wordpress.org/plugins/yith-woocommerce-ajax-navigation/)
70
+ * [**YITH Woocommerce Infinite scrolling**](http://it.wordpress.org/plugins/yith-infinite-scrolling/)
71
+
72
+ Nevertheless, it could be compatible with many other WooCommerce plugins that have not been tested yet. If you want to inform us about compatibility with other plugins, please, [email to us](mailto:plugins@yithemes.com "Your Inspiration Themes").
73
 
74
  == Installation ==
75
+ Important: First of all, you have to download and activate WooCommerce plugin, because without it YITH WooCommerce Ajax Search cannot work.
76
 
77
+ 1. Unzip the downloaded .zip file.
78
+ 2. Upload the YITH WooCommerce Ajax Search folder into the `wp-content/plugins/` directory of your WordPress site.
79
  3. Activate `YITH WooCommerce Ajax Search` from Plugins page
80
 
81
+
82
  = Configuration =
83
+ YITH WooCommerce Ajax Search will add a new tab called "Ajax Search" in "YIT Plugins" menu. There, you will find all YIThemes plugins and you will be able to access quickly plugin settings page.
84
+
85
+ == Frequently Asked Questions ==
86
+
87
+ = Is it compatible with all WordPress themes? =
88
+
89
+ Compatibility with all themes is impossible, because they are too many, but generally if themes are developed according to WordPress and WooCommerce guidelines, YITH plugins are compatible with them.
90
+ Yet, we can grant compatibility with themes developed by YIThemes, because they are constantly updated and tested with our plugins. Sometimes, especially when new versions are released, it might only require some time for them to be all updated, but you can be sure that they will be tested and will be working in a few days.
91
+
92
+
93
+ = How can I get support if my WooCommerce plugin is not working? =
94
+
95
+ If you have problems with our plugins or something is not working as it should, first follow this preliminary steps:
96
+
97
+ * Test the plugin with a WordPress default theme, to be sure that the error is not caused by the theme you are currently using.
98
+ * Deactivate all plugins you are using and check if the problem is still occurring.
99
+ * Ensure that you plugin version, your theme version and your WordPress and WooCommerce version (if required) are updated and that the problem you are experiencing has not already been solved in a later plugin update.
100
+
101
+ If none of the previous listed actions helps you solve the problem, then, submit a ticket in the forum and describe your problem accurately, specify WordPress and WooCommerce versions you are using and any other information that might help us solve your problem as quickly as possible. Thanks!
102
+
103
+
104
+ = How can I get more features for my WooCommerce plugin? =
105
+ You can get more features with the premium version of YITH WooCommerce Ajax Search, available on [YIThemes page]( https://yithemes.com/themes/plugins/yith-woocommerce-ajax-search/). Here you can read more about the premium features of the plugin and make it give it its best shot!
106
+
107
+
108
+ = How can I try the full-featured plugin? =
109
+
110
+ If you want to see a demonstration version of the premium plugin, you can see that in [this page](http://plugins.yithemes.com/yith-woocommerce-ajax-search/). Browse it and try all options available so that you can see how your plugin looks like.
111
+
112
 
113
  == Suggestions ==
114
+ If you have any suggestions for improving YITH WooCommerce Ajax Search, you can [write to us](mailto:plugins@yithemes.com "Your Inspiration Themes"), and contribute in making your YITH WooCommerce Ajax Search more and more performing.
115
 
116
  == Translators ==
117
 
118
  = Available Languages =
119
  * English (Default)
120
+ * Italian
121
 
122
+ If you have created your own language pack for YITH WooCommerce Ajax Search, or have an update for an existing one, you can send [gettext PO and MO file](http://codex.wordpress.org/Translating_WordPress "Translating WordPress")
123
  [to us](mailto:plugins@yithemes.com "Your Inspiration Themes") so we can bundle it into YITH WooCommerce Ajax Search.
124
 
125
 
126
 
127
  == Screenshots ==
128
 
129
+ 1. YITH WooCommerce Ajax Search settings page
130
+ 2. YITH WooCommerce Ajax Search in operation displaying WooCommerce search results
131
 
132
  == Changelog ==
133
 
134
+ = 1.3.6 =
135
+ * Added: Support to WooCommerce 2.4.2
136
+ * Updated: Plugin Core Framework
137
 
138
  = 1.3.5 =
139
+ * Added: Support more search elements on a page
140
 
141
  = 1.3.4 =
142
  * Fixed: Support to WPML
157
 
158
  * Added: Wordpress 4.2 compatibility
159
  * Fixed: Shorcode output
160
+ * Fixed: WP security issue
161
 
162
  = 1.2.7 =
163
 
166
  = 1.2.6 =
167
 
168
  * Updated: Plugin Core Framework
169
+ * Fixed: Loader image not hidden after search
170
  * Fixed: Disabled submit when search string is empty
171
  * Fixed: Support to WPML in query string
172
 
init.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: YITH WooCommerce Ajax Search
4
  * Plugin URI: http://yithemes.com/
5
  * Description: YITH WooCommerce Ajax Search allows your users to search products in real time.
6
- * Version: 1.3.5
7
  * Author: Yithemes
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yit
@@ -59,7 +59,7 @@ register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
59
  if ( defined( 'YITH_WCAS_VERSION' ) ){
60
  return;
61
  }else{
62
- define( 'YITH_WCAS_VERSION', '1.3.5' );
63
  }
64
 
65
  if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
3
  * Plugin Name: YITH WooCommerce Ajax Search
4
  * Plugin URI: http://yithemes.com/
5
  * Description: YITH WooCommerce Ajax Search allows your users to search products in real time.
6
+ * Version: 1.3.6
7
  * Author: Yithemes
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yit
59
  if ( defined( 'YITH_WCAS_VERSION' ) ){
60
  return;
61
  }else{
62
+ define( 'YITH_WCAS_VERSION', '1.3.6' );
63
  }
64
 
65
  if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
plugin-fw/assets/css/yit-plugin-panel.css CHANGED
@@ -626,6 +626,11 @@
626
  color: #45bbe6;
627
  }
628
 
 
 
 
 
 
629
  /* === Responsive === */
630
 
631
  @media (max-width: 767px) {}
626
  color: #45bbe6;
627
  }
628
 
629
+ /* WooCommerce 2.4 Support */
630
+ .woocommerce table.form-table .colorpick{
631
+ width: 6em;
632
+ }
633
+
634
  /* === Responsive === */
635
 
636
  @media (max-width: 767px) {}
plugin-fw/lib/yit-plugin-panel-wc.php CHANGED
@@ -37,6 +37,11 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
37
  */
38
  public $settings = array();
39
 
 
 
 
 
 
40
  /**
41
  * @var array
42
  */
@@ -51,6 +56,14 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
51
  */
52
  public function __construct( $args = array() ) {
53
 
 
 
 
 
 
 
 
 
54
  if ( ! empty( $args ) ) {
55
  $this->settings = $args;
56
  $this->_tabs_path_files = $this->get_tabs_path_files();
@@ -64,10 +77,14 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
64
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
65
  add_action( 'admin_init', array( $this, 'woocommerce_update_options' ) );
66
  add_filter( 'woocommerce_screen_ids', array( $this, 'add_allowed_screen_id' ) );
 
67
 
68
  /* Add VideoBox and InfoBox */
69
  add_action( 'woocommerce_admin_field_boxinfo', array( $this, 'add_infobox' ), 10, 1 );
70
  add_action( 'woocommerce_admin_field_videobox', array( $this, 'add_videobox' ), 10, 1 );
 
 
 
71
  }
72
  }
73
 
@@ -251,6 +268,16 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
251
  $yit_options = $this->get_main_array_options();
252
  $current_tab = $this->get_current_tab();
253
 
 
 
 
 
 
 
 
 
 
 
254
  woocommerce_update_options( $yit_options[ $current_tab ] );
255
 
256
  do_action( 'yit_panel_wc_after_update' );
@@ -320,7 +347,6 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
320
  } else {
321
  add_option($value['id'], $default_value);
322
  }
323
-
324
  }
325
 
326
  }
@@ -328,6 +354,51 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
328
 
329
  }
330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
 
332
  }
333
  }
37
  */
38
  public $settings = array();
39
 
40
+ /**
41
+ * @var array a setting list of parameters
42
+ */
43
+ public $wc_type = array();
44
+
45
  /**
46
  * @var array
47
  */
56
  */
57
  public function __construct( $args = array() ) {
58
 
59
+ $this->wc_type = array(
60
+ 'checkbox',
61
+ 'textarea',
62
+ 'multiselect',
63
+ 'multi_select_countries',
64
+ 'image_width'
65
+ );
66
+
67
  if ( ! empty( $args ) ) {
68
  $this->settings = $args;
69
  $this->_tabs_path_files = $this->get_tabs_path_files();
77
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
78
  add_action( 'admin_init', array( $this, 'woocommerce_update_options' ) );
79
  add_filter( 'woocommerce_screen_ids', array( $this, 'add_allowed_screen_id' ) );
80
+ add_filter( 'woocommerce_admin_settings_sanitize_option', array( $this, 'maybe_unserialize_panel_data' ), 10, 3 );
81
 
82
  /* Add VideoBox and InfoBox */
83
  add_action( 'woocommerce_admin_field_boxinfo', array( $this, 'add_infobox' ), 10, 1 );
84
  add_action( 'woocommerce_admin_field_videobox', array( $this, 'add_videobox' ), 10, 1 );
85
+
86
+ /* WooCommerce 2.4 Support */
87
+ add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
88
  }
89
  }
90
 
268
  $yit_options = $this->get_main_array_options();
269
  $current_tab = $this->get_current_tab();
270
 
271
+ if( version_compare( WC()->version, '2.4.0', '>=' ) ) {
272
+ if ( ! empty( $yit_options[ $current_tab ] ) ) {
273
+ foreach ( $yit_options[ $current_tab ] as $option ) {
274
+ if ( isset( $option['id'] ) && isset( $_POST[ $option['id'] ] ) && isset( $option['type' ] ) && ! in_array( $option['type'], $this->wc_type ) ) {
275
+ $_POST[ $option['id'] ] = maybe_serialize( $_POST[ $option['id'] ] );
276
+ }
277
+ }
278
+ }
279
+ }
280
+
281
  woocommerce_update_options( $yit_options[ $current_tab ] );
282
 
283
  do_action( 'yit_panel_wc_after_update' );
347
  } else {
348
  add_option($value['id'], $default_value);
349
  }
 
350
  }
351
 
352
  }
354
 
355
  }
356
 
357
+ /**
358
+ * Add the woocommerce body class in plugin panel page
359
+ *
360
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
361
+ * @since 2.0
362
+ * @param $classes The body classes
363
+ *
364
+ * @return array Filtered body classes
365
+ */
366
+ public function admin_body_class( $admin_body_classes ){
367
+ $admin_body_classes .= ' woocommerce ';
368
+ return $admin_body_classes;
369
+ }
370
+
371
+ /**
372
+ * Maybe unserialize panel data
373
+ *
374
+ * @param $value mixed Option value
375
+ * @param $option mixed Option settings array
376
+ * @param $raw_value string Raw option value
377
+ *
378
+ * @return mixed Filtered return value
379
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
380
+ * @since 2.0
381
+ */
382
+ public function maybe_unserialize_panel_data( $value, $option, $raw_value ) {
383
+
384
+
385
+ if( ! version_compare( WC()->version, '2.4.0', '>=' ) || ! isset( $option['type' ] ) || in_array( $option['type'], $this->wc_type ) ) {
386
+ return $value;
387
+ }
388
+
389
+ $yit_options = $this->get_main_array_options();
390
+ $current_tab = $this->get_current_tab();
391
+
392
+ if( ! empty( $yit_options[ $current_tab ] ) ){
393
+ foreach( $yit_options[ $current_tab ] as $option_array ){
394
+ if( isset( $option_array['id'] ) && isset( $option['id'] ) && $option_array['id'] == $option['id'] ){
395
+ return maybe_unserialize( $value );
396
+ }
397
+ }
398
+ }
399
+
400
+ return $value;
401
+ }
402
 
403
  }
404
  }
plugin-fw/yit-functions.php CHANGED
@@ -818,4 +818,66 @@ if ( ! function_exists( 'yit_load_js_file' ) ) {
818
 
819
  return $filename;
820
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
821
  }
818
 
819
  return $filename;
820
  }
821
+ }
822
+
823
+ if ( ! function_exists( 'yit_wpml_register_string' ) ) {
824
+ /**
825
+ * Register a string in wpml trnslation
826
+ *
827
+ * @param $contenxt context name
828
+ * @param $name string name
829
+ * @param $value value to translate
830
+ *
831
+ * @since 2.0.0
832
+ * @author Andrea Frascaspata <andrea.frascaspata@yithemes.com>
833
+ */
834
+ function yit_wpml_register_string( $contenxt , $name , $value ) {
835
+ // wpml string translation
836
+ do_action( 'wpml_register_single_string', $contenxt, $name, $value );
837
+ }
838
+ }
839
+
840
+ if ( ! function_exists( 'yit_wpml_string_translate' ) ) {
841
+ /**
842
+ * Get a string translation
843
+ *
844
+ * @param $contenxt context name
845
+ * @param $name string name
846
+ * @param $default_value value to translate
847
+ *
848
+ * @return string the string translated
849
+ * @since 2.0.0
850
+ * @author Andrea Frascaspata <andrea.frascaspata@yithemes.com>
851
+ */
852
+ function yit_wpml_string_translate( $contenxt, $name, $default_value ) {
853
+ return apply_filters( 'wpml_translate_single_string', $default_value, $contenxt, $name );
854
+ }
855
+
856
+ }
857
+
858
+ if ( ! function_exists( 'yit_wpml_object_id' ) ) {
859
+ /**
860
+ * Get id of post translation in current language
861
+ *
862
+ * @param int $element_id
863
+ * @param string $element_type
864
+ * @param bool $return_original_if_missing
865
+ * @param null|string $ulanguage_code
866
+ *
867
+ * @return int the translation id
868
+ * @since 2.0.0
869
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
870
+ */
871
+ function yit_wpml_object_id( $element_id, $element_type = 'post', $return_original_if_missing = false, $ulanguage_code = null ) {
872
+ if( function_exists( 'wpml_object_id' ) ){
873
+ return wpml_object_id( $element_id, $element_type, $return_original_if_missing, $ulanguage_code );
874
+ }
875
+ elseif( function_exists( 'icl_object_id' ) ){
876
+ return icl_object_id( $element_id, $element_type, $return_original_if_missing, $ulanguage_code );
877
+ }
878
+ else{
879
+ return $element_id;
880
+ }
881
+ }
882
+
883
  }