| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The public-facing functionality of the plugin. |
| 5 |
* |
| 6 |
* @link http://wpgeodirectory.com |
| 7 |
* @since 1.0.0 |
| 8 |
* |
| 9 |
* @package userswp |
| 10 |
* @subpackage userswp/public |
| 11 |
*/ |
| 12 |
|
| 13 |
/** |
| 14 |
* The public-facing functionality of the plugin. |
| 15 |
* |
| 16 |
* Defines the plugin name, version, and two examples hooks for how to |
| 17 |
* enqueue the admin-specific stylesheet and JavaScript. |
| 18 |
* |
| 19 |
* @package userswp |
| 20 |
* @subpackage userswp/public |
| 21 |
* @author GeoDirectory Team <info@wpgeodirectory.com> |
| 22 |
*/ |
| 23 |
class UsersWP_Public { |
| 24 |
|
| 25 |
|
| 26 |
/** |
| 27 |
* Register the stylesheets for the public-facing side of the site. |
| 28 |
* |
| 29 |
* @since 1.0.0 |
| 30 |
*/ |
| 31 |
public function enqueue_styles() { |
| 32 |
|
| 33 |
if (is_uwp_page()) { |
| 34 |
// include only in uwp pages |
| 35 |
wp_register_style('jquery-ui', plugin_dir_url(dirname(__FILE__)) . 'public/assets/css/jquery-ui.css'); |
| 36 |
wp_enqueue_style( 'jquery-ui' ); |
| 37 |
} |
| 38 |
|
| 39 |
if (is_uwp_current_user_profile_page()) { |
| 40 |
// include only profile pages |
| 41 |
wp_enqueue_style( 'jcrop' ); |
| 42 |
|
| 43 |
if (is_user_logged_in()) { |
| 44 |
wp_enqueue_media(); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
$enable_timepicker_in_register = false; |
| 49 |
$enable_timepicker_in_account = false; |
| 50 |
|
| 51 |
$enable_chosen_in_register = false; |
| 52 |
$enable_chosen_in_account = false; |
| 53 |
|
| 54 |
if (is_uwp_register_page() || is_uwp_account_page()) { |
| 55 |
if (is_uwp_register_page()) { |
| 56 |
$fields = get_register_form_fields(); |
| 57 |
} else { |
| 58 |
// account page |
| 59 |
$fields = get_account_form_fields(); |
| 60 |
} |
| 61 |
if (!empty($fields)) { |
| 62 |
foreach ($fields as $field) { |
| 63 |
if ($field->field_type == 'time') { |
| 64 |
$enable_timepicker_in_register = true; |
| 65 |
} |
| 66 |
|
| 67 |
if ($field->field_type == 'multiselect') { |
| 68 |
$enable_chosen_in_register = true; |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
if ($enable_timepicker_in_register || $enable_timepicker_in_account) { |
| 76 |
// time fields available only in register and account pages |
| 77 |
wp_enqueue_style( "uwp_timepicker_css", plugin_dir_url( __FILE__ ) . 'assets/css/jquery.ui.timepicker.css', array(), null, 'all' ); |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
if ($enable_chosen_in_register || $enable_chosen_in_account) { |
| 82 |
// chosen fields (multiselect) available only in register and account pages |
| 83 |
wp_enqueue_style( "uwp_chosen_css", plugin_dir_url( __FILE__ ) . 'assets/css/chosen.css', array(), null, 'all' ); |
| 84 |
} |
| 85 |
|
| 86 |
wp_enqueue_style( USERSWP_NAME, plugin_dir_url( __FILE__ ) . 'assets/css/users-wp.css', array(), null, 'all' ); |
| 87 |
//widget styles for all pages |
| 88 |
wp_enqueue_style( "uwp_widget_css", plugin_dir_url( __FILE__ ) . 'assets/css/widgets.css', array(), null, 'all' ); |
| 89 |
|
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* Register the JavaScript for the public-facing side of the site. |
| 94 |
* |
| 95 |
* @since 1.0.0 |
| 96 |
*/ |
| 97 |
public function enqueue_scripts() { |
| 98 |
|
| 99 |
if (is_uwp_page()) { |
| 100 |
// include only in uwp pages |
| 101 |
wp_enqueue_script( 'jquery-ui-core', array( 'jquery' ) ); |
| 102 |
} |
| 103 |
|
| 104 |
if (is_uwp_current_user_profile_page()) { |
| 105 |
// include only profile pages |
| 106 |
wp_enqueue_script( 'jcrop', array( 'jquery' ) ); |
| 107 |
} |
| 108 |
|
| 109 |
$enable_timepicker_in_register = false; |
| 110 |
$enable_timepicker_in_account = false; |
| 111 |
|
| 112 |
$enable_datepicker_in_register = false; |
| 113 |
$enable_datepicker_in_account = false; |
| 114 |
|
| 115 |
$enable_chosen_in_register = false; |
| 116 |
$enable_chosen_in_account = false; |
| 117 |
|
| 118 |
if (is_uwp_register_page() || is_uwp_account_page()) { |
| 119 |
if (is_uwp_register_page()) { |
| 120 |
$fields = get_register_form_fields(); |
| 121 |
} else { |
| 122 |
// account page |
| 123 |
$fields = get_account_form_fields(); |
| 124 |
} |
| 125 |
|
| 126 |
if (!empty($fields)) { |
| 127 |
foreach ($fields as $field) { |
| 128 |
if ($field->field_type == 'time') { |
| 129 |
$enable_timepicker_in_register = true; |
| 130 |
} |
| 131 |
|
| 132 |
if ($field->field_type == 'datepicker') { |
| 133 |
$enable_datepicker_in_register = true; |
| 134 |
} |
| 135 |
|
| 136 |
if ($field->field_type == 'multiselect') { |
| 137 |
$enable_chosen_in_register = true; |
| 138 |
} |
| 139 |
} |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
if ($enable_timepicker_in_register || $enable_timepicker_in_account) { |
| 144 |
// time fields available only in register and account pages |
| 145 |
wp_enqueue_script( "uwp_timepicker", plugin_dir_url( __FILE__ ) . 'assets/js/jquery.ui.timepicker.min.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-core' ), null, false ); |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
if ($enable_datepicker_in_register || $enable_datepicker_in_account) { |
| 150 |
// date fields available only in register and account pages |
| 151 |
wp_enqueue_script( 'jquery-ui-datepicker', array( 'jquery' ) ); |
| 152 |
} |
| 153 |
|
| 154 |
if (is_uwp_profile_page() ) { |
| 155 |
wp_enqueue_script( 'jquery-ui-progressbar', array( 'jquery' ) ); |
| 156 |
} |
| 157 |
|
| 158 |
if ($enable_chosen_in_register || $enable_chosen_in_account) { |
| 159 |
// chosen fields (multiselect) available only in register and account pages |
| 160 |
wp_dequeue_script('chosen'); |
| 161 |
wp_enqueue_script( "uwp_chosen", plugin_dir_url( __FILE__ ) . 'assets/js/chosen.jquery.js', array( 'jquery' ), null, false ); |
| 162 |
} |
| 163 |
|
| 164 |
// include only in uwp pages |
| 165 |
wp_enqueue_script( USERSWP_NAME, plugin_dir_url( __FILE__ ) . 'assets/js/users-wp.min.js', array( 'jquery' ), null, false ); |
| 166 |
|
| 167 |
//load CountrySelect |
| 168 |
wp_enqueue_script( "country-select", plugin_dir_url(dirname(__FILE__)) . 'public/assets/js/countrySelect.min.js', array( 'jquery' ), null, false ); |
| 169 |
|
| 170 |
$country_data = uwp_get_country_data(); |
| 171 |
wp_localize_script(USERSWP_NAME, 'uwp_country_data', $country_data); |
| 172 |
|
| 173 |
$uwp_localize_data = uwp_get_localize_data(); |
| 174 |
wp_localize_script(USERSWP_NAME, 'uwp_localize_data', $uwp_localize_data); |
| 175 |
|
| 176 |
} |
| 177 |
|
| 178 |
} |