@@ -33,265 +33,265 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function geodir_add_nav_menu_items() |
| 35 | 35 | {
|
| 36 | - $items = ''; |
|
| 37 | - // apply filter to add more navigations // -Filter-Location-Manager |
|
| 38 | - |
|
| 39 | - if (get_option('geodir_show_listing_nav')) {
|
|
| 40 | - |
|
| 41 | - $menu_class = ''; |
|
| 42 | - if (geodir_is_page('listing'))
|
|
| 43 | - $menu_class = 'current-menu-item'; |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION |
|
| 47 | - $post_types = geodir_get_posttypes('object');
|
|
| 48 | - $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
|
|
| 49 | - if (!empty($post_types)) {
|
|
| 50 | - foreach ($post_types as $post_type => $args) {
|
|
| 51 | - if (!empty($show_post_type_main_nav)) {
|
|
| 52 | - if (in_array($post_type, $show_post_type_main_nav)) {
|
|
| 53 | - if (get_post_type_archive_link($post_type)) {
|
|
| 54 | - $menu_class = ''; |
|
| 55 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 56 | - $menu_class = 'current-menu-item'; |
|
| 57 | - /** |
|
| 58 | - * Filter the menu li class. |
|
| 59 | - * |
|
| 60 | - * @since 1.0.0 |
|
| 61 | - * @param string $menu_class The menu HTML class. |
|
| 62 | - */ |
|
| 63 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 64 | - /** |
|
| 65 | - * Filter the menu a class. |
|
| 66 | - * |
|
| 67 | - * @since 1.0.0 |
|
| 68 | - */ |
|
| 69 | - $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 70 | - $items .= '<li class="' . $li_class . '"> |
|
| 36 | + $items = ''; |
|
| 37 | + // apply filter to add more navigations // -Filter-Location-Manager |
|
| 38 | + |
|
| 39 | + if (get_option('geodir_show_listing_nav')) {
|
|
| 40 | + |
|
| 41 | + $menu_class = ''; |
|
| 42 | + if (geodir_is_page('listing'))
|
|
| 43 | + $menu_class = 'current-menu-item'; |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION |
|
| 47 | + $post_types = geodir_get_posttypes('object');
|
|
| 48 | + $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
|
|
| 49 | + if (!empty($post_types)) {
|
|
| 50 | + foreach ($post_types as $post_type => $args) {
|
|
| 51 | + if (!empty($show_post_type_main_nav)) {
|
|
| 52 | + if (in_array($post_type, $show_post_type_main_nav)) {
|
|
| 53 | + if (get_post_type_archive_link($post_type)) {
|
|
| 54 | + $menu_class = ''; |
|
| 55 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 56 | + $menu_class = 'current-menu-item'; |
|
| 57 | + /** |
|
| 58 | + * Filter the menu li class. |
|
| 59 | + * |
|
| 60 | + * @since 1.0.0 |
|
| 61 | + * @param string $menu_class The menu HTML class. |
|
| 62 | + */ |
|
| 63 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 64 | + /** |
|
| 65 | + * Filter the menu a class. |
|
| 66 | + * |
|
| 67 | + * @since 1.0.0 |
|
| 68 | + */ |
|
| 69 | + $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 70 | + $items .= '<li class="' . $li_class . '"> |
|
| 71 | 71 | <a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '"> |
| 72 | 72 | ' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . ' |
| 73 | 73 | </a> |
| 74 | 74 | </li>'; |
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - //END LISTING OF POST TYPE IN MAIN NAVIGATION |
|
| 81 | - |
|
| 82 | - $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
|
|
| 83 | - $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false; |
|
| 84 | - if ($is_listing_sub_meny_exists) {
|
|
| 85 | - /** |
|
| 86 | - * Filter the menu li class. |
|
| 87 | - * |
|
| 88 | - * @since 1.0.0 |
|
| 89 | - * @param string $menu_class The menu HTML class. |
|
| 90 | - */ |
|
| 91 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
|
|
| 92 | - /** |
|
| 93 | - * Filter the sub menu li class. |
|
| 94 | - * |
|
| 95 | - * @since 1.0.0 |
|
| 96 | - * @param string $menu_class The menu HTML class. |
|
| 97 | - */ |
|
| 98 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 99 | - /** |
|
| 100 | - * Filter the sub menu ul class. |
|
| 101 | - * |
|
| 102 | - * @since 1.0.0 |
|
| 103 | - */ |
|
| 104 | - $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
|
|
| 105 | - /** |
|
| 106 | - * Filter the menu a class. |
|
| 107 | - * |
|
| 108 | - * @since 1.0.0 |
|
| 109 | - */ |
|
| 110 | - $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 111 | - /** |
|
| 112 | - * Filter the sub menu a class. |
|
| 113 | - * |
|
| 114 | - * @since 1.0.0 |
|
| 115 | - */ |
|
| 116 | - $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
|
| 117 | - $items .= '<li class="' . $li_class . '"> |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + //END LISTING OF POST TYPE IN MAIN NAVIGATION |
|
| 81 | + |
|
| 82 | + $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
|
|
| 83 | + $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false; |
|
| 84 | + if ($is_listing_sub_meny_exists) {
|
|
| 85 | + /** |
|
| 86 | + * Filter the menu li class. |
|
| 87 | + * |
|
| 88 | + * @since 1.0.0 |
|
| 89 | + * @param string $menu_class The menu HTML class. |
|
| 90 | + */ |
|
| 91 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
|
|
| 92 | + /** |
|
| 93 | + * Filter the sub menu li class. |
|
| 94 | + * |
|
| 95 | + * @since 1.0.0 |
|
| 96 | + * @param string $menu_class The menu HTML class. |
|
| 97 | + */ |
|
| 98 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 99 | + /** |
|
| 100 | + * Filter the sub menu ul class. |
|
| 101 | + * |
|
| 102 | + * @since 1.0.0 |
|
| 103 | + */ |
|
| 104 | + $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
|
|
| 105 | + /** |
|
| 106 | + * Filter the menu a class. |
|
| 107 | + * |
|
| 108 | + * @since 1.0.0 |
|
| 109 | + */ |
|
| 110 | + $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 111 | + /** |
|
| 112 | + * Filter the sub menu a class. |
|
| 113 | + * |
|
| 114 | + * @since 1.0.0 |
|
| 115 | + */ |
|
| 116 | + $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
|
| 117 | + $items .= '<li class="' . $li_class . '"> |
|
| 118 | 118 | <a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
|
| 119 | 119 | <ul class="' . $sub_ul_class . '">'; |
| 120 | - $post_types = geodir_get_posttypes('object');
|
|
| 120 | + $post_types = geodir_get_posttypes('object');
|
|
| 121 | 121 | |
| 122 | - $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
|
|
| 122 | + $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
|
|
| 123 | 123 | |
| 124 | - if (!empty($post_types)) {
|
|
| 125 | - global $geodir_add_location_url; |
|
| 126 | - $geodir_add_location_url = true; |
|
| 127 | - foreach ($post_types as $post_type => $args) {
|
|
| 128 | - if (!empty($show_listing_post_types)) {
|
|
| 129 | - if (in_array($post_type, $show_listing_post_types)) {
|
|
| 130 | - if (get_post_type_archive_link($post_type)) {
|
|
| 124 | + if (!empty($post_types)) {
|
|
| 125 | + global $geodir_add_location_url; |
|
| 126 | + $geodir_add_location_url = true; |
|
| 127 | + foreach ($post_types as $post_type => $args) {
|
|
| 128 | + if (!empty($show_listing_post_types)) {
|
|
| 129 | + if (in_array($post_type, $show_listing_post_types)) {
|
|
| 130 | + if (get_post_type_archive_link($post_type)) {
|
|
| 131 | 131 | |
| 132 | - $menu_class = ''; |
|
| 133 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 134 | - $menu_class = 'current-menu-item'; |
|
| 132 | + $menu_class = ''; |
|
| 133 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 134 | + $menu_class = 'current-menu-item'; |
|
| 135 | 135 | |
| 136 | - $items .= '<li class="' . $sub_li_class . '"> |
|
| 136 | + $items .= '<li class="' . $sub_li_class . '"> |
|
| 137 | 137 | <a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '"> |
| 138 | 138 | ' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . ' |
| 139 | 139 | </a> |
| 140 | 140 | </li>'; |
| 141 | - } |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - $geodir_add_location_url = NULL; |
|
| 146 | - } |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + $geodir_add_location_url = NULL; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - $items .= ' </ul> '; |
|
| 149 | - /** |
|
| 150 | - * Filter called after the sub menu closing ul tag for dynamic added menu items. |
|
| 151 | - * |
|
| 152 | - * @since 1.5.9 |
|
| 153 | - */ |
|
| 154 | - $items .= apply_filters('geodir_menu_after_sub_ul','');
|
|
| 155 | - $items .= '</li>'; |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - if (get_option('geodir_show_addlisting_nav')) {
|
|
| 160 | - |
|
| 161 | - $menu_class = ''; |
|
| 162 | - if (geodir_is_page('add-listing'))
|
|
| 163 | - $menu_class = 'current-menu-item'; |
|
| 164 | - |
|
| 165 | - //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
| 166 | - $post_types = geodir_get_posttypes('object');
|
|
| 167 | - $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
|
|
| 168 | - $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 169 | - |
|
| 170 | - if (!empty($post_types)) {
|
|
| 171 | - foreach ($post_types as $post_type => $args) {
|
|
| 172 | - if (!empty($geodir_allow_posttype_frontend)) {
|
|
| 173 | - if (in_array($post_type, $geodir_allow_posttype_frontend)) {
|
|
| 174 | - if (!empty($show_add_listing_post_types_main_nav)) {
|
|
| 175 | - if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
|
|
| 176 | - if (geodir_get_addlisting_link($post_type)) {
|
|
| 177 | - |
|
| 178 | - $menu_class = ''; |
|
| 179 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 180 | - $menu_class = 'current-menu-item'; |
|
| 181 | - /** |
|
| 182 | - * Filter the menu li class. |
|
| 183 | - * |
|
| 184 | - * @since 1.0.0 |
|
| 185 | - * @param string $menu_class The menu HTML class. |
|
| 186 | - */ |
|
| 187 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 188 | - /** |
|
| 189 | - * Filter the menu a class. |
|
| 190 | - * |
|
| 191 | - * @since 1.0.0 |
|
| 192 | - */ |
|
| 193 | - $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 194 | - $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
| 195 | - $items .= '<li class="' . $li_class . '"> |
|
| 148 | + $items .= ' </ul> '; |
|
| 149 | + /** |
|
| 150 | + * Filter called after the sub menu closing ul tag for dynamic added menu items. |
|
| 151 | + * |
|
| 152 | + * @since 1.5.9 |
|
| 153 | + */ |
|
| 154 | + $items .= apply_filters('geodir_menu_after_sub_ul','');
|
|
| 155 | + $items .= '</li>'; |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + if (get_option('geodir_show_addlisting_nav')) {
|
|
| 160 | + |
|
| 161 | + $menu_class = ''; |
|
| 162 | + if (geodir_is_page('add-listing'))
|
|
| 163 | + $menu_class = 'current-menu-item'; |
|
| 164 | + |
|
| 165 | + //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
| 166 | + $post_types = geodir_get_posttypes('object');
|
|
| 167 | + $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
|
|
| 168 | + $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 169 | + |
|
| 170 | + if (!empty($post_types)) {
|
|
| 171 | + foreach ($post_types as $post_type => $args) {
|
|
| 172 | + if (!empty($geodir_allow_posttype_frontend)) {
|
|
| 173 | + if (in_array($post_type, $geodir_allow_posttype_frontend)) {
|
|
| 174 | + if (!empty($show_add_listing_post_types_main_nav)) {
|
|
| 175 | + if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
|
|
| 176 | + if (geodir_get_addlisting_link($post_type)) {
|
|
| 177 | + |
|
| 178 | + $menu_class = ''; |
|
| 179 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 180 | + $menu_class = 'current-menu-item'; |
|
| 181 | + /** |
|
| 182 | + * Filter the menu li class. |
|
| 183 | + * |
|
| 184 | + * @since 1.0.0 |
|
| 185 | + * @param string $menu_class The menu HTML class. |
|
| 186 | + */ |
|
| 187 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 188 | + /** |
|
| 189 | + * Filter the menu a class. |
|
| 190 | + * |
|
| 191 | + * @since 1.0.0 |
|
| 192 | + */ |
|
| 193 | + $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 194 | + $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
| 195 | + $items .= '<li class="' . $li_class . '"> |
|
| 196 | 196 | <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '"> |
| 197 | 197 | ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
|
| 198 | 198 | </a> |
| 199 | 199 | </li>'; |
| 200 | - } |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
|
|
| 211 | - $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false; |
|
| 212 | - if ($is_add_listing_sub_meny_exists) {
|
|
| 213 | - |
|
| 214 | - if (get_option('geodir_show_addlisting_nav')) {
|
|
| 215 | - /** |
|
| 216 | - * Filter the menu li class. |
|
| 217 | - * |
|
| 218 | - * @since 1.0.0 |
|
| 219 | - * @param string $menu_class The menu HTML class. |
|
| 220 | - */ |
|
| 221 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
|
|
| 222 | - /** |
|
| 223 | - * Filter the sub menu li class. |
|
| 224 | - * |
|
| 225 | - * @since 1.0.0 |
|
| 226 | - * @param string $menu_class The menu HTML class. |
|
| 227 | - */ |
|
| 228 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 229 | - /** |
|
| 230 | - * Filter the sub menu ul class. |
|
| 231 | - * |
|
| 232 | - * @since 1.0.0 |
|
| 233 | - */ |
|
| 234 | - $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
|
|
| 235 | - /** |
|
| 236 | - * Filter the menu a class. |
|
| 237 | - * |
|
| 238 | - * @since 1.0.0 |
|
| 239 | - */ |
|
| 240 | - $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 241 | - /** |
|
| 242 | - * Filter the sub menu a class. |
|
| 243 | - * |
|
| 244 | - * @since 1.0.0 |
|
| 245 | - */ |
|
| 246 | - $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
|
| 247 | - $items .= '<li class="' . $li_class . '"> |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
|
|
| 211 | + $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false; |
|
| 212 | + if ($is_add_listing_sub_meny_exists) {
|
|
| 213 | + |
|
| 214 | + if (get_option('geodir_show_addlisting_nav')) {
|
|
| 215 | + /** |
|
| 216 | + * Filter the menu li class. |
|
| 217 | + * |
|
| 218 | + * @since 1.0.0 |
|
| 219 | + * @param string $menu_class The menu HTML class. |
|
| 220 | + */ |
|
| 221 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
|
|
| 222 | + /** |
|
| 223 | + * Filter the sub menu li class. |
|
| 224 | + * |
|
| 225 | + * @since 1.0.0 |
|
| 226 | + * @param string $menu_class The menu HTML class. |
|
| 227 | + */ |
|
| 228 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 229 | + /** |
|
| 230 | + * Filter the sub menu ul class. |
|
| 231 | + * |
|
| 232 | + * @since 1.0.0 |
|
| 233 | + */ |
|
| 234 | + $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
|
|
| 235 | + /** |
|
| 236 | + * Filter the menu a class. |
|
| 237 | + * |
|
| 238 | + * @since 1.0.0 |
|
| 239 | + */ |
|
| 240 | + $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 241 | + /** |
|
| 242 | + * Filter the sub menu a class. |
|
| 243 | + * |
|
| 244 | + * @since 1.0.0 |
|
| 245 | + */ |
|
| 246 | + $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
|
| 247 | + $items .= '<li class="' . $li_class . '"> |
|
| 248 | 248 | <a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
|
| 249 | 249 | <ul class="' . $sub_ul_class . '">'; |
| 250 | 250 | |
| 251 | - $post_types = geodir_get_posttypes('object');
|
|
| 252 | - |
|
| 253 | - $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
|
|
| 254 | - |
|
| 255 | - if (!empty($post_types)) {
|
|
| 256 | - foreach ($post_types as $post_type => $args) {
|
|
| 257 | - if (!empty($geodir_allow_posttype_frontend)) {
|
|
| 258 | - if (in_array($post_type, $geodir_allow_posttype_frontend)) {
|
|
| 259 | - if (!empty($show_add_listing_post_types)) {
|
|
| 260 | - if (in_array($post_type, $show_add_listing_post_types)) {
|
|
| 261 | - if (geodir_get_addlisting_link($post_type)) {
|
|
| 262 | - |
|
| 263 | - $menu_class = ''; |
|
| 264 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 265 | - $menu_class = 'current-menu-item'; |
|
| 266 | - /** |
|
| 267 | - * Filter the menu li class. |
|
| 268 | - * |
|
| 269 | - * @since 1.0.0 |
|
| 270 | - * @param string $menu_class The menu HTML class. |
|
| 271 | - */ |
|
| 272 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 273 | - $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
| 274 | - $items .= '<li class="' . $sub_li_class . '"> |
|
| 251 | + $post_types = geodir_get_posttypes('object');
|
|
| 252 | + |
|
| 253 | + $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
|
|
| 254 | + |
|
| 255 | + if (!empty($post_types)) {
|
|
| 256 | + foreach ($post_types as $post_type => $args) {
|
|
| 257 | + if (!empty($geodir_allow_posttype_frontend)) {
|
|
| 258 | + if (in_array($post_type, $geodir_allow_posttype_frontend)) {
|
|
| 259 | + if (!empty($show_add_listing_post_types)) {
|
|
| 260 | + if (in_array($post_type, $show_add_listing_post_types)) {
|
|
| 261 | + if (geodir_get_addlisting_link($post_type)) {
|
|
| 262 | + |
|
| 263 | + $menu_class = ''; |
|
| 264 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 265 | + $menu_class = 'current-menu-item'; |
|
| 266 | + /** |
|
| 267 | + * Filter the menu li class. |
|
| 268 | + * |
|
| 269 | + * @since 1.0.0 |
|
| 270 | + * @param string $menu_class The menu HTML class. |
|
| 271 | + */ |
|
| 272 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 273 | + $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
| 274 | + $items .= '<li class="' . $sub_li_class . '"> |
|
| 275 | 275 | <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '"> |
| 276 | 276 | ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
|
| 277 | 277 | </a> |
| 278 | 278 | </li>'; |
| 279 | - } |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - } |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | 286 | |
| 287 | - $items .= ' </ul> '; |
|
| 288 | - $items .= apply_filters('geodir_menu_after_sub_ul','');
|
|
| 289 | - $items .= '</li>'; |
|
| 287 | + $items .= ' </ul> '; |
|
| 288 | + $items .= apply_filters('geodir_menu_after_sub_ul','');
|
|
| 289 | + $items .= '</li>'; |
|
| 290 | 290 | |
| 291 | - } |
|
| 292 | - } |
|
| 293 | - // apply filter to add more navigations // -Filter-Location-Manager |
|
| 294 | - return $items; |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + // apply filter to add more navigations // -Filter-Location-Manager |
|
| 294 | + return $items; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | |
@@ -309,20 +309,20 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | function geodir_pagemenu_items($menu, $args) |
| 311 | 311 | {
|
| 312 | - $locations = get_nav_menu_locations(); |
|
| 313 | - $geodir_theme_location = get_option('geodir_theme_location_nav');
|
|
| 314 | - $geodir_theme_location_nav = array(); |
|
| 315 | - if (empty($locations) && empty($geodir_theme_location)) {
|
|
| 316 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 317 | - $geodir_theme_location_nav[] = $args['theme_location']; |
|
| 318 | - update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
|
|
| 319 | - } |
|
| 320 | - //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
|
| 312 | + $locations = get_nav_menu_locations(); |
|
| 313 | + $geodir_theme_location = get_option('geodir_theme_location_nav');
|
|
| 314 | + $geodir_theme_location_nav = array(); |
|
| 315 | + if (empty($locations) && empty($geodir_theme_location)) {
|
|
| 316 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 317 | + $geodir_theme_location_nav[] = $args['theme_location']; |
|
| 318 | + update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
|
|
| 319 | + } |
|
| 320 | + //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
|
| 321 | 321 | // $menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
|
| 322 | - else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
|
| 323 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 322 | + else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
|
| 323 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 324 | 324 | |
| 325 | - return $menu; |
|
| 325 | + return $menu; |
|
| 326 | 326 | |
| 327 | 327 | } |
| 328 | 328 | |
@@ -342,18 +342,18 @@ discard block |
||
| 342 | 342 | function geodir_menu_items($items, $args) |
| 343 | 343 | {
|
| 344 | 344 | |
| 345 | - $location = $args->theme_location; |
|
| 345 | + $location = $args->theme_location; |
|
| 346 | 346 | |
| 347 | - $geodir_theme_location = get_option('geodir_theme_location_nav');
|
|
| 347 | + $geodir_theme_location = get_option('geodir_theme_location_nav');
|
|
| 348 | 348 | |
| 349 | - if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
|
|
| 349 | + if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
|
|
| 350 | 350 | |
| 351 | - $items = $items . geodir_add_nav_menu_items(); |
|
| 352 | - return $items; |
|
| 351 | + $items = $items . geodir_add_nav_menu_items(); |
|
| 352 | + return $items; |
|
| 353 | 353 | |
| 354 | - } else {
|
|
| 355 | - return $items; |
|
| 356 | - } |
|
| 354 | + } else {
|
|
| 355 | + return $items; |
|
| 356 | + } |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
@@ -368,25 +368,25 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | function geodir_get_category_all_array() |
| 370 | 370 | {
|
| 371 | - global $wpdb; |
|
| 372 | - $return_array = array(); |
|
| 373 | - |
|
| 374 | - $taxonomies = geodir_get_taxonomies(); |
|
| 375 | - $taxonomies = implode("','", $taxonomies);
|
|
| 376 | - $taxonomies = "'" . $taxonomies . "'"; |
|
| 377 | - |
|
| 378 | - $pn_categories = $wpdb->get_results( |
|
| 379 | - $wpdb->prepare( |
|
| 380 | - "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name", |
|
| 381 | - array($wpdb->terms . term_id) |
|
| 382 | - ) |
|
| 383 | - ); |
|
| 384 | - |
|
| 385 | - foreach ($pn_categories as $pn_categories_obj) {
|
|
| 386 | - $return_array[] = array("id" => $pn_categories_obj->cat_ID,
|
|
| 387 | - "title" => $pn_categories_obj->name,); |
|
| 388 | - } |
|
| 389 | - return $return_array; |
|
| 371 | + global $wpdb; |
|
| 372 | + $return_array = array(); |
|
| 373 | + |
|
| 374 | + $taxonomies = geodir_get_taxonomies(); |
|
| 375 | + $taxonomies = implode("','", $taxonomies);
|
|
| 376 | + $taxonomies = "'" . $taxonomies . "'"; |
|
| 377 | + |
|
| 378 | + $pn_categories = $wpdb->get_results( |
|
| 379 | + $wpdb->prepare( |
|
| 380 | + "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name", |
|
| 381 | + array($wpdb->terms . term_id) |
|
| 382 | + ) |
|
| 383 | + ); |
|
| 384 | + |
|
| 385 | + foreach ($pn_categories as $pn_categories_obj) {
|
|
| 386 | + $return_array[] = array("id" => $pn_categories_obj->cat_ID,
|
|
| 387 | + "title" => $pn_categories_obj->name,); |
|
| 388 | + } |
|
| 389 | + return $return_array; |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | |
@@ -402,49 +402,49 @@ discard block |
||
| 402 | 402 | * @return string The post type. |
| 403 | 403 | */ |
| 404 | 404 | function geodir_get_current_posttype() {
|
| 405 | - global $wp_query, $post, $geodir_post_type; |
|
| 405 | + global $wp_query, $post, $geodir_post_type; |
|
| 406 | 406 | |
| 407 | - $geodir_post_type = get_query_var('post_type');
|
|
| 407 | + $geodir_post_type = get_query_var('post_type');
|
|
| 408 | 408 | |
| 409 | - if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
|
| 410 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 411 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 412 | - elseif (isset($_REQUEST['listing_type'])) |
|
| 413 | - $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 414 | - } |
|
| 409 | + if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
|
| 410 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 411 | + $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 412 | + elseif (isset($_REQUEST['listing_type'])) |
|
| 413 | + $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
|
|
| 417 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 416 | + if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
|
|
| 417 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 418 | 418 | |
| 419 | - if (is_tax()) |
|
| 420 | - $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 419 | + if (is_tax()) |
|
| 420 | + $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 421 | 421 | |
| 422 | - // Retrive post type for map marker html ajax request on preview page. |
|
| 423 | - if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
|
|
| 424 | - if (!empty($post->post_type)) {
|
|
| 425 | - $geodir_post_type = $post->post_type; |
|
| 426 | - } else if (!empty($post->listing_type)) {
|
|
| 427 | - $geodir_post_type = $post->listing_type; |
|
| 428 | - } |
|
| 429 | - } |
|
| 422 | + // Retrive post type for map marker html ajax request on preview page. |
|
| 423 | + if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
|
|
| 424 | + if (!empty($post->post_type)) {
|
|
| 425 | + $geodir_post_type = $post->post_type; |
|
| 426 | + } else if (!empty($post->listing_type)) {
|
|
| 427 | + $geodir_post_type = $post->listing_type; |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | 430 | |
| 431 | - $all_postypes = geodir_get_posttypes(); |
|
| 432 | - $all_postypes = stripslashes_deep($all_postypes); |
|
| 431 | + $all_postypes = geodir_get_posttypes(); |
|
| 432 | + $all_postypes = stripslashes_deep($all_postypes); |
|
| 433 | 433 | |
| 434 | - if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
| 435 | - $geodir_post_type = ''; |
|
| 434 | + if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
| 435 | + $geodir_post_type = ''; |
|
| 436 | 436 | |
| 437 | - if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
|
|
| 438 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 439 | - } |
|
| 437 | + if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
|
|
| 438 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | 441 | |
| 442 | - /** |
|
| 443 | - * Filter the default CPT return. |
|
| 444 | - * |
|
| 445 | - * @since 1.6.9 |
|
| 446 | - */ |
|
| 447 | - return apply_filters('geodir_get_current_posttype',$geodir_post_type);
|
|
| 442 | + /** |
|
| 443 | + * Filter the default CPT return. |
|
| 444 | + * |
|
| 445 | + * @since 1.6.9 |
|
| 446 | + */ |
|
| 447 | + return apply_filters('geodir_get_current_posttype',$geodir_post_type);
|
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | /** |
@@ -458,22 +458,22 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | function geodir_get_default_posttype() |
| 460 | 460 | {
|
| 461 | - $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
| 462 | - |
|
| 463 | - $stype = false; |
|
| 464 | - foreach ( $post_types as $post_type => $info ) {
|
|
| 465 | - global $wpdb; |
|
| 466 | - $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
| 467 | - if ( $has_posts ) {
|
|
| 468 | - $stype = $post_type; break; |
|
| 469 | - } |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - if(!$stype){
|
|
| 473 | - $stype = 'gd_place'; |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - return $stype; |
|
| 461 | + $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
| 462 | + |
|
| 463 | + $stype = false; |
|
| 464 | + foreach ( $post_types as $post_type => $info ) {
|
|
| 465 | + global $wpdb; |
|
| 466 | + $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
| 467 | + if ( $has_posts ) {
|
|
| 468 | + $stype = $post_type; break; |
|
| 469 | + } |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + if(!$stype){
|
|
| 473 | + $stype = 'gd_place'; |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + return $stype; |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | /** |
@@ -487,21 +487,21 @@ discard block |
||
| 487 | 487 | */ |
| 488 | 488 | function geodir_get_posttypes($output = 'names') |
| 489 | 489 | {
|
| 490 | - $post_types = array(); |
|
| 491 | - $post_types = get_option('geodir_post_types');
|
|
| 492 | - $post_types = stripslashes_deep($post_types); |
|
| 493 | - if (!empty($post_types)) {
|
|
| 494 | - switch ($output): |
|
| 495 | - case 'object': |
|
| 496 | - case 'Object': |
|
| 497 | - $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
| 498 | - break; |
|
| 499 | - case 'array': |
|
| 500 | - case 'Array': |
|
| 501 | - $post_types = (array)$post_types; |
|
| 502 | - break; |
|
| 490 | + $post_types = array(); |
|
| 491 | + $post_types = get_option('geodir_post_types');
|
|
| 492 | + $post_types = stripslashes_deep($post_types); |
|
| 493 | + if (!empty($post_types)) {
|
|
| 494 | + switch ($output): |
|
| 495 | + case 'object': |
|
| 496 | + case 'Object': |
|
| 497 | + $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
| 498 | + break; |
|
| 499 | + case 'array': |
|
| 500 | + case 'Array': |
|
| 501 | + $post_types = (array)$post_types; |
|
| 502 | + break; |
|
| 503 | 503 | case 'options': |
| 504 | - $post_types = (array)$post_types; |
|
| 504 | + $post_types = (array)$post_types; |
|
| 505 | 505 | |
| 506 | 506 | $options = array(); |
| 507 | 507 | if (!empty($post_types)) {
|
@@ -510,17 +510,17 @@ discard block |
||
| 510 | 510 | } |
| 511 | 511 | } |
| 512 | 512 | $post_types = $options; |
| 513 | - break; |
|
| 514 | - default: |
|
| 515 | - $post_types = array_keys($post_types); |
|
| 516 | - break; |
|
| 517 | - endswitch; |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - if (!empty($post_types)) |
|
| 521 | - return $post_types; |
|
| 522 | - else |
|
| 523 | - return array(); |
|
| 513 | + break; |
|
| 514 | + default: |
|
| 515 | + $post_types = array_keys($post_types); |
|
| 516 | + break; |
|
| 517 | + endswitch; |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + if (!empty($post_types)) |
|
| 521 | + return $post_types; |
|
| 522 | + else |
|
| 523 | + return array(); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | /** |
@@ -533,108 +533,108 @@ discard block |
||
| 533 | 533 | */ |
| 534 | 534 | function geodir_get_posttype_info($post_type = '') |
| 535 | 535 | {
|
| 536 | - $post_types = array(); |
|
| 537 | - $post_types = get_option('geodir_post_types');
|
|
| 538 | - $post_types = stripslashes_deep($post_types); |
|
| 539 | - if (!empty($post_types) && $post_type != '') {
|
|
| 540 | - return $post_types[$post_type]; |
|
| 541 | - } else |
|
| 542 | - return false; |
|
| 536 | + $post_types = array(); |
|
| 537 | + $post_types = get_option('geodir_post_types');
|
|
| 538 | + $post_types = stripslashes_deep($post_types); |
|
| 539 | + if (!empty($post_types) && $post_type != '') {
|
|
| 540 | + return $post_types[$post_type]; |
|
| 541 | + } else |
|
| 542 | + return false; |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | if (!function_exists('geodir_get_taxonomies')) {
|
| 546 | - /** |
|
| 547 | - * Get all custom taxonomies. |
|
| 548 | - * |
|
| 549 | - * @since 1.0.0 |
|
| 550 | - * @package GeoDirectory |
|
| 551 | - * @param string $post_type The post type. |
|
| 552 | - * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 553 | - * @return array|bool Taxonomies on success. false on failure. |
|
| 554 | - */ |
|
| 555 | - function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) |
|
| 556 | - {
|
|
| 546 | + /** |
|
| 547 | + * Get all custom taxonomies. |
|
| 548 | + * |
|
| 549 | + * @since 1.0.0 |
|
| 550 | + * @package GeoDirectory |
|
| 551 | + * @param string $post_type The post type. |
|
| 552 | + * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 553 | + * @return array|bool Taxonomies on success. false on failure. |
|
| 554 | + */ |
|
| 555 | + function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) |
|
| 556 | + {
|
|
| 557 | 557 | |
| 558 | - $taxonomies = array(); |
|
| 559 | - $gd_taxonomies = array(); |
|
| 558 | + $taxonomies = array(); |
|
| 559 | + $gd_taxonomies = array(); |
|
| 560 | 560 | |
| 561 | - if ($taxonomies = get_option('geodir_taxonomies')) {
|
|
| 561 | + if ($taxonomies = get_option('geodir_taxonomies')) {
|
|
| 562 | 562 | |
| 563 | 563 | |
| 564 | - $gd_taxonomies = array_keys($taxonomies); |
|
| 564 | + $gd_taxonomies = array_keys($taxonomies); |
|
| 565 | 565 | |
| 566 | 566 | |
| 567 | - if ($post_type != '') |
|
| 568 | - $gd_taxonomies = array(); |
|
| 567 | + if ($post_type != '') |
|
| 568 | + $gd_taxonomies = array(); |
|
| 569 | 569 | |
| 570 | - $i = 0; |
|
| 571 | - foreach ($taxonomies as $taxonomy => $args) {
|
|
| 570 | + $i = 0; |
|
| 571 | + foreach ($taxonomies as $taxonomy => $args) {
|
|
| 572 | 572 | |
| 573 | - if ($post_type != '' && $args['object_type'] == $post_type) |
|
| 574 | - $gd_taxonomies[] = $taxonomy; |
|
| 573 | + if ($post_type != '' && $args['object_type'] == $post_type) |
|
| 574 | + $gd_taxonomies[] = $taxonomy; |
|
| 575 | 575 | |
| 576 | - if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
|
|
| 577 | - if (array_search($taxonomy, $gd_taxonomies) !== false) |
|
| 578 | - unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
| 579 | - } |
|
| 576 | + if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
|
|
| 577 | + if (array_search($taxonomy, $gd_taxonomies) !== false) |
|
| 578 | + unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
| 579 | + } |
|
| 580 | 580 | |
| 581 | - } |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + $gd_taxonomies = array_values($gd_taxonomies); |
|
| 584 | + } |
|
| 582 | 585 | |
| 583 | - $gd_taxonomies = array_values($gd_taxonomies); |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - /** |
|
| 587 | - * Filter the taxonomies. |
|
| 588 | - * |
|
| 589 | - * @since 1.0.0 |
|
| 590 | - * @param array $gd_taxonomies The taxonomy array. |
|
| 591 | - */ |
|
| 592 | - $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
|
|
| 593 | - |
|
| 594 | - if (!empty($taxonomies)) {
|
|
| 595 | - return $taxonomies; |
|
| 596 | - } else {
|
|
| 597 | - return false; |
|
| 598 | - } |
|
| 599 | - } |
|
| 586 | + /** |
|
| 587 | + * Filter the taxonomies. |
|
| 588 | + * |
|
| 589 | + * @since 1.0.0 |
|
| 590 | + * @param array $gd_taxonomies The taxonomy array. |
|
| 591 | + */ |
|
| 592 | + $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
|
|
| 593 | + |
|
| 594 | + if (!empty($taxonomies)) {
|
|
| 595 | + return $taxonomies; |
|
| 596 | + } else {
|
|
| 597 | + return false; |
|
| 598 | + } |
|
| 599 | + } |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | if (!function_exists(' geodir_get_categories_dl')) {
|
| 603 | - /** |
|
| 604 | - * Get categories dropdown HTML. |
|
| 605 | - * |
|
| 606 | - * @since 1.0.0 |
|
| 607 | - * @package GeoDirectory |
|
| 608 | - * @param string $post_type The post type. |
|
| 609 | - * @param string $selected The selected value. |
|
| 610 | - * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 611 | - * @param bool $echo Prints the HTML when set to true. Default: true. |
|
| 612 | - * @return void|string Dropdown HTML. |
|
| 613 | - */ |
|
| 614 | - function geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true) |
|
| 615 | - {
|
|
| 616 | - |
|
| 617 | - $html = ''; |
|
| 618 | - $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies); |
|
| 619 | - |
|
| 620 | - $categories = get_terms($taxonomies); |
|
| 621 | - |
|
| 622 | - $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
|
|
| 623 | - |
|
| 624 | - foreach ($categories as $category_obj) {
|
|
| 625 | - $select_opt = ''; |
|
| 626 | - if ($selected == $category_obj->term_id) {
|
|
| 627 | - $select_opt = 'selected="selected"'; |
|
| 628 | - } |
|
| 629 | - $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
| 630 | - . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - if ($echo) |
|
| 634 | - echo $html; |
|
| 635 | - else |
|
| 636 | - return $html; |
|
| 637 | - } |
|
| 603 | + /** |
|
| 604 | + * Get categories dropdown HTML. |
|
| 605 | + * |
|
| 606 | + * @since 1.0.0 |
|
| 607 | + * @package GeoDirectory |
|
| 608 | + * @param string $post_type The post type. |
|
| 609 | + * @param string $selected The selected value. |
|
| 610 | + * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 611 | + * @param bool $echo Prints the HTML when set to true. Default: true. |
|
| 612 | + * @return void|string Dropdown HTML. |
|
| 613 | + */ |
|
| 614 | + function geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true) |
|
| 615 | + {
|
|
| 616 | + |
|
| 617 | + $html = ''; |
|
| 618 | + $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies); |
|
| 619 | + |
|
| 620 | + $categories = get_terms($taxonomies); |
|
| 621 | + |
|
| 622 | + $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
|
|
| 623 | + |
|
| 624 | + foreach ($categories as $category_obj) {
|
|
| 625 | + $select_opt = ''; |
|
| 626 | + if ($selected == $category_obj->term_id) {
|
|
| 627 | + $select_opt = 'selected="selected"'; |
|
| 628 | + } |
|
| 629 | + $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
| 630 | + . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + if ($echo) |
|
| 634 | + echo $html; |
|
| 635 | + else |
|
| 636 | + return $html; |
|
| 637 | + } |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | |
@@ -649,28 +649,28 @@ discard block |
||
| 649 | 649 | function geodir_get_listing_slug($object_type = '') |
| 650 | 650 | {
|
| 651 | 651 | |
| 652 | - $listing_slug = ''; |
|
| 652 | + $listing_slug = ''; |
|
| 653 | 653 | |
| 654 | - $post_types = get_option('geodir_post_types');
|
|
| 655 | - $taxonomies = get_option('geodir_taxonomies');
|
|
| 654 | + $post_types = get_option('geodir_post_types');
|
|
| 655 | + $taxonomies = get_option('geodir_taxonomies');
|
|
| 656 | 656 | |
| 657 | 657 | |
| 658 | - if ($object_type != '') {
|
|
| 659 | - if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
|
|
| 658 | + if ($object_type != '') {
|
|
| 659 | + if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
|
|
| 660 | 660 | |
| 661 | - $object_info = $post_types[$object_type]; |
|
| 662 | - $listing_slug = $object_info['listing_slug']; |
|
| 663 | - } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
|
|
| 664 | - $object_info = $taxonomies[$object_type]; |
|
| 665 | - $listing_slug = $object_info['listing_slug']; |
|
| 666 | - } |
|
| 661 | + $object_info = $post_types[$object_type]; |
|
| 662 | + $listing_slug = $object_info['listing_slug']; |
|
| 663 | + } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
|
|
| 664 | + $object_info = $taxonomies[$object_type]; |
|
| 665 | + $listing_slug = $object_info['listing_slug']; |
|
| 666 | + } |
|
| 667 | 667 | |
| 668 | - } |
|
| 668 | + } |
|
| 669 | 669 | |
| 670 | - if (!empty($listing_slug)) |
|
| 671 | - return $listing_slug; |
|
| 672 | - else |
|
| 673 | - return false; |
|
| 670 | + if (!empty($listing_slug)) |
|
| 671 | + return $listing_slug; |
|
| 672 | + else |
|
| 673 | + return false; |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | |
@@ -685,212 +685,212 @@ discard block |
||
| 685 | 685 | */ |
| 686 | 686 | function geodir_get_taxonomy_posttype($taxonomy = '') |
| 687 | 687 | {
|
| 688 | - global $wp_query; |
|
| 689 | - |
|
| 690 | - $post_type = array(); |
|
| 691 | - $taxonomies = array(); |
|
| 692 | - |
|
| 693 | - if (!empty($taxonomy)) {
|
|
| 694 | - $taxonomies[] = $taxonomy; |
|
| 695 | - } elseif (isset($wp_query->tax_query->queries)) {
|
|
| 696 | - $tax_arr = $wp_query->tax_query->queries; |
|
| 697 | - //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
|
| 698 | - if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
|
|
| 699 | - $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
|
| 700 | - } |
|
| 701 | - |
|
| 702 | - if (!empty($taxonomies)) {
|
|
| 703 | - foreach (geodir_get_posttypes() as $pt) {
|
|
| 704 | - $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
| 705 | - if (array_intersect($taxonomies, $object_taxonomies)) |
|
| 706 | - $post_type[] = $pt; |
|
| 707 | - } |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - if (!empty($post_type)) |
|
| 711 | - return $post_type[0]; |
|
| 712 | - else |
|
| 713 | - return false; |
|
| 688 | + global $wp_query; |
|
| 689 | + |
|
| 690 | + $post_type = array(); |
|
| 691 | + $taxonomies = array(); |
|
| 692 | + |
|
| 693 | + if (!empty($taxonomy)) {
|
|
| 694 | + $taxonomies[] = $taxonomy; |
|
| 695 | + } elseif (isset($wp_query->tax_query->queries)) {
|
|
| 696 | + $tax_arr = $wp_query->tax_query->queries; |
|
| 697 | + //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
|
| 698 | + if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
|
|
| 699 | + $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + if (!empty($taxonomies)) {
|
|
| 703 | + foreach (geodir_get_posttypes() as $pt) {
|
|
| 704 | + $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
| 705 | + if (array_intersect($taxonomies, $object_taxonomies)) |
|
| 706 | + $post_type[] = $pt; |
|
| 707 | + } |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + if (!empty($post_type)) |
|
| 711 | + return $post_type[0]; |
|
| 712 | + else |
|
| 713 | + return false; |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | if (!function_exists('geodir_custom_taxonomy_walker')) {
|
| 717 | - /** |
|
| 718 | - * Custom taxonomy walker function. |
|
| 719 | - * |
|
| 720 | - * @since 1.0.0 |
|
| 721 | - * @package GeoDirectory |
|
| 722 | - * @param string $cat_taxonomy The taxonomy name. |
|
| 723 | - * @param int $cat_parent The parent term ID. |
|
| 724 | - * @param bool $hide_empty Hide empty taxonomies? Default: false. |
|
| 725 | - * @param int $pading CSS padding in pixels. |
|
| 726 | - * @return string|void taxonomy HTML. |
|
| 727 | - */ |
|
| 728 | - function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) |
|
| 729 | - {
|
|
| 730 | - global $cat_display, $post_cat, $exclude_cats; |
|
| 731 | - |
|
| 732 | - $search_terms = trim($post_cat, ","); |
|
| 733 | - |
|
| 734 | - $search_terms = explode(",", $search_terms);
|
|
| 735 | - |
|
| 736 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
|
|
| 737 | - |
|
| 738 | - $display = ''; |
|
| 739 | - $onchange = ''; |
|
| 740 | - $term_check = ''; |
|
| 741 | - $main_list_class = ''; |
|
| 742 | - $out = ''; |
|
| 743 | - //If there are terms, start displaying |
|
| 744 | - if (count($cat_terms) > 0) {
|
|
| 745 | - //Displaying as a list |
|
| 746 | - $p = $pading * 20; |
|
| 747 | - $pading++; |
|
| 748 | - |
|
| 749 | - |
|
| 750 | - if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
|
|
| 751 | - if ($cat_parent == 0) {
|
|
| 752 | - $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
| 753 | - $main_list_class = 'class="main_list_selecter"'; |
|
| 754 | - } else {
|
|
| 755 | - //$display = 'display:none'; |
|
| 756 | - $list_class = 'sub_list gd-sub-cats-list'; |
|
| 757 | - } |
|
| 758 | - } |
|
| 717 | + /** |
|
| 718 | + * Custom taxonomy walker function. |
|
| 719 | + * |
|
| 720 | + * @since 1.0.0 |
|
| 721 | + * @package GeoDirectory |
|
| 722 | + * @param string $cat_taxonomy The taxonomy name. |
|
| 723 | + * @param int $cat_parent The parent term ID. |
|
| 724 | + * @param bool $hide_empty Hide empty taxonomies? Default: false. |
|
| 725 | + * @param int $pading CSS padding in pixels. |
|
| 726 | + * @return string|void taxonomy HTML. |
|
| 727 | + */ |
|
| 728 | + function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) |
|
| 729 | + {
|
|
| 730 | + global $cat_display, $post_cat, $exclude_cats; |
|
| 731 | + |
|
| 732 | + $search_terms = trim($post_cat, ","); |
|
| 733 | + |
|
| 734 | + $search_terms = explode(",", $search_terms);
|
|
| 735 | + |
|
| 736 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
|
|
| 737 | + |
|
| 738 | + $display = ''; |
|
| 739 | + $onchange = ''; |
|
| 740 | + $term_check = ''; |
|
| 741 | + $main_list_class = ''; |
|
| 742 | + $out = ''; |
|
| 743 | + //If there are terms, start displaying |
|
| 744 | + if (count($cat_terms) > 0) {
|
|
| 745 | + //Displaying as a list |
|
| 746 | + $p = $pading * 20; |
|
| 747 | + $pading++; |
|
| 748 | + |
|
| 749 | + |
|
| 750 | + if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
|
|
| 751 | + if ($cat_parent == 0) {
|
|
| 752 | + $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
| 753 | + $main_list_class = 'class="main_list_selecter"'; |
|
| 754 | + } else {
|
|
| 755 | + //$display = 'display:none'; |
|
| 756 | + $list_class = 'sub_list gd-sub-cats-list'; |
|
| 757 | + } |
|
| 758 | + } |
|
| 759 | 759 | |
| 760 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') {
|
|
| 761 | - $p = 0; |
|
| 762 | - $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 763 | - } |
|
| 760 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') {
|
|
| 761 | + $p = 0; |
|
| 762 | + $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 763 | + } |
|
| 764 | 764 | |
| 765 | - foreach ($cat_terms as $cat_term) {
|
|
| 765 | + foreach ($cat_terms as $cat_term) {
|
|
| 766 | 766 | |
| 767 | - $checked = ''; |
|
| 767 | + $checked = ''; |
|
| 768 | 768 | |
| 769 | - if (in_array($cat_term->term_id, $search_terms)) {
|
|
| 770 | - if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 771 | - $checked = 'selected="selected"'; |
|
| 772 | - else |
|
| 773 | - $checked = 'checked="checked"'; |
|
| 774 | - } |
|
| 769 | + if (in_array($cat_term->term_id, $search_terms)) {
|
|
| 770 | + if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 771 | + $checked = 'selected="selected"'; |
|
| 772 | + else |
|
| 773 | + $checked = 'checked="checked"'; |
|
| 774 | + } |
|
| 775 | 775 | |
| 776 | - if ($cat_display == 'radio') |
|
| 777 | - $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 778 | - elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 779 | - $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 776 | + if ($cat_display == 'radio') |
|
| 777 | + $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 778 | + elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 779 | + $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 780 | 780 | |
| 781 | - else {
|
|
| 782 | - $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 783 | - } |
|
| 781 | + else {
|
|
| 782 | + $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 783 | + } |
|
| 784 | 784 | |
| 785 | - // Call recurson to print sub cats |
|
| 786 | - $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); |
|
| 785 | + // Call recurson to print sub cats |
|
| 786 | + $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); |
|
| 787 | 787 | |
| 788 | - } |
|
| 788 | + } |
|
| 789 | 789 | |
| 790 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
| 791 | - $out .= '</div>'; |
|
| 790 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
| 791 | + $out .= '</div>'; |
|
| 792 | 792 | |
| 793 | - return $out; |
|
| 794 | - } |
|
| 795 | - return; |
|
| 796 | - } |
|
| 793 | + return $out; |
|
| 794 | + } |
|
| 795 | + return; |
|
| 796 | + } |
|
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | if (!function_exists('geodir_custom_taxonomy_walker2')) {
|
| 800 | - /** |
|
| 801 | - * Custom taxonomy walker function. |
|
| 802 | - * |
|
| 803 | - * @since 1.0.0 |
|
| 804 | - * @package GeoDirectory |
|
| 805 | - * @global object $post WordPress Post object. |
|
| 806 | - * @global object $gd_session GeoDirectory Session object. |
|
| 807 | - * @param string $cat_taxonomy The taxonomy name. |
|
| 808 | - * @param string $cat_limit Number of categories to display. |
|
| 809 | - */ |
|
| 810 | - function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') |
|
| 811 | - {
|
|
| 812 | - $post_category = ''; |
|
| 813 | - $post_category_str = ''; |
|
| 814 | - global $exclude_cats, $gd_session; |
|
| 815 | - |
|
| 816 | - $cat_exclude = ''; |
|
| 817 | - if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
| 818 | - $cat_exclude = serialize($exclude_cats); |
|
| 819 | - |
|
| 820 | - if (isset($_REQUEST['backandedit'])) {
|
|
| 821 | - $post = (object)$gd_session->get('listing');
|
|
| 822 | - |
|
| 823 | - if (!is_array($post->post_category[$cat_taxonomy])) |
|
| 824 | - $post_category = $post->post_category[$cat_taxonomy]; |
|
| 825 | - |
|
| 826 | - $post_categories = $post->post_category_str; |
|
| 827 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
| 828 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 829 | - |
|
| 830 | - } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
|
|
| 831 | - global $post; |
|
| 832 | - |
|
| 833 | - $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); |
|
| 834 | - if (empty($post_category) && isset($post->{$cat_taxonomy})) {
|
|
| 835 | - $post_category = $post->{$cat_taxonomy};
|
|
| 836 | - } |
|
| 800 | + /** |
|
| 801 | + * Custom taxonomy walker function. |
|
| 802 | + * |
|
| 803 | + * @since 1.0.0 |
|
| 804 | + * @package GeoDirectory |
|
| 805 | + * @global object $post WordPress Post object. |
|
| 806 | + * @global object $gd_session GeoDirectory Session object. |
|
| 807 | + * @param string $cat_taxonomy The taxonomy name. |
|
| 808 | + * @param string $cat_limit Number of categories to display. |
|
| 809 | + */ |
|
| 810 | + function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') |
|
| 811 | + {
|
|
| 812 | + $post_category = ''; |
|
| 813 | + $post_category_str = ''; |
|
| 814 | + global $exclude_cats, $gd_session; |
|
| 815 | + |
|
| 816 | + $cat_exclude = ''; |
|
| 817 | + if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
| 818 | + $cat_exclude = serialize($exclude_cats); |
|
| 819 | + |
|
| 820 | + if (isset($_REQUEST['backandedit'])) {
|
|
| 821 | + $post = (object)$gd_session->get('listing');
|
|
| 822 | + |
|
| 823 | + if (!is_array($post->post_category[$cat_taxonomy])) |
|
| 824 | + $post_category = $post->post_category[$cat_taxonomy]; |
|
| 825 | + |
|
| 826 | + $post_categories = $post->post_category_str; |
|
| 827 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
| 828 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 829 | + |
|
| 830 | + } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
|
|
| 831 | + global $post; |
|
| 832 | + |
|
| 833 | + $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); |
|
| 834 | + if (empty($post_category) && isset($post->{$cat_taxonomy})) {
|
|
| 835 | + $post_category = $post->{$cat_taxonomy};
|
|
| 836 | + } |
|
| 837 | 837 | |
| 838 | - $post_categories = get_post_meta($post->ID, 'post_categories', true); |
|
| 838 | + $post_categories = get_post_meta($post->ID, 'post_categories', true); |
|
| 839 | 839 | |
| 840 | - if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 841 | - foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
|
|
| 842 | - if (is_numeric($cat_part)) {
|
|
| 843 | - $cat_part_arr[] = $cat_part; |
|
| 844 | - } |
|
| 845 | - } |
|
| 846 | - if (is_array($cat_part_arr)) {
|
|
| 847 | - $post_category = implode(',', $cat_part_arr);
|
|
| 848 | - } |
|
| 849 | - } |
|
| 840 | + if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 841 | + foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
|
|
| 842 | + if (is_numeric($cat_part)) {
|
|
| 843 | + $cat_part_arr[] = $cat_part; |
|
| 844 | + } |
|
| 845 | + } |
|
| 846 | + if (is_array($cat_part_arr)) {
|
|
| 847 | + $post_category = implode(',', $cat_part_arr);
|
|
| 848 | + } |
|
| 849 | + } |
|
| 850 | 850 | |
| 851 | - if (!empty($post_category)) {
|
|
| 852 | - $cat1 = array_filter(explode(',', $post_category));
|
|
| 853 | - $post_category = ',' . implode(',', $cat1) . ',';
|
|
| 851 | + if (!empty($post_category)) {
|
|
| 852 | + $cat1 = array_filter(explode(',', $post_category));
|
|
| 853 | + $post_category = ',' . implode(',', $cat1) . ',';
|
|
| 854 | 854 | |
| 855 | - } |
|
| 855 | + } |
|
| 856 | 856 | |
| 857 | - if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
|
|
| 857 | + if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
|
|
| 858 | 858 | |
| 859 | - $post_category_upd = explode(',', $post_category);
|
|
| 860 | - $post_category_change = ''; |
|
| 861 | - foreach ($post_category_upd as $cat) {
|
|
| 859 | + $post_category_upd = explode(',', $post_category);
|
|
| 860 | + $post_category_change = ''; |
|
| 861 | + foreach ($post_category_upd as $cat) {
|
|
| 862 | 862 | |
| 863 | - if (!in_array($cat, $exclude_cats) && $cat != '') {
|
|
| 864 | - $post_category_change .= ',' . $cat; |
|
| 865 | - } |
|
| 866 | - } |
|
| 867 | - $post_category = $post_category_change; |
|
| 868 | - } |
|
| 863 | + if (!in_array($cat, $exclude_cats) && $cat != '') {
|
|
| 864 | + $post_category_change .= ',' . $cat; |
|
| 865 | + } |
|
| 866 | + } |
|
| 867 | + $post_category = $post_category_change; |
|
| 868 | + } |
|
| 869 | 869 | |
| 870 | 870 | |
| 871 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 872 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 873 | - } |
|
| 874 | - } |
|
| 871 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 872 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 873 | + } |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | - echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
| 876 | + echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
| 877 | 877 | |
| 878 | - echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
| 878 | + echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
| 879 | 879 | |
| 880 | - echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
| 880 | + echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
| 881 | 881 | |
| 882 | 882 | |
| 883 | - ?> |
|
| 883 | + ?> |
|
| 884 | 884 | <div class="cat_sublist"> |
| 885 | 885 | <?php |
| 886 | 886 | |
| 887 | - $post_id = isset($post->ID) ? $post->ID : ''; |
|
| 887 | + $post_id = isset($post->ID) ? $post->ID : ''; |
|
| 888 | 888 | |
| 889 | - if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 889 | + if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 890 | 890 | |
| 891 | - geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); |
|
| 892 | - } |
|
| 893 | - ?> |
|
| 891 | + geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); |
|
| 892 | + } |
|
| 893 | + ?> |
|
| 894 | 894 | </div> |
| 895 | 895 | <script type="text/javascript"> |
| 896 | 896 | |
@@ -1013,22 +1013,22 @@ discard block |
||
| 1013 | 1013 | |
| 1014 | 1014 | </script> |
| 1015 | 1015 | <?php |
| 1016 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 1017 | - $post_cat_str = $post_categories[$cat_taxonomy]; |
|
| 1018 | - $post_cat_array = explode("#", $post_cat_str);
|
|
| 1019 | - if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
| 1020 | - $style = "display:none;"; |
|
| 1021 | - } |
|
| 1022 | - ?> |
|
| 1016 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 1017 | + $post_cat_str = $post_categories[$cat_taxonomy]; |
|
| 1018 | + $post_cat_array = explode("#", $post_cat_str);
|
|
| 1019 | + if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
| 1020 | + $style = "display:none;"; |
|
| 1021 | + } |
|
| 1022 | + ?> |
|
| 1023 | 1023 | <div class="main_cat_list" style=" <?php if (isset($style)) {
|
| 1024 | - echo $style; |
|
| 1025 | - }?> "> |
|
| 1024 | + echo $style; |
|
| 1025 | + }?> "> |
|
| 1026 | 1026 | <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list |
| 1027 | - ?> |
|
| 1027 | + ?> |
|
| 1028 | 1028 | </div> |
| 1029 | 1029 | <?php |
| 1030 | 1030 | |
| 1031 | - } |
|
| 1031 | + } |
|
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | /** |
@@ -1045,23 +1045,23 @@ discard block |
||
| 1045 | 1045 | */ |
| 1046 | 1046 | function geodir_addpost_categories_html($request_taxonomy, $parrent, $selected = false, $main_selected = true, $default = false, $exclude = '') |
| 1047 | 1047 | {
|
| 1048 | - global $exclude_cats; |
|
| 1048 | + global $exclude_cats; |
|
| 1049 | 1049 | |
| 1050 | - if ($exclude != '') {
|
|
| 1051 | - $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
|
| 1050 | + if ($exclude != '') {
|
|
| 1051 | + $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
|
| 1052 | 1052 | |
| 1053 | - if(is_array( $exclude_cats)){
|
|
| 1054 | - $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
| 1055 | - }else{
|
|
| 1056 | - $exclude_cats = intval($exclude_cats); |
|
| 1057 | - } |
|
| 1053 | + if(is_array( $exclude_cats)){
|
|
| 1054 | + $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
| 1055 | + }else{
|
|
| 1056 | + $exclude_cats = intval($exclude_cats); |
|
| 1057 | + } |
|
| 1058 | 1058 | |
| 1059 | - } |
|
| 1059 | + } |
|
| 1060 | 1060 | |
| 1061 | - if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) || |
|
| 1062 | - (!is_array($exclude_cats) || empty($exclude_cats)) |
|
| 1063 | - ) {
|
|
| 1064 | - ?> |
|
| 1061 | + if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) || |
|
| 1062 | + (!is_array($exclude_cats) || empty($exclude_cats)) |
|
| 1063 | + ) {
|
|
| 1064 | + ?> |
|
| 1065 | 1065 | |
| 1066 | 1066 | <?php $main_cat = get_term($parrent, $request_taxonomy); ?> |
| 1067 | 1067 | |
@@ -1090,8 +1090,8 @@ discard block |
||
| 1090 | 1090 | |
| 1091 | 1091 | <br/> |
| 1092 | 1092 | <?php |
| 1093 | - $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1094 | - if (!empty($cat_terms)) { ?>
|
|
| 1093 | + $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1094 | + if (!empty($cat_terms)) { ?>
|
|
| 1095 | 1095 | <span> <?php printf(__('Add listing in category', 'geodirectory')); ?></span>
|
| 1096 | 1096 | <?php geodir_get_catlist($request_taxonomy, $parrent, $selected) ?> |
| 1097 | 1097 | <?php } ?> |
@@ -1113,53 +1113,53 @@ discard block |
||
| 1113 | 1113 | function geodir_editpost_categories_html($request_taxonomy, $request_postid, $post_categories) |
| 1114 | 1114 | {
|
| 1115 | 1115 | |
| 1116 | - if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
|
|
| 1117 | - $post_cat_str = $post_categories[$request_taxonomy]; |
|
| 1118 | - $post_cat_array = explode("#", $post_cat_str);
|
|
| 1119 | - if (is_array($post_cat_array)) {
|
|
| 1120 | - $post_cat_array = array_unique( $post_cat_array ); |
|
| 1116 | + if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
|
|
| 1117 | + $post_cat_str = $post_categories[$request_taxonomy]; |
|
| 1118 | + $post_cat_array = explode("#", $post_cat_str);
|
|
| 1119 | + if (is_array($post_cat_array)) {
|
|
| 1120 | + $post_cat_array = array_unique( $post_cat_array ); |
|
| 1121 | 1121 | |
| 1122 | 1122 | foreach ($post_cat_array as $post_cat_html) {
|
| 1123 | 1123 | |
| 1124 | - $post_cat_info = explode(":", $post_cat_html);
|
|
| 1125 | - $post_maincat_str = $post_cat_info[0]; |
|
| 1124 | + $post_cat_info = explode(":", $post_cat_html);
|
|
| 1125 | + $post_maincat_str = $post_cat_info[0]; |
|
| 1126 | 1126 | |
| 1127 | - if (!empty($post_maincat_str)) {
|
|
| 1128 | - $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1129 | - $post_maincat_id = $post_maincat_info[0]; |
|
| 1130 | - ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1131 | - (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1132 | - } |
|
| 1133 | - $post_sub_catid = ''; |
|
| 1134 | - if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1135 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1136 | - } |
|
| 1127 | + if (!empty($post_maincat_str)) {
|
|
| 1128 | + $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1129 | + $post_maincat_id = $post_maincat_info[0]; |
|
| 1130 | + ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1131 | + (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1132 | + } |
|
| 1133 | + $post_sub_catid = ''; |
|
| 1134 | + if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1135 | + $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1136 | + } |
|
| 1137 | 1137 | |
| 1138 | - geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1138 | + geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1139 | 1139 | |
| 1140 | - } |
|
| 1141 | - } else {
|
|
| 1140 | + } |
|
| 1141 | + } else {
|
|
| 1142 | 1142 | |
| 1143 | - $post_cat_info = explode(":", $post_cat_str);
|
|
| 1144 | - $post_maincat_str = $post_cat_info[0]; |
|
| 1143 | + $post_cat_info = explode(":", $post_cat_str);
|
|
| 1144 | + $post_maincat_str = $post_cat_info[0]; |
|
| 1145 | 1145 | |
| 1146 | - $post_sub_catid = ''; |
|
| 1146 | + $post_sub_catid = ''; |
|
| 1147 | 1147 | |
| 1148 | - if (!empty($post_maincat_str)) {
|
|
| 1149 | - $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1150 | - $post_maincat_id = $post_maincat_info[0]; |
|
| 1151 | - ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1152 | - (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1153 | - } |
|
| 1148 | + if (!empty($post_maincat_str)) {
|
|
| 1149 | + $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1150 | + $post_maincat_id = $post_maincat_info[0]; |
|
| 1151 | + ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1152 | + (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | - if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1156 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1157 | - } |
|
| 1155 | + if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1156 | + $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1157 | + } |
|
| 1158 | 1158 | |
| 1159 | - geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1159 | + geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1160 | 1160 | |
| 1161 | - } |
|
| 1162 | - } |
|
| 1161 | + } |
|
| 1162 | + } |
|
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | /** |
@@ -1173,35 +1173,35 @@ discard block |
||
| 1173 | 1173 | */ |
| 1174 | 1174 | function geodir_get_catlist($cat_taxonomy, $parrent = 0, $selected = false) |
| 1175 | 1175 | {
|
| 1176 | - global $exclude_cats; |
|
| 1176 | + global $exclude_cats; |
|
| 1177 | 1177 | |
| 1178 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1178 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1179 | 1179 | |
| 1180 | - if (!empty($cat_terms)) {
|
|
| 1181 | - $onchange = ''; |
|
| 1182 | - $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
|
| 1180 | + if (!empty($cat_terms)) {
|
|
| 1181 | + $onchange = ''; |
|
| 1182 | + $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
|
| 1183 | 1183 | |
| 1184 | - $option_selected = ''; |
|
| 1185 | - if (!$selected) |
|
| 1186 | - $option_slected = ' selected="selected" '; |
|
| 1184 | + $option_selected = ''; |
|
| 1185 | + if (!$selected) |
|
| 1186 | + $option_slected = ' selected="selected" '; |
|
| 1187 | 1187 | |
| 1188 | - echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
| 1188 | + echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
| 1189 | 1189 | |
| 1190 | - echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
|
|
| 1190 | + echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
|
|
| 1191 | 1191 | |
| 1192 | - foreach ($cat_terms as $cat_term) {
|
|
| 1193 | - $option_selected = ''; |
|
| 1194 | - if ($selected == $cat_term->term_id) |
|
| 1195 | - $option_selected = ' selected="selected" '; |
|
| 1192 | + foreach ($cat_terms as $cat_term) {
|
|
| 1193 | + $option_selected = ''; |
|
| 1194 | + if ($selected == $cat_term->term_id) |
|
| 1195 | + $option_selected = ' selected="selected" '; |
|
| 1196 | 1196 | |
| 1197 | - // Count child terms |
|
| 1198 | - $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
| 1199 | - $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
| 1197 | + // Count child terms |
|
| 1198 | + $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
| 1199 | + $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
| 1200 | 1200 | |
| 1201 | - echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 1202 | - } |
|
| 1203 | - echo '</select>'; |
|
| 1204 | - } |
|
| 1201 | + echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 1202 | + } |
|
| 1203 | + echo '</select>'; |
|
| 1204 | + } |
|
| 1205 | 1205 | } |
| 1206 | 1206 | |
| 1207 | 1207 | /** |
@@ -1217,28 +1217,28 @@ discard block |
||
| 1217 | 1217 | */ |
| 1218 | 1218 | function geodir_custom_update_messages($messages) |
| 1219 | 1219 | {
|
| 1220 | - global $post, $post_ID; |
|
| 1221 | - |
|
| 1222 | - $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
|
|
| 1223 | - |
|
| 1224 | - foreach ($post_types as $post_type => $post_object) {
|
|
| 1225 | - |
|
| 1226 | - $messages[$post_type] = array( |
|
| 1227 | - 0 => '', // Unused. Messages start at index 1. |
|
| 1228 | - 1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1229 | - 2 => __('Custom field updated.', 'geodirectory'),
|
|
| 1230 | - 3 => __('Custom field deleted.', 'geodirectory'),
|
|
| 1231 | - 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1232 | - 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
|
|
| 1233 | - 6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1234 | - 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1235 | - 8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
|
| 1236 | - 9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1237 | - 10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
|
| 1238 | - ); |
|
| 1239 | - } |
|
| 1240 | - |
|
| 1241 | - return $messages; |
|
| 1220 | + global $post, $post_ID; |
|
| 1221 | + |
|
| 1222 | + $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
|
|
| 1223 | + |
|
| 1224 | + foreach ($post_types as $post_type => $post_object) {
|
|
| 1225 | + |
|
| 1226 | + $messages[$post_type] = array( |
|
| 1227 | + 0 => '', // Unused. Messages start at index 1. |
|
| 1228 | + 1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1229 | + 2 => __('Custom field updated.', 'geodirectory'),
|
|
| 1230 | + 3 => __('Custom field deleted.', 'geodirectory'),
|
|
| 1231 | + 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1232 | + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
|
|
| 1233 | + 6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1234 | + 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1235 | + 8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
|
| 1236 | + 9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1237 | + 10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
|
| 1238 | + ); |
|
| 1239 | + } |
|
| 1240 | + |
|
| 1241 | + return $messages; |
|
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | |
@@ -1253,182 +1253,182 @@ discard block |
||
| 1253 | 1253 | function geodir_register_defaults() |
| 1254 | 1254 | {
|
| 1255 | 1255 | |
| 1256 | - global $wpdb; |
|
| 1257 | - |
|
| 1258 | - $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
| 1259 | - |
|
| 1260 | - if (!$listing_slug = get_option('geodir_listing_prefix'))
|
|
| 1261 | - $listing_slug = 'places'; |
|
| 1262 | - |
|
| 1263 | - /** |
|
| 1264 | - * Taxonomies |
|
| 1265 | - **/ |
|
| 1266 | - //if ( ! taxonomy_exists('gd_place_tags') )
|
|
| 1267 | - {
|
|
| 1268 | - |
|
| 1269 | - $gd_placetags = array(); |
|
| 1270 | - $gd_placetags['object_type'] = 'gd_place'; |
|
| 1271 | - $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
| 1272 | - $gd_placetags['args'] = array( |
|
| 1273 | - 'public' => true, |
|
| 1274 | - 'hierarchical' => false, |
|
| 1275 | - 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
|
|
| 1276 | - 'query_var' => true, |
|
| 1277 | - |
|
| 1278 | - 'labels' => array( |
|
| 1279 | - 'name' => __('Place Tags', 'geodirectory'),
|
|
| 1280 | - 'singular_name' => __('Place Tag', 'geodirectory'),
|
|
| 1281 | - 'search_items' => __('Search Place Tags', 'geodirectory'),
|
|
| 1282 | - 'popular_items' => __('Popular Place Tags', 'geodirectory'),
|
|
| 1283 | - 'all_items' => __('All Place Tags', 'geodirectory'),
|
|
| 1284 | - 'edit_item' => __('Edit Place Tag', 'geodirectory'),
|
|
| 1285 | - 'update_item' => __('Update Place Tag', 'geodirectory'),
|
|
| 1286 | - 'add_new_item' => __('Add New Place Tag', 'geodirectory'),
|
|
| 1287 | - 'new_item_name' => __('New Place Tag Name', 'geodirectory'),
|
|
| 1288 | - 'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
|
|
| 1289 | - 'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
|
|
| 1290 | - 'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
|
|
| 1291 | - ), |
|
| 1292 | - ); |
|
| 1293 | - |
|
| 1294 | - |
|
| 1295 | - $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1296 | - $geodir_taxonomies['gd_place_tags'] = $gd_placetags; |
|
| 1297 | - update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1298 | - |
|
| 1299 | - |
|
| 1300 | - // Update post types and delete tmp options |
|
| 1301 | - flush_rewrite_rules(); |
|
| 1302 | - |
|
| 1303 | - } |
|
| 1304 | - |
|
| 1305 | - //if ( ! taxonomy_exists('gd_placecategory') )
|
|
| 1306 | - {
|
|
| 1307 | - |
|
| 1308 | - $gd_placecategory = array(); |
|
| 1309 | - $gd_placecategory['object_type'] = 'gd_place'; |
|
| 1310 | - $gd_placecategory['listing_slug'] = $listing_slug; |
|
| 1311 | - $gd_placecategory['args'] = array( |
|
| 1312 | - 'public' => true, |
|
| 1313 | - 'hierarchical' => true, |
|
| 1314 | - 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
|
|
| 1315 | - 'query_var' => true, |
|
| 1316 | - 'labels' => array( |
|
| 1317 | - 'name' => __('Place Categories', 'geodirectory'),
|
|
| 1318 | - 'singular_name' => __('Place Category', 'geodirectory'),
|
|
| 1319 | - 'search_items' => __('Search Place Categories', 'geodirectory'),
|
|
| 1320 | - 'popular_items' => __('Popular Place Categories', 'geodirectory'),
|
|
| 1321 | - 'all_items' => __('All Place Categories', 'geodirectory'),
|
|
| 1322 | - 'edit_item' => __('Edit Place Category', 'geodirectory'),
|
|
| 1323 | - 'update_item' => __('Update Place Category', 'geodirectory'),
|
|
| 1324 | - 'add_new_item' => __('Add New Place Category', 'geodirectory'),
|
|
| 1325 | - 'new_item_name' => __('New Place Category', 'geodirectory'),
|
|
| 1326 | - 'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
|
|
| 1327 | - ), |
|
| 1328 | - ); |
|
| 1329 | - |
|
| 1330 | - |
|
| 1331 | - $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1332 | - $geodir_taxonomies['gd_placecategory'] = $gd_placecategory; |
|
| 1333 | - update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1334 | - |
|
| 1335 | - |
|
| 1336 | - flush_rewrite_rules(); |
|
| 1337 | - } |
|
| 1338 | - |
|
| 1339 | - /** |
|
| 1340 | - * Post Types |
|
| 1341 | - **/ |
|
| 1342 | - |
|
| 1343 | - //if ( ! post_type_exists('gd_place') )
|
|
| 1344 | - {
|
|
| 1345 | - |
|
| 1346 | - $labels = array( |
|
| 1347 | - 'name' => __('Places', 'geodirectory'),
|
|
| 1348 | - 'singular_name' => __('Place', 'geodirectory'),
|
|
| 1349 | - 'add_new' => __('Add New', 'geodirectory'),
|
|
| 1350 | - 'add_new_item' => __('Add New Place', 'geodirectory'),
|
|
| 1351 | - 'edit_item' => __('Edit Place', 'geodirectory'),
|
|
| 1352 | - 'new_item' => __('New Place', 'geodirectory'),
|
|
| 1353 | - 'view_item' => __('View Place', 'geodirectory'),
|
|
| 1354 | - 'search_items' => __('Search Places', 'geodirectory'),
|
|
| 1355 | - 'not_found' => __('No Place Found', 'geodirectory'),
|
|
| 1356 | - 'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
|
|
| 1357 | - |
|
| 1358 | - $place_default = array( |
|
| 1359 | - 'labels' => $labels, |
|
| 1360 | - 'can_export' => true, |
|
| 1361 | - 'capability_type' => 'post', |
|
| 1362 | - 'description' => 'Place post type.', |
|
| 1363 | - 'has_archive' => $listing_slug, |
|
| 1364 | - 'hierarchical' => false, |
|
| 1365 | - 'map_meta_cap' => true, |
|
| 1366 | - 'menu_icon' => $menu_icon, |
|
| 1367 | - 'public' => true, |
|
| 1368 | - 'query_var' => true, |
|
| 1369 | - 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
|
|
| 1370 | - 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
|
|
| 1371 | - 'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
|
|
| 1372 | - |
|
| 1373 | - //Update custom post types |
|
| 1374 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 1375 | - $geodir_post_types['gd_place'] = $place_default; |
|
| 1376 | - update_option('geodir_post_types', $geodir_post_types);
|
|
| 1377 | - |
|
| 1378 | - // Update post types and delete tmp options |
|
| 1379 | - flush_rewrite_rules(); |
|
| 1380 | - } |
|
| 1381 | - |
|
| 1382 | - |
|
| 1383 | - geodir_register_taxonomies(); |
|
| 1384 | - geodir_register_post_types(); |
|
| 1385 | - |
|
| 1386 | - //die; |
|
| 1256 | + global $wpdb; |
|
| 1257 | + |
|
| 1258 | + $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
| 1259 | + |
|
| 1260 | + if (!$listing_slug = get_option('geodir_listing_prefix'))
|
|
| 1261 | + $listing_slug = 'places'; |
|
| 1262 | + |
|
| 1263 | + /** |
|
| 1264 | + * Taxonomies |
|
| 1265 | + **/ |
|
| 1266 | + //if ( ! taxonomy_exists('gd_place_tags') )
|
|
| 1267 | + {
|
|
| 1268 | + |
|
| 1269 | + $gd_placetags = array(); |
|
| 1270 | + $gd_placetags['object_type'] = 'gd_place'; |
|
| 1271 | + $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
| 1272 | + $gd_placetags['args'] = array( |
|
| 1273 | + 'public' => true, |
|
| 1274 | + 'hierarchical' => false, |
|
| 1275 | + 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
|
|
| 1276 | + 'query_var' => true, |
|
| 1277 | + |
|
| 1278 | + 'labels' => array( |
|
| 1279 | + 'name' => __('Place Tags', 'geodirectory'),
|
|
| 1280 | + 'singular_name' => __('Place Tag', 'geodirectory'),
|
|
| 1281 | + 'search_items' => __('Search Place Tags', 'geodirectory'),
|
|
| 1282 | + 'popular_items' => __('Popular Place Tags', 'geodirectory'),
|
|
| 1283 | + 'all_items' => __('All Place Tags', 'geodirectory'),
|
|
| 1284 | + 'edit_item' => __('Edit Place Tag', 'geodirectory'),
|
|
| 1285 | + 'update_item' => __('Update Place Tag', 'geodirectory'),
|
|
| 1286 | + 'add_new_item' => __('Add New Place Tag', 'geodirectory'),
|
|
| 1287 | + 'new_item_name' => __('New Place Tag Name', 'geodirectory'),
|
|
| 1288 | + 'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
|
|
| 1289 | + 'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
|
|
| 1290 | + 'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
|
|
| 1291 | + ), |
|
| 1292 | + ); |
|
| 1293 | + |
|
| 1294 | + |
|
| 1295 | + $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1296 | + $geodir_taxonomies['gd_place_tags'] = $gd_placetags; |
|
| 1297 | + update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1298 | + |
|
| 1299 | + |
|
| 1300 | + // Update post types and delete tmp options |
|
| 1301 | + flush_rewrite_rules(); |
|
| 1302 | + |
|
| 1303 | + } |
|
| 1304 | + |
|
| 1305 | + //if ( ! taxonomy_exists('gd_placecategory') )
|
|
| 1306 | + {
|
|
| 1307 | + |
|
| 1308 | + $gd_placecategory = array(); |
|
| 1309 | + $gd_placecategory['object_type'] = 'gd_place'; |
|
| 1310 | + $gd_placecategory['listing_slug'] = $listing_slug; |
|
| 1311 | + $gd_placecategory['args'] = array( |
|
| 1312 | + 'public' => true, |
|
| 1313 | + 'hierarchical' => true, |
|
| 1314 | + 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
|
|
| 1315 | + 'query_var' => true, |
|
| 1316 | + 'labels' => array( |
|
| 1317 | + 'name' => __('Place Categories', 'geodirectory'),
|
|
| 1318 | + 'singular_name' => __('Place Category', 'geodirectory'),
|
|
| 1319 | + 'search_items' => __('Search Place Categories', 'geodirectory'),
|
|
| 1320 | + 'popular_items' => __('Popular Place Categories', 'geodirectory'),
|
|
| 1321 | + 'all_items' => __('All Place Categories', 'geodirectory'),
|
|
| 1322 | + 'edit_item' => __('Edit Place Category', 'geodirectory'),
|
|
| 1323 | + 'update_item' => __('Update Place Category', 'geodirectory'),
|
|
| 1324 | + 'add_new_item' => __('Add New Place Category', 'geodirectory'),
|
|
| 1325 | + 'new_item_name' => __('New Place Category', 'geodirectory'),
|
|
| 1326 | + 'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
|
|
| 1327 | + ), |
|
| 1328 | + ); |
|
| 1329 | + |
|
| 1330 | + |
|
| 1331 | + $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1332 | + $geodir_taxonomies['gd_placecategory'] = $gd_placecategory; |
|
| 1333 | + update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1334 | + |
|
| 1335 | + |
|
| 1336 | + flush_rewrite_rules(); |
|
| 1337 | + } |
|
| 1338 | + |
|
| 1339 | + /** |
|
| 1340 | + * Post Types |
|
| 1341 | + **/ |
|
| 1342 | + |
|
| 1343 | + //if ( ! post_type_exists('gd_place') )
|
|
| 1344 | + {
|
|
| 1345 | + |
|
| 1346 | + $labels = array( |
|
| 1347 | + 'name' => __('Places', 'geodirectory'),
|
|
| 1348 | + 'singular_name' => __('Place', 'geodirectory'),
|
|
| 1349 | + 'add_new' => __('Add New', 'geodirectory'),
|
|
| 1350 | + 'add_new_item' => __('Add New Place', 'geodirectory'),
|
|
| 1351 | + 'edit_item' => __('Edit Place', 'geodirectory'),
|
|
| 1352 | + 'new_item' => __('New Place', 'geodirectory'),
|
|
| 1353 | + 'view_item' => __('View Place', 'geodirectory'),
|
|
| 1354 | + 'search_items' => __('Search Places', 'geodirectory'),
|
|
| 1355 | + 'not_found' => __('No Place Found', 'geodirectory'),
|
|
| 1356 | + 'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
|
|
| 1357 | + |
|
| 1358 | + $place_default = array( |
|
| 1359 | + 'labels' => $labels, |
|
| 1360 | + 'can_export' => true, |
|
| 1361 | + 'capability_type' => 'post', |
|
| 1362 | + 'description' => 'Place post type.', |
|
| 1363 | + 'has_archive' => $listing_slug, |
|
| 1364 | + 'hierarchical' => false, |
|
| 1365 | + 'map_meta_cap' => true, |
|
| 1366 | + 'menu_icon' => $menu_icon, |
|
| 1367 | + 'public' => true, |
|
| 1368 | + 'query_var' => true, |
|
| 1369 | + 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
|
|
| 1370 | + 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
|
|
| 1371 | + 'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
|
|
| 1372 | + |
|
| 1373 | + //Update custom post types |
|
| 1374 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 1375 | + $geodir_post_types['gd_place'] = $place_default; |
|
| 1376 | + update_option('geodir_post_types', $geodir_post_types);
|
|
| 1377 | + |
|
| 1378 | + // Update post types and delete tmp options |
|
| 1379 | + flush_rewrite_rules(); |
|
| 1380 | + } |
|
| 1381 | + |
|
| 1382 | + |
|
| 1383 | + geodir_register_taxonomies(); |
|
| 1384 | + geodir_register_post_types(); |
|
| 1385 | + |
|
| 1386 | + //die; |
|
| 1387 | 1387 | |
| 1388 | 1388 | } |
| 1389 | 1389 | |
| 1390 | 1390 | $gd_wpml_get_languages = ""; |
| 1391 | 1391 | function gd_wpml_get_lang_from_url($url) {
|
| 1392 | - global $sitepress, $gd_wpml_get_languages; |
|
| 1392 | + global $sitepress, $gd_wpml_get_languages; |
|
| 1393 | 1393 | |
| 1394 | - if (geodir_is_wpml()) {
|
|
| 1395 | - return $sitepress->get_language_from_url($url); |
|
| 1396 | - } |
|
| 1394 | + if (geodir_is_wpml()) {
|
|
| 1395 | + return $sitepress->get_language_from_url($url); |
|
| 1396 | + } |
|
| 1397 | 1397 | |
| 1398 | - if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
|
|
| 1399 | - return $_REQUEST['lang']; |
|
| 1400 | - } |
|
| 1398 | + if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
|
|
| 1399 | + return $_REQUEST['lang']; |
|
| 1400 | + } |
|
| 1401 | 1401 | |
| 1402 | - $url = str_replace(array("http://","https://"),"",$url);
|
|
| 1402 | + $url = str_replace(array("http://","https://"),"",$url);
|
|
| 1403 | 1403 | |
| 1404 | - // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
|
|
| 1405 | - $site_url = str_replace(array("http://","https://"),"",site_url());
|
|
| 1404 | + // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
|
|
| 1405 | + $site_url = str_replace(array("http://","https://"),"",site_url());
|
|
| 1406 | 1406 | |
| 1407 | - $url = str_replace($site_url,"",$url); |
|
| 1407 | + $url = str_replace($site_url,"",$url); |
|
| 1408 | 1408 | |
| 1409 | - $segments = explode('/', trim($url, '/'));
|
|
| 1409 | + $segments = explode('/', trim($url, '/'));
|
|
| 1410 | 1410 | |
| 1411 | - if ($gd_wpml_get_languages) {
|
|
| 1412 | - $langs = $gd_wpml_get_languages; |
|
| 1413 | - } else {
|
|
| 1414 | - $gd_wpml_get_languages = $sitepress->get_active_languages(); |
|
| 1415 | - } |
|
| 1411 | + if ($gd_wpml_get_languages) {
|
|
| 1412 | + $langs = $gd_wpml_get_languages; |
|
| 1413 | + } else {
|
|
| 1414 | + $gd_wpml_get_languages = $sitepress->get_active_languages(); |
|
| 1415 | + } |
|
| 1416 | 1416 | |
| 1417 | - if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
|
|
| 1418 | - return $segments[0]; |
|
| 1419 | - } |
|
| 1417 | + if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
|
|
| 1418 | + return $segments[0]; |
|
| 1419 | + } |
|
| 1420 | 1420 | |
| 1421 | - return false; |
|
| 1421 | + return false; |
|
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | 1424 | function gd_wpml_slug_translation_turned_on($post_type) {
|
| 1425 | 1425 | |
| 1426 | - global $sitepress; |
|
| 1427 | - $settings = $sitepress->get_settings(); |
|
| 1428 | - return isset($settings['posts_slug_translation']['types'][$post_type]) |
|
| 1429 | - && $settings['posts_slug_translation']['types'][$post_type] |
|
| 1430 | - && isset($settings['posts_slug_translation']['on']) |
|
| 1431 | - && $settings['posts_slug_translation']['on']; |
|
| 1426 | + global $sitepress; |
|
| 1427 | + $settings = $sitepress->get_settings(); |
|
| 1428 | + return isset($settings['posts_slug_translation']['types'][$post_type]) |
|
| 1429 | + && $settings['posts_slug_translation']['types'][$post_type] |
|
| 1430 | + && isset($settings['posts_slug_translation']['on']) |
|
| 1431 | + && $settings['posts_slug_translation']['on']; |
|
| 1432 | 1432 | } |
| 1433 | 1433 | |
| 1434 | 1434 | |
@@ -1455,158 +1455,158 @@ discard block |
||
| 1455 | 1455 | */ |
| 1456 | 1456 | function geodir_listing_permalink_structure($post_link, $post_obj, $leavename, $sample) |
| 1457 | 1457 | {
|
| 1458 | - //echo $post_link."<br />".$sample ; |
|
| 1458 | + //echo $post_link."<br />".$sample ; |
|
| 1459 | 1459 | |
| 1460 | 1460 | |
| 1461 | - global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache; |
|
| 1462 | - if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
|
|
| 1463 | - } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
|
|
| 1464 | - return $post_link; |
|
| 1465 | - } else {
|
|
| 1466 | - $orig_post = $post; |
|
| 1467 | - $post = $post_obj; |
|
| 1468 | - } |
|
| 1461 | + global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache; |
|
| 1462 | + if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
|
|
| 1463 | + } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
|
|
| 1464 | + return $post_link; |
|
| 1465 | + } else {
|
|
| 1466 | + $orig_post = $post; |
|
| 1467 | + $post = $post_obj; |
|
| 1468 | + } |
|
| 1469 | 1469 | |
| 1470 | - if (in_array($post->post_type, geodir_get_posttypes())) {
|
|
| 1470 | + if (in_array($post->post_type, geodir_get_posttypes())) {
|
|
| 1471 | 1471 | |
| 1472 | - // if we dont have a GD post then try to grab it |
|
| 1473 | - if(!isset($post->default_category)){
|
|
| 1474 | - $gd_post = geodir_get_post_info($post->ID); |
|
| 1475 | - if(!empty($gd_post)){
|
|
| 1476 | - $post = $gd_post; |
|
| 1477 | - } |
|
| 1478 | - } |
|
| 1472 | + // if we dont have a GD post then try to grab it |
|
| 1473 | + if(!isset($post->default_category)){
|
|
| 1474 | + $gd_post = geodir_get_post_info($post->ID); |
|
| 1475 | + if(!empty($gd_post)){
|
|
| 1476 | + $post = $gd_post; |
|
| 1477 | + } |
|
| 1478 | + } |
|
| 1479 | 1479 | |
| 1480 | 1480 | |
| 1481 | - $post_types = get_option('geodir_post_types');
|
|
| 1482 | - $slug = $post_types[$post->post_type]['rewrite']['slug']; |
|
| 1481 | + $post_types = get_option('geodir_post_types');
|
|
| 1482 | + $slug = $post_types[$post->post_type]['rewrite']['slug']; |
|
| 1483 | 1483 | |
| 1484 | - // Alter the CPT slug if WPML is set to do so |
|
| 1485 | - if(geodir_wpml_is_post_type_translated($post->post_type)){
|
|
| 1486 | - if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
|
|
| 1484 | + // Alter the CPT slug if WPML is set to do so |
|
| 1485 | + if(geodir_wpml_is_post_type_translated($post->post_type)){
|
|
| 1486 | + if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
|
|
| 1487 | 1487 | |
| 1488 | - $org_slug = $slug; |
|
| 1489 | - $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1490 | - $slug, |
|
| 1491 | - 'WordPress', |
|
| 1492 | - 'URL slug: ' . $slug, |
|
| 1493 | - $language_code); |
|
| 1488 | + $org_slug = $slug; |
|
| 1489 | + $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1490 | + $slug, |
|
| 1491 | + 'WordPress', |
|
| 1492 | + 'URL slug: ' . $slug, |
|
| 1493 | + $language_code); |
|
| 1494 | 1494 | |
| 1495 | - if(!$slug){$slug = $org_slug;}
|
|
| 1495 | + if(!$slug){$slug = $org_slug;}
|
|
| 1496 | 1496 | |
| 1497 | - } |
|
| 1498 | - } |
|
| 1497 | + } |
|
| 1498 | + } |
|
| 1499 | 1499 | |
| 1500 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1501 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 1502 | - } |
|
| 1500 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1501 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 1502 | + } |
|
| 1503 | 1503 | |
| 1504 | - // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz. |
|
| 1505 | - $site_url = trailingslashit(get_bloginfo('url'));
|
|
| 1504 | + // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz. |
|
| 1505 | + $site_url = trailingslashit(get_bloginfo('url'));
|
|
| 1506 | 1506 | |
| 1507 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1508 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 1509 | - } |
|
| 1510 | - |
|
| 1511 | - $fix_url = strpos($post_link, $site_url) === 0 ? true : false; |
|
| 1512 | - if ($fix_url) {
|
|
| 1513 | - $post_link = str_replace($site_url, '', $post_link); |
|
| 1514 | - } |
|
| 1515 | - |
|
| 1516 | - $post_link = trailingslashit( |
|
| 1517 | - preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
| 1518 | - ); |
|
| 1519 | - |
|
| 1520 | - if ($fix_url) {
|
|
| 1521 | - $post_link = $site_url . $post_link; |
|
| 1522 | - } |
|
| 1523 | - |
|
| 1524 | - if (isset($comment_post_cache[$post->ID])) {
|
|
| 1525 | - $post = $comment_post_cache[$post->ID]; |
|
| 1526 | - } |
|
| 1527 | - if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
|
|
| 1528 | - $post_id = $post->ID; |
|
| 1529 | - if (isset($orig_post)) {
|
|
| 1530 | - $post = $orig_post; |
|
| 1531 | - } |
|
| 1532 | - return $gd_permalink_cache[$post_id]; |
|
| 1533 | - } |
|
| 1507 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1508 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 1509 | + } |
|
| 1534 | 1510 | |
| 1535 | - if (!isset($post->post_locations)) {
|
|
| 1536 | - $post_type = $post->post_type; |
|
| 1537 | - $ID = $post->ID; |
|
| 1538 | - $post2 = $wpdb->get_row( |
|
| 1539 | - $wpdb->prepare( |
|
| 1540 | - "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1541 | - array($post->ID) |
|
| 1542 | - ) |
|
| 1543 | - ); |
|
| 1511 | + $fix_url = strpos($post_link, $site_url) === 0 ? true : false; |
|
| 1512 | + if ($fix_url) {
|
|
| 1513 | + $post_link = str_replace($site_url, '', $post_link); |
|
| 1514 | + } |
|
| 1544 | 1515 | |
| 1545 | - $post = (object)array_merge((array)$post, (array)$post2); |
|
| 1516 | + $post_link = trailingslashit( |
|
| 1517 | + preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
| 1518 | + ); |
|
| 1546 | 1519 | |
| 1547 | - $comment_post_cache[$post->ID] = $post; |
|
| 1548 | - } |
|
| 1520 | + if ($fix_url) {
|
|
| 1521 | + $post_link = $site_url . $post_link; |
|
| 1522 | + } |
|
| 1549 | 1523 | |
| 1524 | + if (isset($comment_post_cache[$post->ID])) {
|
|
| 1525 | + $post = $comment_post_cache[$post->ID]; |
|
| 1526 | + } |
|
| 1527 | + if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
|
|
| 1528 | + $post_id = $post->ID; |
|
| 1529 | + if (isset($orig_post)) {
|
|
| 1530 | + $post = $orig_post; |
|
| 1531 | + } |
|
| 1532 | + return $gd_permalink_cache[$post_id]; |
|
| 1533 | + } |
|
| 1550 | 1534 | |
| 1535 | + if (!isset($post->post_locations)) {
|
|
| 1536 | + $post_type = $post->post_type; |
|
| 1537 | + $ID = $post->ID; |
|
| 1538 | + $post2 = $wpdb->get_row( |
|
| 1539 | + $wpdb->prepare( |
|
| 1540 | + "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1541 | + array($post->ID) |
|
| 1542 | + ) |
|
| 1543 | + ); |
|
| 1551 | 1544 | |
| 1552 | - if (false !== strpos($post_link, '%gd_taxonomy%')) {
|
|
| 1545 | + $post = (object)array_merge((array)$post, (array)$post2); |
|
| 1553 | 1546 | |
| 1554 | - if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
|
|
| 1555 | - $location_request = ''; |
|
| 1547 | + $comment_post_cache[$post->ID] = $post; |
|
| 1548 | + } |
|
| 1556 | 1549 | |
| 1557 | 1550 | |
| 1558 | - if (!empty($post->post_locations)) {
|
|
| 1559 | - $geodir_arr_locations = explode(',', $post->post_locations);
|
|
| 1560 | - if (count($geodir_arr_locations) == 3) {
|
|
| 1561 | - $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1562 | - $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1563 | - $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1564 | - $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1565 | - $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1566 | - $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1567 | 1551 | |
| 1568 | - $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1569 | - 'region_slug' => $post->region_slug, |
|
| 1570 | - 'city_slug' => $post->city_slug |
|
| 1571 | - ); |
|
| 1552 | + if (false !== strpos($post_link, '%gd_taxonomy%')) {
|
|
| 1572 | 1553 | |
| 1573 | - } else |
|
| 1574 | - $post_location = geodir_get_location(); |
|
| 1554 | + if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
|
|
| 1555 | + $location_request = ''; |
|
| 1575 | 1556 | |
| 1576 | 1557 | |
| 1577 | - } else {
|
|
| 1558 | + if (!empty($post->post_locations)) {
|
|
| 1559 | + $geodir_arr_locations = explode(',', $post->post_locations);
|
|
| 1560 | + if (count($geodir_arr_locations) == 3) {
|
|
| 1561 | + $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1562 | + $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1563 | + $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1564 | + $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1565 | + $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1566 | + $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1578 | 1567 | |
| 1579 | - $post_location_sql = $wpdb->get_results( |
|
| 1580 | - $wpdb->prepare( |
|
| 1581 | - "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1582 | - array($post->ID) |
|
| 1583 | - ) |
|
| 1584 | - ); |
|
| 1585 | - |
|
| 1586 | - if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
|
|
| 1587 | - |
|
| 1588 | - $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
|
|
| 1589 | - if (count($geodir_arr_locations) == 3) {
|
|
| 1590 | - $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1591 | - $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1592 | - $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1593 | - $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1594 | - $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1595 | - $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1596 | - |
|
| 1597 | - $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1598 | - 'region_slug' => $post->region_slug, |
|
| 1599 | - 'city_slug' => $post->city_slug |
|
| 1600 | - ); |
|
| 1568 | + $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1569 | + 'region_slug' => $post->region_slug, |
|
| 1570 | + 'city_slug' => $post->city_slug |
|
| 1571 | + ); |
|
| 1572 | + |
|
| 1573 | + } else |
|
| 1574 | + $post_location = geodir_get_location(); |
|
| 1601 | 1575 | |
| 1602 | - } |
|
| 1603 | - } else |
|
| 1604 | - $post_location = geodir_get_location(); |
|
| 1605 | - } |
|
| 1606 | 1576 | |
| 1577 | + } else {
|
|
| 1607 | 1578 | |
| 1608 | - if (!empty($post_location)) {
|
|
| 1609 | - $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : ''; |
|
| 1579 | + $post_location_sql = $wpdb->get_results( |
|
| 1580 | + $wpdb->prepare( |
|
| 1581 | + "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1582 | + array($post->ID) |
|
| 1583 | + ) |
|
| 1584 | + ); |
|
| 1585 | + |
|
| 1586 | + if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
|
|
| 1587 | + |
|
| 1588 | + $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
|
|
| 1589 | + if (count($geodir_arr_locations) == 3) {
|
|
| 1590 | + $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1591 | + $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1592 | + $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1593 | + $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1594 | + $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1595 | + $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1596 | + |
|
| 1597 | + $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1598 | + 'region_slug' => $post->region_slug, |
|
| 1599 | + 'city_slug' => $post->city_slug |
|
| 1600 | + ); |
|
| 1601 | + |
|
| 1602 | + } |
|
| 1603 | + } else |
|
| 1604 | + $post_location = geodir_get_location(); |
|
| 1605 | + } |
|
| 1606 | + |
|
| 1607 | + |
|
| 1608 | + if (!empty($post_location)) {
|
|
| 1609 | + $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : ''; |
|
| 1610 | 1610 | $region_slug = isset($post_location->region_slug) ? $post_location->region_slug : ''; |
| 1611 | 1611 | $city_slug = isset($post_location->city_slug) ? $post_location->city_slug : ''; |
| 1612 | 1612 | |
@@ -1624,89 +1624,89 @@ discard block |
||
| 1624 | 1624 | $location_slug[] = $city_slug; |
| 1625 | 1625 | |
| 1626 | 1626 | $location_request .= implode('/', $location_slug) . '/';
|
| 1627 | - } |
|
| 1628 | - } |
|
| 1627 | + } |
|
| 1628 | + } |
|
| 1629 | 1629 | |
| 1630 | - if (get_option('geodir_add_categories_url')) {
|
|
| 1630 | + if (get_option('geodir_add_categories_url')) {
|
|
| 1631 | 1631 | |
| 1632 | - $term_request = ''; |
|
| 1633 | - $taxonomies = geodir_get_taxonomies($post->post_type); |
|
| 1632 | + $term_request = ''; |
|
| 1633 | + $taxonomies = geodir_get_taxonomies($post->post_type); |
|
| 1634 | 1634 | |
| 1635 | - $taxonomies = end($taxonomies); |
|
| 1635 | + $taxonomies = end($taxonomies); |
|
| 1636 | 1636 | |
| 1637 | - if (!empty($post->default_category)) {
|
|
| 1638 | - $post_terms = $post->default_category; |
|
| 1639 | - } else {
|
|
| 1640 | - $post_terms = ''; |
|
| 1641 | - |
|
| 1642 | - if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
|
|
| 1643 | - $post_terms = absint($_POST['post_default_category']); |
|
| 1644 | - }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
|
|
| 1645 | - $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
|
|
| 1646 | - $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0; |
|
| 1647 | - }elseif (isset($post->{$taxonomies})) {
|
|
| 1648 | - $post_terms = explode(",", trim($post->{$taxonomies}, ","));
|
|
| 1649 | - $post_terms = $post_terms[0]; |
|
| 1650 | - } |
|
| 1637 | + if (!empty($post->default_category)) {
|
|
| 1638 | + $post_terms = $post->default_category; |
|
| 1639 | + } else {
|
|
| 1640 | + $post_terms = ''; |
|
| 1641 | + |
|
| 1642 | + if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
|
|
| 1643 | + $post_terms = absint($_POST['post_default_category']); |
|
| 1644 | + }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
|
|
| 1645 | + $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
|
|
| 1646 | + $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0; |
|
| 1647 | + }elseif (isset($post->{$taxonomies})) {
|
|
| 1648 | + $post_terms = explode(",", trim($post->{$taxonomies}, ","));
|
|
| 1649 | + $post_terms = $post_terms[0]; |
|
| 1650 | + } |
|
| 1651 | 1651 | |
| 1652 | - if (!$post_terms) |
|
| 1653 | - $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1652 | + if (!$post_terms) |
|
| 1653 | + $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1654 | 1654 | |
| 1655 | - if (!$post_terms) {
|
|
| 1656 | - $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
|
| 1655 | + if (!$post_terms) {
|
|
| 1656 | + $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
|
| 1657 | 1657 | |
| 1658 | - if ($post_terms) {
|
|
| 1659 | - $post_terms = explode(",", trim($post_terms, ","));
|
|
| 1660 | - $post_terms = $post_terms[0]; |
|
| 1661 | - } |
|
| 1662 | - } |
|
| 1663 | - } |
|
| 1658 | + if ($post_terms) {
|
|
| 1659 | + $post_terms = explode(",", trim($post_terms, ","));
|
|
| 1660 | + $post_terms = $post_terms[0]; |
|
| 1661 | + } |
|
| 1662 | + } |
|
| 1663 | + } |
|
| 1664 | 1664 | |
| 1665 | - $term = get_term_by('id', $post_terms, $taxonomies);
|
|
| 1665 | + $term = get_term_by('id', $post_terms, $taxonomies);
|
|
| 1666 | 1666 | |
| 1667 | - if (!empty($term)) |
|
| 1668 | - $term_request = $term->slug; |
|
| 1669 | - //$term_request = $term->slug.'/'; |
|
| 1670 | - } |
|
| 1667 | + if (!empty($term)) |
|
| 1668 | + $term_request = $term->slug; |
|
| 1669 | + //$term_request = $term->slug.'/'; |
|
| 1670 | + } |
|
| 1671 | 1671 | |
| 1672 | - $request_term = ''; |
|
| 1673 | - $listingurl_separator = ''; |
|
| 1674 | - //$detailurl_separator = get_option('geodir_detailurl_separator');
|
|
| 1675 | - $detailurl_separator = ''; |
|
| 1676 | - if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
|
|
| 1677 | - $request_term = $location_request; |
|
| 1678 | - //$listingurl_separator = get_option('geodir_listingurl_separator');
|
|
| 1679 | - //$request_term .= $listingurl_separator.'/'.$term_request; |
|
| 1680 | - $request_term .= $term_request; |
|
| 1672 | + $request_term = ''; |
|
| 1673 | + $listingurl_separator = ''; |
|
| 1674 | + //$detailurl_separator = get_option('geodir_detailurl_separator');
|
|
| 1675 | + $detailurl_separator = ''; |
|
| 1676 | + if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
|
|
| 1677 | + $request_term = $location_request; |
|
| 1678 | + //$listingurl_separator = get_option('geodir_listingurl_separator');
|
|
| 1679 | + //$request_term .= $listingurl_separator.'/'.$term_request; |
|
| 1680 | + $request_term .= $term_request; |
|
| 1681 | 1681 | |
| 1682 | - } else {
|
|
| 1683 | - if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
| 1682 | + } else {
|
|
| 1683 | + if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
| 1684 | 1684 | |
| 1685 | - if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
| 1686 | - } |
|
| 1687 | - $request_term = trim($request_term, '/'); |
|
| 1685 | + if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
| 1686 | + } |
|
| 1687 | + $request_term = trim($request_term, '/'); |
|
| 1688 | 1688 | |
| 1689 | - // Fix with WPML the location terms added twice when CPT slug is translated. |
|
| 1690 | - if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
|
|
| 1691 | - $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
|
|
| 1692 | - } |
|
| 1689 | + // Fix with WPML the location terms added twice when CPT slug is translated. |
|
| 1690 | + if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
|
|
| 1691 | + $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
|
|
| 1692 | + } |
|
| 1693 | 1693 | |
| 1694 | - if (!empty($request_term)) |
|
| 1695 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1696 | - else |
|
| 1697 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1698 | - //echo $post_link ; |
|
| 1699 | - } |
|
| 1700 | - // temp cache the permalink |
|
| 1701 | - if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
|
|
| 1702 | - $gd_permalink_cache[$post->ID] = $post_link; |
|
| 1703 | - } |
|
| 1704 | - } |
|
| 1705 | - if (isset($orig_post)) {
|
|
| 1706 | - $post = $orig_post; |
|
| 1707 | - } |
|
| 1708 | - |
|
| 1709 | - return $post_link; |
|
| 1694 | + if (!empty($request_term)) |
|
| 1695 | + $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1696 | + else |
|
| 1697 | + $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1698 | + //echo $post_link ; |
|
| 1699 | + } |
|
| 1700 | + // temp cache the permalink |
|
| 1701 | + if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
|
|
| 1702 | + $gd_permalink_cache[$post->ID] = $post_link; |
|
| 1703 | + } |
|
| 1704 | + } |
|
| 1705 | + if (isset($orig_post)) {
|
|
| 1706 | + $post = $orig_post; |
|
| 1707 | + } |
|
| 1708 | + |
|
| 1709 | + return $post_link; |
|
| 1710 | 1710 | } |
| 1711 | 1711 | |
| 1712 | 1712 | /** |
@@ -1722,99 +1722,99 @@ discard block |
||
| 1722 | 1722 | * @return string The term link. |
| 1723 | 1723 | */ |
| 1724 | 1724 | function geodir_term_link($termlink, $term, $taxonomy) {
|
| 1725 | - $geodir_taxonomies = geodir_get_taxonomies('', true);
|
|
| 1725 | + $geodir_taxonomies = geodir_get_taxonomies('', true);
|
|
| 1726 | 1726 | |
| 1727 | - if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
|
|
| 1728 | - global $geodir_add_location_url, $gd_session; |
|
| 1729 | - $include_location = false; |
|
| 1730 | - $request_term = array(); |
|
| 1731 | - $add_location_url = get_option('geodir_add_location_url');
|
|
| 1732 | - $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 1727 | + if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
|
|
| 1728 | + global $geodir_add_location_url, $gd_session; |
|
| 1729 | + $include_location = false; |
|
| 1730 | + $request_term = array(); |
|
| 1731 | + $add_location_url = get_option('geodir_add_location_url');
|
|
| 1732 | + $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 1733 | 1733 | |
| 1734 | - $listing_slug = geodir_get_listing_slug($taxonomy); |
|
| 1734 | + $listing_slug = geodir_get_listing_slug($taxonomy); |
|
| 1735 | 1735 | |
| 1736 | - if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
|
|
| 1737 | - if ($geodir_add_location_url && $add_location_url) {
|
|
| 1738 | - $include_location = true; |
|
| 1739 | - } |
|
| 1740 | - } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
|
|
| 1741 | - $include_location = true; |
|
| 1742 | - } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
|
|
| 1743 | - $include_location = true; |
|
| 1744 | - } |
|
| 1745 | - |
|
| 1746 | - if ($include_location) {
|
|
| 1747 | - global $post; |
|
| 1736 | + if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
|
|
| 1737 | + if ($geodir_add_location_url && $add_location_url) {
|
|
| 1738 | + $include_location = true; |
|
| 1739 | + } |
|
| 1740 | + } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
|
|
| 1741 | + $include_location = true; |
|
| 1742 | + } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
|
|
| 1743 | + $include_location = true; |
|
| 1744 | + } |
|
| 1745 | + |
|
| 1746 | + if ($include_location) {
|
|
| 1747 | + global $post; |
|
| 1748 | 1748 | |
| 1749 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 1749 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 1750 | 1750 | |
| 1751 | - if (geodir_is_page('detail') && isset($post->country_slug)) {
|
|
| 1752 | - $location_terms = array( |
|
| 1753 | - 'gd_country' => $post->country_slug, |
|
| 1754 | - 'gd_region' => $post->region_slug, |
|
| 1755 | - 'gd_city' => $post->city_slug |
|
| 1756 | - ); |
|
| 1751 | + if (geodir_is_page('detail') && isset($post->country_slug)) {
|
|
| 1752 | + $location_terms = array( |
|
| 1753 | + 'gd_country' => $post->country_slug, |
|
| 1754 | + 'gd_region' => $post->region_slug, |
|
| 1755 | + 'gd_city' => $post->city_slug |
|
| 1756 | + ); |
|
| 1757 | 1757 | |
| 1758 | - if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
|
| 1759 | - $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
| 1760 | - } |
|
| 1761 | - } else {
|
|
| 1762 | - $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1763 | - } |
|
| 1758 | + if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
|
| 1759 | + $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
| 1760 | + } |
|
| 1761 | + } else {
|
|
| 1762 | + $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1763 | + } |
|
| 1764 | 1764 | |
| 1765 | - $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 1766 | - $location_terms = geodir_remove_location_terms($location_terms); |
|
| 1765 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 1766 | + $location_terms = geodir_remove_location_terms($location_terms); |
|
| 1767 | 1767 | |
| 1768 | - if (!empty($location_terms)) {
|
|
| 1769 | - $url_separator = ''; |
|
| 1768 | + if (!empty($location_terms)) {
|
|
| 1769 | + $url_separator = ''; |
|
| 1770 | 1770 | |
| 1771 | - if (get_option('permalink_structure') != '') {
|
|
| 1772 | - $old_listing_slug = '/' . $listing_slug . '/'; |
|
| 1773 | - $request_term = implode("/", $location_terms);
|
|
| 1774 | - $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
| 1771 | + if (get_option('permalink_structure') != '') {
|
|
| 1772 | + $old_listing_slug = '/' . $listing_slug . '/'; |
|
| 1773 | + $request_term = implode("/", $location_terms);
|
|
| 1774 | + $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
| 1775 | 1775 | |
| 1776 | - $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
|
| 1777 | - } else {
|
|
| 1778 | - $termlink = geodir_getlink($termlink, $request_term); |
|
| 1779 | - } |
|
| 1780 | - } |
|
| 1781 | - } |
|
| 1776 | + $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
|
| 1777 | + } else {
|
|
| 1778 | + $termlink = geodir_getlink($termlink, $request_term); |
|
| 1779 | + } |
|
| 1780 | + } |
|
| 1781 | + } |
|
| 1782 | 1782 | |
| 1783 | - // Alter the CPT slug is WPML is set to do so |
|
| 1784 | - /* we can replace this with the below function |
|
| 1783 | + // Alter the CPT slug is WPML is set to do so |
|
| 1784 | + /* we can replace this with the below function |
|
| 1785 | 1785 | if(geodir_is_wpml()){
|
| 1786 | 1786 | global $sitepress; |
| 1787 | 1787 | $post_type = str_replace("category","",$taxonomy);
|
| 1788 | 1788 | $termlink = $sitepress->post_type_archive_link_filter( $termlink, $post_type); |
| 1789 | 1789 | }*/ |
| 1790 | 1790 | |
| 1791 | - // Alter the CPT slug if WPML is set to do so |
|
| 1792 | - if (geodir_is_wpml()) {
|
|
| 1793 | - $post_types = get_option('geodir_post_types');
|
|
| 1794 | - $post_type = str_replace("category","",$taxonomy);
|
|
| 1795 | - $post_type = str_replace("_tags","",$post_type);
|
|
| 1796 | - $slug = $post_types[$post_type]['rewrite']['slug']; |
|
| 1797 | - if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) {
|
|
| 1798 | - global $sitepress; |
|
| 1799 | - $default_lang = $sitepress->get_default_language(); |
|
| 1800 | - $language_code = gd_wpml_get_lang_from_url($termlink); |
|
| 1801 | - if (!$language_code ) {
|
|
| 1802 | - $language_code = $default_lang; |
|
| 1803 | - } |
|
| 1791 | + // Alter the CPT slug if WPML is set to do so |
|
| 1792 | + if (geodir_is_wpml()) {
|
|
| 1793 | + $post_types = get_option('geodir_post_types');
|
|
| 1794 | + $post_type = str_replace("category","",$taxonomy);
|
|
| 1795 | + $post_type = str_replace("_tags","",$post_type);
|
|
| 1796 | + $slug = $post_types[$post_type]['rewrite']['slug']; |
|
| 1797 | + if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) {
|
|
| 1798 | + global $sitepress; |
|
| 1799 | + $default_lang = $sitepress->get_default_language(); |
|
| 1800 | + $language_code = gd_wpml_get_lang_from_url($termlink); |
|
| 1801 | + if (!$language_code ) {
|
|
| 1802 | + $language_code = $default_lang; |
|
| 1803 | + } |
|
| 1804 | 1804 | |
| 1805 | - $org_slug = $slug; |
|
| 1806 | - $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
|
|
| 1805 | + $org_slug = $slug; |
|
| 1806 | + $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
|
|
| 1807 | 1807 | |
| 1808 | - if (!$slug) {
|
|
| 1809 | - $slug = $org_slug; |
|
| 1810 | - } |
|
| 1808 | + if (!$slug) {
|
|
| 1809 | + $slug = $org_slug; |
|
| 1810 | + } |
|
| 1811 | 1811 | |
| 1812 | - $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1));
|
|
| 1813 | - } |
|
| 1814 | - } |
|
| 1815 | - } |
|
| 1812 | + $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1));
|
|
| 1813 | + } |
|
| 1814 | + } |
|
| 1815 | + } |
|
| 1816 | 1816 | |
| 1817 | - return $termlink; |
|
| 1817 | + return $termlink; |
|
| 1818 | 1818 | } |
| 1819 | 1819 | |
| 1820 | 1820 | /** |
@@ -1840,14 +1840,14 @@ discard block |
||
| 1840 | 1840 | if (in_array($post_type, geodir_get_posttypes())) {
|
| 1841 | 1841 | if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
|
| 1842 | 1842 | if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
|
| 1843 | - $location_terms = array( |
|
| 1844 | - 'gd_country' => $post->country_slug, |
|
| 1845 | - 'gd_region' => $post->region_slug, |
|
| 1846 | - 'gd_city' => $post->city_slug |
|
| 1847 | - ); |
|
| 1848 | - } else {
|
|
| 1849 | - $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1850 | - } |
|
| 1843 | + $location_terms = array( |
|
| 1844 | + 'gd_country' => $post->country_slug, |
|
| 1845 | + 'gd_region' => $post->region_slug, |
|
| 1846 | + 'gd_city' => $post->city_slug |
|
| 1847 | + ); |
|
| 1848 | + } else {
|
|
| 1849 | + $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1850 | + } |
|
| 1851 | 1851 | |
| 1852 | 1852 | $location_terms = geodir_remove_location_terms($location_terms); |
| 1853 | 1853 | |
@@ -1879,17 +1879,17 @@ discard block |
||
| 1879 | 1879 | * @return void|string Label. |
| 1880 | 1880 | */ |
| 1881 | 1881 | function get_post_type_singular_label($post_type, $echo = false, $translate = false) {
|
| 1882 | - $obj_post_type = get_post_type_object($post_type); |
|
| 1883 | - if (!is_object($obj_post_type)) {
|
|
| 1884 | - return; |
|
| 1885 | - } |
|
| 1882 | + $obj_post_type = get_post_type_object($post_type); |
|
| 1883 | + if (!is_object($obj_post_type)) {
|
|
| 1884 | + return; |
|
| 1885 | + } |
|
| 1886 | 1886 | |
| 1887 | - $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
|
| 1887 | + $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
|
| 1888 | 1888 | |
| 1889 | - if ($echo) |
|
| 1890 | - echo $label; |
|
| 1891 | - else |
|
| 1892 | - return $label; |
|
| 1889 | + if ($echo) |
|
| 1890 | + echo $label; |
|
| 1891 | + else |
|
| 1892 | + return $label; |
|
| 1893 | 1893 | } |
| 1894 | 1894 | |
| 1895 | 1895 | /** |
@@ -1904,19 +1904,19 @@ discard block |
||
| 1904 | 1904 | * @return void|string Label. |
| 1905 | 1905 | */ |
| 1906 | 1906 | function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
|
| 1907 | - $all_postypes = geodir_get_posttypes(); |
|
| 1907 | + $all_postypes = geodir_get_posttypes(); |
|
| 1908 | 1908 | |
| 1909 | - if (!in_array($post_type, $all_postypes)) |
|
| 1910 | - return false; |
|
| 1909 | + if (!in_array($post_type, $all_postypes)) |
|
| 1910 | + return false; |
|
| 1911 | 1911 | |
| 1912 | - $obj_post_type = get_post_type_object($post_type); |
|
| 1912 | + $obj_post_type = get_post_type_object($post_type); |
|
| 1913 | 1913 | |
| 1914 | - $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
|
| 1914 | + $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
|
| 1915 | 1915 | |
| 1916 | - if ($echo) |
|
| 1917 | - echo $label; |
|
| 1918 | - else |
|
| 1919 | - return $label; |
|
| 1916 | + if ($echo) |
|
| 1917 | + echo $label; |
|
| 1918 | + else |
|
| 1919 | + return $label; |
|
| 1920 | 1920 | } |
| 1921 | 1921 | |
| 1922 | 1922 | /** |
@@ -1934,51 +1934,51 @@ discard block |
||
| 1934 | 1934 | */ |
| 1935 | 1935 | function geodir_term_exists($term, $taxonomy = '', $parent = 0) |
| 1936 | 1936 | {
|
| 1937 | - global $wpdb; |
|
| 1938 | - |
|
| 1939 | - $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
|
| 1940 | - $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
|
| 1941 | - |
|
| 1942 | - if (is_int($term)) {
|
|
| 1943 | - if (0 == $term) |
|
| 1944 | - return 0; |
|
| 1945 | - $where = 't.term_id = %d'; |
|
| 1946 | - if (!empty($taxonomy)) |
|
| 1947 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1948 | - else |
|
| 1949 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1950 | - } |
|
| 1937 | + global $wpdb; |
|
| 1938 | + |
|
| 1939 | + $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
|
| 1940 | + $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
|
| 1941 | + |
|
| 1942 | + if (is_int($term)) {
|
|
| 1943 | + if (0 == $term) |
|
| 1944 | + return 0; |
|
| 1945 | + $where = 't.term_id = %d'; |
|
| 1946 | + if (!empty($taxonomy)) |
|
| 1947 | + return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1948 | + else |
|
| 1949 | + return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1950 | + } |
|
| 1951 | 1951 | |
| 1952 | - $term = trim(wp_unslash($term)); |
|
| 1952 | + $term = trim(wp_unslash($term)); |
|
| 1953 | 1953 | |
| 1954 | - if ('' === $slug = sanitize_title($term))
|
|
| 1955 | - return 0; |
|
| 1954 | + if ('' === $slug = sanitize_title($term))
|
|
| 1955 | + return 0; |
|
| 1956 | 1956 | |
| 1957 | - $where = 't.slug = %s'; |
|
| 1957 | + $where = 't.slug = %s'; |
|
| 1958 | 1958 | |
| 1959 | - $where_fields = array($slug); |
|
| 1960 | - if (!empty($taxonomy)) {
|
|
| 1961 | - $parent = (int)$parent; |
|
| 1962 | - if ($parent > 0) {
|
|
| 1963 | - $where_fields[] = $parent; |
|
| 1964 | - $else_where_fields[] = $parent; |
|
| 1965 | - $where .= ' AND tt.parent = %d'; |
|
| 1959 | + $where_fields = array($slug); |
|
| 1960 | + if (!empty($taxonomy)) {
|
|
| 1961 | + $parent = (int)$parent; |
|
| 1962 | + if ($parent > 0) {
|
|
| 1963 | + $where_fields[] = $parent; |
|
| 1964 | + $else_where_fields[] = $parent; |
|
| 1965 | + $where .= ' AND tt.parent = %d'; |
|
| 1966 | 1966 | |
| 1967 | - } |
|
| 1967 | + } |
|
| 1968 | 1968 | |
| 1969 | - $where_fields[] = $taxonomy; |
|
| 1969 | + $where_fields[] = $taxonomy; |
|
| 1970 | 1970 | |
| 1971 | 1971 | |
| 1972 | - if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
|
|
| 1973 | - return $result; |
|
| 1972 | + if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
|
|
| 1973 | + return $result; |
|
| 1974 | 1974 | |
| 1975 | - return false; |
|
| 1976 | - } |
|
| 1975 | + return false; |
|
| 1976 | + } |
|
| 1977 | 1977 | |
| 1978 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
|
|
| 1979 | - return $result; |
|
| 1978 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
|
|
| 1979 | + return $result; |
|
| 1980 | 1980 | |
| 1981 | - return false; |
|
| 1981 | + return false; |
|
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | 1984 | /** |
@@ -1990,7 +1990,7 @@ discard block |
||
| 1990 | 1990 | function geodir_get_term_icon_rebuild() |
| 1991 | 1991 | {
|
| 1992 | 1992 | |
| 1993 | - update_option('gd_term_icons', '');
|
|
| 1993 | + update_option('gd_term_icons', '');
|
|
| 1994 | 1994 | |
| 1995 | 1995 | } |
| 1996 | 1996 | |
@@ -2008,61 +2008,61 @@ discard block |
||
| 2008 | 2008 | */ |
| 2009 | 2009 | function geodir_get_term_icon($term_id = false, $rebuild = false) |
| 2010 | 2010 | {
|
| 2011 | - global $wpdb; |
|
| 2012 | - if (!$rebuild) {
|
|
| 2013 | - $terms_icons = get_option('gd_term_icons');
|
|
| 2014 | - } else {
|
|
| 2015 | - $terms_icons = array(); |
|
| 2016 | - } |
|
| 2017 | - |
|
| 2018 | - if (empty($terms_icons)) {
|
|
| 2019 | - $terms_icons = array(); |
|
| 2020 | - $default_icon_url = get_option('geodir_default_marker_icon');
|
|
| 2021 | - $taxonomy = geodir_get_taxonomies(); |
|
| 2022 | - $post_types = geodir_get_posttypes(); |
|
| 2023 | - $tax_arr = array(); |
|
| 2024 | - foreach ($post_types as $post_type) {
|
|
| 2025 | - $tax_arr[] = "'" . $post_type . "category'"; |
|
| 2026 | - } |
|
| 2027 | - $tax_c = implode(',', $tax_arr);
|
|
| 2028 | - $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
|
|
| 2029 | - //$terms = get_terms( $taxonomy ); |
|
| 2030 | - |
|
| 2031 | - if($terms) {
|
|
| 2032 | - foreach ($terms as $term) {
|
|
| 2033 | - $post_type = str_replace("category", "", $term->taxonomy);
|
|
| 2034 | - $a_terms[$post_type][] = $term; |
|
| 2011 | + global $wpdb; |
|
| 2012 | + if (!$rebuild) {
|
|
| 2013 | + $terms_icons = get_option('gd_term_icons');
|
|
| 2014 | + } else {
|
|
| 2015 | + $terms_icons = array(); |
|
| 2016 | + } |
|
| 2035 | 2017 | |
| 2036 | - } |
|
| 2037 | - } |
|
| 2018 | + if (empty($terms_icons)) {
|
|
| 2019 | + $terms_icons = array(); |
|
| 2020 | + $default_icon_url = get_option('geodir_default_marker_icon');
|
|
| 2021 | + $taxonomy = geodir_get_taxonomies(); |
|
| 2022 | + $post_types = geodir_get_posttypes(); |
|
| 2023 | + $tax_arr = array(); |
|
| 2024 | + foreach ($post_types as $post_type) {
|
|
| 2025 | + $tax_arr[] = "'" . $post_type . "category'"; |
|
| 2026 | + } |
|
| 2027 | + $tax_c = implode(',', $tax_arr);
|
|
| 2028 | + $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
|
|
| 2029 | + //$terms = get_terms( $taxonomy ); |
|
| 2038 | 2030 | |
| 2039 | - if($a_terms) {
|
|
| 2040 | - foreach ($a_terms as $pt => $t2) {
|
|
| 2031 | + if($terms) {
|
|
| 2032 | + foreach ($terms as $term) {
|
|
| 2033 | + $post_type = str_replace("category", "", $term->taxonomy);
|
|
| 2034 | + $a_terms[$post_type][] = $term; |
|
| 2041 | 2035 | |
| 2042 | - foreach ($t2 as $term) {
|
|
| 2043 | - $term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); |
|
| 2044 | - if ($term_icon) {
|
|
| 2045 | - $term_icon_url = $term_icon["src"]; |
|
| 2046 | - } else {
|
|
| 2047 | - $term_icon_url = $default_icon_url; |
|
| 2048 | - } |
|
| 2049 | - $terms_icons[$term->term_id] = $term_icon_url; |
|
| 2050 | - } |
|
| 2051 | - } |
|
| 2052 | - } |
|
| 2036 | + } |
|
| 2037 | + } |
|
| 2053 | 2038 | |
| 2054 | - update_option('gd_term_icons', $terms_icons);
|
|
| 2055 | - } |
|
| 2039 | + if($a_terms) {
|
|
| 2040 | + foreach ($a_terms as $pt => $t2) {
|
|
| 2056 | 2041 | |
| 2057 | - if ($term_id && isset($terms_icons[$term_id])) {
|
|
| 2058 | - return $terms_icons[$term_id]; |
|
| 2059 | - } elseif ($term_id && !isset($terms_icons[$term_id])) {
|
|
| 2060 | - return get_option('geodir_default_marker_icon');
|
|
| 2061 | - } |
|
| 2042 | + foreach ($t2 as $term) {
|
|
| 2043 | + $term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); |
|
| 2044 | + if ($term_icon) {
|
|
| 2045 | + $term_icon_url = $term_icon["src"]; |
|
| 2046 | + } else {
|
|
| 2047 | + $term_icon_url = $default_icon_url; |
|
| 2048 | + } |
|
| 2049 | + $terms_icons[$term->term_id] = $term_icon_url; |
|
| 2050 | + } |
|
| 2051 | + } |
|
| 2052 | + } |
|
| 2053 | + |
|
| 2054 | + update_option('gd_term_icons', $terms_icons);
|
|
| 2055 | + } |
|
| 2062 | 2056 | |
| 2063 | - if (is_ssl()) {
|
|
| 2064 | - $terms_icons = str_replace("http:","https:",$terms_icons );
|
|
| 2065 | - } |
|
| 2057 | + if ($term_id && isset($terms_icons[$term_id])) {
|
|
| 2058 | + return $terms_icons[$term_id]; |
|
| 2059 | + } elseif ($term_id && !isset($terms_icons[$term_id])) {
|
|
| 2060 | + return get_option('geodir_default_marker_icon');
|
|
| 2061 | + } |
|
| 2062 | + |
|
| 2063 | + if (is_ssl()) {
|
|
| 2064 | + $terms_icons = str_replace("http:","https:",$terms_icons );
|
|
| 2065 | + } |
|
| 2066 | 2066 | |
| 2067 | - return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
|
|
| 2067 | + return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
|
|
| 2068 | 2068 | } |
| 2069 | 2069 | \ No newline at end of file |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | * @since 1.0.0 |
| 61 | 61 | * @param string $menu_class The menu HTML class. |
| 62 | 62 | */ |
| 63 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 63 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
|
|
| 64 | 64 | /** |
| 65 | 65 | * Filter the menu a class. |
| 66 | 66 | * |
| 67 | 67 | * @since 1.0.0 |
| 68 | 68 | */ |
| 69 | 69 | $a_class = apply_filters('geodir_menu_a_class', '');
|
| 70 | - $items .= '<li class="' . $li_class . '"> |
|
| 71 | - <a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '"> |
|
| 72 | - ' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . ' |
|
| 70 | + $items .= '<li class="'.$li_class.'"> |
|
| 71 | + <a href="' . get_post_type_archive_link($post_type).'" class="'.$a_class.'"> |
|
| 72 | + ' . __(geodir_utf8_ucfirst($args->labels->name), 'geodirectory').' |
|
| 73 | 73 | </a> |
| 74 | 74 | </li>'; |
| 75 | 75 | } |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | * @since 1.0.0 |
| 89 | 89 | * @param string $menu_class The menu HTML class. |
| 90 | 90 | */ |
| 91 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
|
|
| 91 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings '.$menu_class);
|
|
| 92 | 92 | /** |
| 93 | 93 | * Filter the sub menu li class. |
| 94 | 94 | * |
| 95 | 95 | * @since 1.0.0 |
| 96 | 96 | * @param string $menu_class The menu HTML class. |
| 97 | 97 | */ |
| 98 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 98 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item '.$menu_class);
|
|
| 99 | 99 | /** |
| 100 | 100 | * Filter the sub menu ul class. |
| 101 | 101 | * |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | * @since 1.0.0 |
| 115 | 115 | */ |
| 116 | 116 | $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
| 117 | - $items .= '<li class="' . $li_class . '"> |
|
| 118 | - <a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
|
|
| 119 | - <ul class="' . $sub_ul_class . '">'; |
|
| 117 | + $items .= '<li class="'.$li_class.'"> |
|
| 118 | + <a href="#" class="' . $a_class.'">'.__('Listing', 'geodirectory').'</a>
|
|
| 119 | + <ul class="' . $sub_ul_class.'">'; |
|
| 120 | 120 | $post_types = geodir_get_posttypes('object');
|
| 121 | 121 | |
| 122 | 122 | $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
|
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
| 134 | 134 | $menu_class = 'current-menu-item'; |
| 135 | 135 | |
| 136 | - $items .= '<li class="' . $sub_li_class . '"> |
|
| 137 | - <a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '"> |
|
| 138 | - ' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . ' |
|
| 136 | + $items .= '<li class="'.$sub_li_class.'"> |
|
| 137 | + <a href="' . get_post_type_archive_link($post_type).'" class="'.$sub_a_class.'"> |
|
| 138 | + ' . __(geodir_utf8_ucfirst($args->labels->name), 'geodirectory').' |
|
| 139 | 139 | </a> |
| 140 | 140 | </li>'; |
| 141 | 141 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * |
| 152 | 152 | * @since 1.5.9 |
| 153 | 153 | */ |
| 154 | - $items .= apply_filters('geodir_menu_after_sub_ul','');
|
|
| 154 | + $items .= apply_filters('geodir_menu_after_sub_ul', '');
|
|
| 155 | 155 | $items .= '</li>'; |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * @since 1.0.0 |
| 185 | 185 | * @param string $menu_class The menu HTML class. |
| 186 | 186 | */ |
| 187 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 187 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
|
|
| 188 | 188 | /** |
| 189 | 189 | * Filter the menu a class. |
| 190 | 190 | * |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | $a_class = apply_filters('geodir_menu_a_class', '');
|
| 194 | 194 | $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
| 195 | - $items .= '<li class="' . $li_class . '"> |
|
| 196 | - <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '"> |
|
| 197 | - ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
|
|
| 195 | + $items .= '<li class="'.$li_class.'"> |
|
| 196 | + <a href="' . geodir_get_addlisting_link($post_type).'" class="'.$a_class.'"> |
|
| 197 | + ' . sprintf(__('Add %s', 'geodirectory'), $cpt_name).'
|
|
| 198 | 198 | </a> |
| 199 | 199 | </li>'; |
| 200 | 200 | } |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | * @since 1.0.0 |
| 219 | 219 | * @param string $menu_class The menu HTML class. |
| 220 | 220 | */ |
| 221 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
|
|
| 221 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing '.$menu_class);
|
|
| 222 | 222 | /** |
| 223 | 223 | * Filter the sub menu li class. |
| 224 | 224 | * |
| 225 | 225 | * @since 1.0.0 |
| 226 | 226 | * @param string $menu_class The menu HTML class. |
| 227 | 227 | */ |
| 228 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 228 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item '.$menu_class);
|
|
| 229 | 229 | /** |
| 230 | 230 | * Filter the sub menu ul class. |
| 231 | 231 | * |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | * @since 1.0.0 |
| 245 | 245 | */ |
| 246 | 246 | $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
| 247 | - $items .= '<li class="' . $li_class . '"> |
|
| 248 | - <a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
|
|
| 249 | - <ul class="' . $sub_ul_class . '">'; |
|
| 247 | + $items .= '<li class="'.$li_class.'"> |
|
| 248 | + <a href="#" class="' . $a_class.'">'.__('Add Listing', 'geodirectory').'</a>
|
|
| 249 | + <ul class="' . $sub_ul_class.'">'; |
|
| 250 | 250 | |
| 251 | 251 | $post_types = geodir_get_posttypes('object');
|
| 252 | 252 | |
@@ -269,11 +269,11 @@ discard block |
||
| 269 | 269 | * @since 1.0.0 |
| 270 | 270 | * @param string $menu_class The menu HTML class. |
| 271 | 271 | */ |
| 272 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 272 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
|
|
| 273 | 273 | $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
| 274 | - $items .= '<li class="' . $sub_li_class . '"> |
|
| 275 | - <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '"> |
|
| 276 | - ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
|
|
| 274 | + $items .= '<li class="'.$sub_li_class.'"> |
|
| 275 | + <a href="' . geodir_get_addlisting_link($post_type).'" class="'.$sub_a_class.'"> |
|
| 276 | + ' . sprintf(__('Add %s', 'geodirectory'), $cpt_name).'
|
|
| 277 | 277 | </a> |
| 278 | 278 | </li>'; |
| 279 | 279 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | $items .= ' </ul> '; |
| 288 | - $items .= apply_filters('geodir_menu_after_sub_ul','');
|
|
| 288 | + $items .= apply_filters('geodir_menu_after_sub_ul', '');
|
|
| 289 | 289 | $items .= '</li>'; |
| 290 | 290 | |
| 291 | 291 | } |
@@ -313,14 +313,14 @@ discard block |
||
| 313 | 313 | $geodir_theme_location = get_option('geodir_theme_location_nav');
|
| 314 | 314 | $geodir_theme_location_nav = array(); |
| 315 | 315 | if (empty($locations) && empty($geodir_theme_location)) {
|
| 316 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 316 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items()."</ul></div>", $menu);
|
|
| 317 | 317 | $geodir_theme_location_nav[] = $args['theme_location']; |
| 318 | 318 | update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
|
| 319 | 319 | } |
| 320 | 320 | //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
| 321 | 321 | // $menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
|
| 322 | 322 | else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
| 323 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 323 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items()."</ul></div>", $menu);
|
|
| 324 | 324 | |
| 325 | 325 | return $menu; |
| 326 | 326 | |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
|
| 350 | 350 | |
| 351 | - $items = $items . geodir_add_nav_menu_items(); |
|
| 351 | + $items = $items.geodir_add_nav_menu_items(); |
|
| 352 | 352 | return $items; |
| 353 | 353 | |
| 354 | 354 | } else {
|
@@ -373,12 +373,12 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | $taxonomies = geodir_get_taxonomies(); |
| 375 | 375 | $taxonomies = implode("','", $taxonomies);
|
| 376 | - $taxonomies = "'" . $taxonomies . "'"; |
|
| 376 | + $taxonomies = "'".$taxonomies."'"; |
|
| 377 | 377 | |
| 378 | 378 | $pn_categories = $wpdb->get_results( |
| 379 | 379 | $wpdb->prepare( |
| 380 | 380 | "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name", |
| 381 | - array($wpdb->terms . term_id) |
|
| 381 | + array($wpdb->terms.term_id) |
|
| 382 | 382 | ) |
| 383 | 383 | ); |
| 384 | 384 | |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
| 410 | 410 | if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
| 411 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 411 | + $geodir_post_type = get_post_type((int) $_REQUEST['pid']); |
|
| 412 | 412 | elseif (isset($_REQUEST['listing_type'])) |
| 413 | 413 | $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
| 414 | 414 | } |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
| 435 | 435 | $geodir_post_type = ''; |
| 436 | 436 | |
| 437 | - if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
|
|
| 437 | + if (defined('DOING_AJAX') && isset($_REQUEST['stype'])) {
|
|
| 438 | 438 | $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
| 439 | 439 | } |
| 440 | 440 | |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | * |
| 445 | 445 | * @since 1.6.9 |
| 446 | 446 | */ |
| 447 | - return apply_filters('geodir_get_current_posttype',$geodir_post_type);
|
|
| 447 | + return apply_filters('geodir_get_current_posttype', $geodir_post_type);
|
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | /** |
@@ -458,18 +458,18 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | function geodir_get_default_posttype() |
| 460 | 460 | {
|
| 461 | - $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
| 461 | + $post_types = apply_filters('geodir_get_default_posttype', geodir_get_posttypes('object'));
|
|
| 462 | 462 | |
| 463 | 463 | $stype = false; |
| 464 | - foreach ( $post_types as $post_type => $info ) {
|
|
| 464 | + foreach ($post_types as $post_type => $info) {
|
|
| 465 | 465 | global $wpdb; |
| 466 | - $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
| 467 | - if ( $has_posts ) {
|
|
| 466 | + $has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type));
|
|
| 467 | + if ($has_posts) {
|
|
| 468 | 468 | $stype = $post_type; break; |
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - if(!$stype){
|
|
| 472 | + if (!$stype) {
|
|
| 473 | 473 | $stype = 'gd_place'; |
| 474 | 474 | } |
| 475 | 475 | |
@@ -494,14 +494,14 @@ discard block |
||
| 494 | 494 | switch ($output): |
| 495 | 495 | case 'object': |
| 496 | 496 | case 'Object': |
| 497 | - $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
| 497 | + $post_types = json_decode(json_encode($post_types), FALSE); //(object)$post_types; |
|
| 498 | 498 | break; |
| 499 | 499 | case 'array': |
| 500 | 500 | case 'Array': |
| 501 | - $post_types = (array)$post_types; |
|
| 501 | + $post_types = (array) $post_types; |
|
| 502 | 502 | break; |
| 503 | 503 | case 'options': |
| 504 | - $post_types = (array)$post_types; |
|
| 504 | + $post_types = (array) $post_types; |
|
| 505 | 505 | |
| 506 | 506 | $options = array(); |
| 507 | 507 | if (!empty($post_types)) {
|
@@ -619,15 +619,15 @@ discard block |
||
| 619 | 619 | |
| 620 | 620 | $categories = get_terms($taxonomies); |
| 621 | 621 | |
| 622 | - $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
|
|
| 622 | + $html .= '<option value="0">'.__('All', 'geodirectory').'</option>';
|
|
| 623 | 623 | |
| 624 | 624 | foreach ($categories as $category_obj) {
|
| 625 | 625 | $select_opt = ''; |
| 626 | 626 | if ($selected == $category_obj->term_id) {
|
| 627 | 627 | $select_opt = 'selected="selected"'; |
| 628 | 628 | } |
| 629 | - $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
| 630 | - . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
|
| 629 | + $html .= '<option '.$select_opt.' value="'.$category_obj->term_id.'">' |
|
| 630 | + . geodir_utf8_ucfirst($category_obj->name).'</option>'; |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | if ($echo) |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | } elseif (isset($wp_query->tax_query->queries)) {
|
| 696 | 696 | $tax_arr = $wp_query->tax_query->queries; |
| 697 | 697 | //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
| 698 | - if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
|
|
| 698 | + if (isset($tax_arr['relation'])) {unset($tax_arr['relation']); }
|
|
| 699 | 699 | $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
| 700 | 700 | } |
| 701 | 701 | |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | |
| 750 | 750 | if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
|
| 751 | 751 | if ($cat_parent == 0) {
|
| 752 | - $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
| 752 | + $list_class = 'main_list gd-parent-cats-list gd-cats-display-'.$cat_display; |
|
| 753 | 753 | $main_list_class = 'class="main_list_selecter"'; |
| 754 | 754 | } else {
|
| 755 | 755 | //$display = 'display:none'; |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | |
| 760 | 760 | if ($cat_display == 'checkbox' || $cat_display == 'radio') {
|
| 761 | 761 | $p = 0; |
| 762 | - $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 762 | + $out = '<div class="'.$list_class.' gd-cat-row-'.$cat_parent.'" style="margin-left:'.$p.'px;'.$display.';">'; |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | foreach ($cat_terms as $cat_term) {
|
@@ -774,12 +774,12 @@ discard block |
||
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | if ($cat_display == 'radio') |
| 777 | - $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 777 | + $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category['.$cat_term->taxonomy.'][]" '.$main_list_class.' alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' id="gd-cat-'.$cat_term->term_id.'" >'.$term_check.geodir_utf8_ucfirst($cat_term->name).'</span>'; |
|
| 778 | 778 | elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
| 779 | - $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 779 | + $out .= '<option '.$main_list_class.' style="margin-left:'.$p.'px;" alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' >'.$term_check.geodir_utf8_ucfirst($cat_term->name).'</option>'; |
|
| 780 | 780 | |
| 781 | 781 | else {
|
| 782 | - $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 782 | + $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category['.$cat_term->taxonomy.'][]" '.$main_list_class.' alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' id="gd-cat-'.$cat_term->term_id.'" >'.$term_check.geodir_utf8_ucfirst($cat_term->name).'</span>'; |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | // Call recurson to print sub cats |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | $cat_exclude = serialize($exclude_cats); |
| 819 | 819 | |
| 820 | 820 | if (isset($_REQUEST['backandedit'])) {
|
| 821 | - $post = (object)$gd_session->get('listing');
|
|
| 821 | + $post = (object) $gd_session->get('listing');
|
|
| 822 | 822 | |
| 823 | 823 | if (!is_array($post->post_category[$cat_taxonomy])) |
| 824 | 824 | $post_category = $post->post_category[$cat_taxonomy]; |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | |
| 851 | 851 | if (!empty($post_category)) {
|
| 852 | 852 | $cat1 = array_filter(explode(',', $post_category));
|
| 853 | - $post_category = ',' . implode(',', $cat1) . ',';
|
|
| 853 | + $post_category = ','.implode(',', $cat1).',';
|
|
| 854 | 854 | |
| 855 | 855 | } |
| 856 | 856 | |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | foreach ($post_category_upd as $cat) {
|
| 862 | 862 | |
| 863 | 863 | if (!in_array($cat, $exclude_cats) && $cat != '') {
|
| 864 | - $post_category_change .= ',' . $cat; |
|
| 864 | + $post_category_change .= ','.$cat; |
|
| 865 | 865 | } |
| 866 | 866 | } |
| 867 | 867 | $post_category = $post_category_change; |
@@ -873,11 +873,11 @@ discard block |
||
| 873 | 873 | } |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
| 876 | + echo '<input type="hidden" id="cat_limit" value="'.$cat_limit.'" name="cat_limit['.$cat_taxonomy.']" />'; |
|
| 877 | 877 | |
| 878 | - echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
| 878 | + echo '<input type="hidden" id="post_category" value="'.$post_category.'" name="post_category['.$cat_taxonomy.']" />'; |
|
| 879 | 879 | |
| 880 | - echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
| 880 | + echo '<input type="hidden" id="post_category_str" value="'.$post_category_str.'" name="post_category_str['.$cat_taxonomy.']" />'; |
|
| 881 | 881 | |
| 882 | 882 | |
| 883 | 883 | ?> |
@@ -896,14 +896,14 @@ discard block |
||
| 896 | 896 | |
| 897 | 897 | function show_subcatlist(main_cat, catObj) {
|
| 898 | 898 | if (main_cat != '') {
|
| 899 | - var url = '<?php echo geodir_get_ajax_url();?>'; |
|
| 900 | - var cat_taxonomy = '<?php echo $cat_taxonomy;?>'; |
|
| 901 | - var cat_exclude = '<?php echo base64_encode($cat_exclude);?>'; |
|
| 899 | + var url = '<?php echo geodir_get_ajax_url(); ?>'; |
|
| 900 | + var cat_taxonomy = '<?php echo $cat_taxonomy; ?>'; |
|
| 901 | + var cat_exclude = '<?php echo base64_encode($cat_exclude); ?>'; |
|
| 902 | 902 | var cat_limit = jQuery('#' + cat_taxonomy).find('#cat_limit').val();
|
| 903 | - <?php if ((int)$cat_limit > 0) { ?>
|
|
| 903 | + <?php if ((int) $cat_limit > 0) { ?>
|
|
| 904 | 904 | var selected = parseInt(jQuery('#' + cat_taxonomy).find('.cat_sublist > div.post_catlist_item').length);
|
| 905 | 905 | if (cat_limit != '' && selected > 0 && selected >= cat_limit && cat_limit != 0) {
|
| 906 | - alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', 'geodirectory'), (int)$cat_limit));?>");
|
|
| 906 | + alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', 'geodirectory'), (int) $cat_limit)); ?>");
|
|
| 907 | 907 | return false; |
| 908 | 908 | } |
| 909 | 909 | <?php } ?> |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | } |
| 943 | 943 | |
| 944 | 944 | function update_listing_cat(el) {
|
| 945 | - var cat_taxonomy = '<?php echo $cat_taxonomy;?>'; |
|
| 945 | + var cat_taxonomy = '<?php echo $cat_taxonomy; ?>'; |
|
| 946 | 946 | var cat_ids = ''; |
| 947 | 947 | var main_cat = ''; |
| 948 | 948 | var sub_cat = ''; |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | <div class="main_cat_list" style=" <?php if (isset($style)) {
|
| 1024 | 1024 | echo $style; |
| 1025 | 1025 | }?> "> |
| 1026 | - <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list |
|
| 1026 | + <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list |
|
| 1027 | 1027 | ?> |
| 1028 | 1028 | </div> |
| 1029 | 1029 | <?php |
@@ -1050,9 +1050,9 @@ discard block |
||
| 1050 | 1050 | if ($exclude != '') {
|
| 1051 | 1051 | $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
| 1052 | 1052 | |
| 1053 | - if(is_array( $exclude_cats)){
|
|
| 1054 | - $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
| 1055 | - }else{
|
|
| 1053 | + if (is_array($exclude_cats)) {
|
|
| 1054 | + $exclude_cats = array_map('intval', $exclude_cats);
|
|
| 1055 | + } else {
|
|
| 1056 | 1056 | $exclude_cats = intval($exclude_cats); |
| 1057 | 1057 | } |
| 1058 | 1058 | |
@@ -1066,25 +1066,25 @@ discard block |
||
| 1066 | 1066 | <?php $main_cat = get_term($parrent, $request_taxonomy); ?> |
| 1067 | 1067 | |
| 1068 | 1068 | <div class="post_catlist_item" style="border:1px solid #CCCCCC; margin:5px auto; padding:5px;"> |
| 1069 | - <img alt="move icon" src="<?php echo geodir_plugin_url() . '/geodirectory-assets/images/move.png';?>" |
|
| 1069 | + <img alt="move icon" src="<?php echo geodir_plugin_url().'/geodirectory-assets/images/move.png'; ?>" |
|
| 1070 | 1070 | onclick="jQuery(this).closest('div').remove();update_listing_cat(this);" align="right"/>
|
| 1071 | 1071 | <?php /* ?> |
| 1072 | 1072 | <img src="<?php echo geodir_plugin_url().'/geodirectory-assets/images/move.png';?>" onclick="jQuery(this).closest('div').remove();show_subcatlist();" align="right" />
|
| 1073 | 1073 | <?php */ ?> |
| 1074 | 1074 | |
| 1075 | - <input type="checkbox" value="<?php echo $main_cat->term_id;?>" class="listing_main_cat" |
|
| 1075 | + <input type="checkbox" value="<?php echo $main_cat->term_id; ?>" class="listing_main_cat" |
|
| 1076 | 1076 | onchange="if(jQuery(this).is(':checked')){jQuery(this).closest('div').find('.post_default_category').prop('checked',false).show();}else{jQuery(this).closest('div').find('.post_default_category').prop('checked',false).hide();};update_listing_cat()"
|
| 1077 | 1077 | checked="checked" disabled="disabled"/> |
| 1078 | 1078 | <span> |
| 1079 | - <?php printf(__('Add listing in %s category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
|
|
| 1079 | + <?php printf(__('Add listing in %s category', 'geodirectory'), geodir_ucwords($main_cat->name)); ?>
|
|
| 1080 | 1080 | </span> |
| 1081 | 1081 | <br/> |
| 1082 | 1082 | |
| 1083 | 1083 | <div class="post_default_category"> |
| 1084 | - <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>" |
|
| 1085 | - onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?> /> |
|
| 1084 | + <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id; ?>" |
|
| 1085 | + onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" '; ?> /> |
|
| 1086 | 1086 | <span> |
| 1087 | - <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
|
|
| 1087 | + <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name)); ?>
|
|
| 1088 | 1088 | </span> |
| 1089 | 1089 | </div> |
| 1090 | 1090 | |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | $post_cat_str = $post_categories[$request_taxonomy]; |
| 1118 | 1118 | $post_cat_array = explode("#", $post_cat_str);
|
| 1119 | 1119 | if (is_array($post_cat_array)) {
|
| 1120 | - $post_cat_array = array_unique( $post_cat_array ); |
|
| 1120 | + $post_cat_array = array_unique($post_cat_array); |
|
| 1121 | 1121 | |
| 1122 | 1122 | foreach ($post_cat_array as $post_cat_html) {
|
| 1123 | 1123 | |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | } |
| 1133 | 1133 | $post_sub_catid = ''; |
| 1134 | 1134 | if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
| 1135 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1135 | + $post_sub_catid = (int) $post_cat_info[1]; |
|
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | 1138 | geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
@@ -1153,7 +1153,7 @@ discard block |
||
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | 1155 | if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
| 1156 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1156 | + $post_sub_catid = (int) $post_cat_info[1]; |
|
| 1157 | 1157 | } |
| 1158 | 1158 | |
| 1159 | 1159 | geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
@@ -1185,9 +1185,9 @@ discard block |
||
| 1185 | 1185 | if (!$selected) |
| 1186 | 1186 | $option_slected = ' selected="selected" '; |
| 1187 | 1187 | |
| 1188 | - echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
| 1188 | + echo '<select field_type="select" id="'.sanitize_text_field($cat_taxonomy).'" class="chosen_select" '.$onchange.' option-ajaxChosen="false" >'; |
|
| 1189 | 1189 | |
| 1190 | - echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
|
|
| 1190 | + echo '<option value="" '.$option_selected.' >'.__('Select Category', 'geodirectory').'</option>';
|
|
| 1191 | 1191 | |
| 1192 | 1192 | foreach ($cat_terms as $cat_term) {
|
| 1193 | 1193 | $option_selected = ''; |
@@ -1195,10 +1195,10 @@ discard block |
||
| 1195 | 1195 | $option_selected = ' selected="selected" '; |
| 1196 | 1196 | |
| 1197 | 1197 | // Count child terms |
| 1198 | - $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
| 1199 | - $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
| 1198 | + $child_terms = get_terms($cat_taxonomy, array('parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1));
|
|
| 1199 | + $has_child = !empty($child_terms) ? 't' : 'f'; |
|
| 1200 | 1200 | |
| 1201 | - echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 1201 | + echo '<option '.$option_selected.' alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" _hc="'.$has_child.'" >'.geodir_utf8_ucfirst($cat_term->name).'</option>'; |
|
| 1202 | 1202 | } |
| 1203 | 1203 | echo '</select>'; |
| 1204 | 1204 | } |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | 2 => __('Custom field updated.', 'geodirectory'),
|
| 1230 | 1230 | 3 => __('Custom field deleted.', 'geodirectory'),
|
| 1231 | 1231 | 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
|
| 1232 | - 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
|
|
| 1232 | + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], false)) : false,
|
|
| 1233 | 1233 | 6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
| 1234 | 1234 | 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
|
| 1235 | 1235 | 8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
@@ -1255,7 +1255,7 @@ discard block |
||
| 1255 | 1255 | |
| 1256 | 1256 | global $wpdb; |
| 1257 | 1257 | |
| 1258 | - $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
| 1258 | + $menu_icon = geodir_plugin_url().'/geodirectory-assets/images/favicon.ico'; |
|
| 1259 | 1259 | |
| 1260 | 1260 | if (!$listing_slug = get_option('geodir_listing_prefix'))
|
| 1261 | 1261 | $listing_slug = 'places'; |
@@ -1268,11 +1268,11 @@ discard block |
||
| 1268 | 1268 | |
| 1269 | 1269 | $gd_placetags = array(); |
| 1270 | 1270 | $gd_placetags['object_type'] = 'gd_place'; |
| 1271 | - $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
| 1271 | + $gd_placetags['listing_slug'] = $listing_slug.'/tags'; |
|
| 1272 | 1272 | $gd_placetags['args'] = array( |
| 1273 | 1273 | 'public' => true, |
| 1274 | 1274 | 'hierarchical' => false, |
| 1275 | - 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
|
|
| 1275 | + 'rewrite' => array('slug' => $listing_slug.'/tags', 'with_front' => false, 'hierarchical' => true),
|
|
| 1276 | 1276 | 'query_var' => true, |
| 1277 | 1277 | |
| 1278 | 1278 | 'labels' => array( |
@@ -1366,7 +1366,7 @@ discard block |
||
| 1366 | 1366 | 'menu_icon' => $menu_icon, |
| 1367 | 1367 | 'public' => true, |
| 1368 | 1368 | 'query_var' => true, |
| 1369 | - 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
|
|
| 1369 | + 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
|
|
| 1370 | 1370 | 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
|
| 1371 | 1371 | 'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
|
| 1372 | 1372 | |
@@ -1399,12 +1399,12 @@ discard block |
||
| 1399 | 1399 | return $_REQUEST['lang']; |
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | - $url = str_replace(array("http://","https://"),"",$url);
|
|
| 1402 | + $url = str_replace(array("http://", "https://"), "", $url);
|
|
| 1403 | 1403 | |
| 1404 | 1404 | // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
|
| 1405 | - $site_url = str_replace(array("http://","https://"),"",site_url());
|
|
| 1405 | + $site_url = str_replace(array("http://", "https://"), "", site_url());
|
|
| 1406 | 1406 | |
| 1407 | - $url = str_replace($site_url,"",$url); |
|
| 1407 | + $url = str_replace($site_url, "", $url); |
|
| 1408 | 1408 | |
| 1409 | 1409 | $segments = explode('/', trim($url, '/'));
|
| 1410 | 1410 | |
@@ -1470,9 +1470,9 @@ discard block |
||
| 1470 | 1470 | if (in_array($post->post_type, geodir_get_posttypes())) {
|
| 1471 | 1471 | |
| 1472 | 1472 | // if we dont have a GD post then try to grab it |
| 1473 | - if(!isset($post->default_category)){
|
|
| 1473 | + if (!isset($post->default_category)) {
|
|
| 1474 | 1474 | $gd_post = geodir_get_post_info($post->ID); |
| 1475 | - if(!empty($gd_post)){
|
|
| 1475 | + if (!empty($gd_post)) {
|
|
| 1476 | 1476 | $post = $gd_post; |
| 1477 | 1477 | } |
| 1478 | 1478 | } |
@@ -1482,17 +1482,17 @@ discard block |
||
| 1482 | 1482 | $slug = $post_types[$post->post_type]['rewrite']['slug']; |
| 1483 | 1483 | |
| 1484 | 1484 | // Alter the CPT slug if WPML is set to do so |
| 1485 | - if(geodir_wpml_is_post_type_translated($post->post_type)){
|
|
| 1486 | - if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
|
|
| 1485 | + if (geodir_wpml_is_post_type_translated($post->post_type)) {
|
|
| 1486 | + if (gd_wpml_slug_translation_turned_on($post->post_type) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
|
|
| 1487 | 1487 | |
| 1488 | 1488 | $org_slug = $slug; |
| 1489 | - $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1489 | + $slug = apply_filters('wpml_translate_single_string',
|
|
| 1490 | 1490 | $slug, |
| 1491 | 1491 | 'WordPress', |
| 1492 | - 'URL slug: ' . $slug, |
|
| 1492 | + 'URL slug: '.$slug, |
|
| 1493 | 1493 | $language_code); |
| 1494 | 1494 | |
| 1495 | - if(!$slug){$slug = $org_slug;}
|
|
| 1495 | + if (!$slug) {$slug = $org_slug; }
|
|
| 1496 | 1496 | |
| 1497 | 1497 | } |
| 1498 | 1498 | } |
@@ -1514,11 +1514,11 @@ discard block |
||
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | $post_link = trailingslashit( |
| 1517 | - preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
| 1517 | + preg_replace("/".preg_quote($slug, "/")."/", $slug."/%gd_taxonomy%", $post_link, 1)
|
|
| 1518 | 1518 | ); |
| 1519 | 1519 | |
| 1520 | 1520 | if ($fix_url) {
|
| 1521 | - $post_link = $site_url . $post_link; |
|
| 1521 | + $post_link = $site_url.$post_link; |
|
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | 1524 | if (isset($comment_post_cache[$post->ID])) {
|
@@ -1537,12 +1537,12 @@ discard block |
||
| 1537 | 1537 | $ID = $post->ID; |
| 1538 | 1538 | $post2 = $wpdb->get_row( |
| 1539 | 1539 | $wpdb->prepare( |
| 1540 | - "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1540 | + "SELECT * from ".$plugin_prefix.$post->post_type."_detail WHERE post_id = %d ", |
|
| 1541 | 1541 | array($post->ID) |
| 1542 | 1542 | ) |
| 1543 | 1543 | ); |
| 1544 | 1544 | |
| 1545 | - $post = (object)array_merge((array)$post, (array)$post2); |
|
| 1545 | + $post = (object) array_merge((array) $post, (array) $post2); |
|
| 1546 | 1546 | |
| 1547 | 1547 | $comment_post_cache[$post->ID] = $post; |
| 1548 | 1548 | } |
@@ -1551,7 +1551,7 @@ discard block |
||
| 1551 | 1551 | |
| 1552 | 1552 | if (false !== strpos($post_link, '%gd_taxonomy%')) {
|
| 1553 | 1553 | |
| 1554 | - if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
|
|
| 1554 | + if (apply_filters("geodir_add_location_url_to_url", get_option('geodir_add_location_url'), $post->post_type, $post)) {
|
|
| 1555 | 1555 | $location_request = ''; |
| 1556 | 1556 | |
| 1557 | 1557 | |
@@ -1565,7 +1565,7 @@ discard block |
||
| 1565 | 1565 | $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
| 1566 | 1566 | $post->country_slug = str_replace(']', '', $post->country_slug);
|
| 1567 | 1567 | |
| 1568 | - $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1568 | + $post_location = (object) array('country_slug' => $post->country_slug,
|
|
| 1569 | 1569 | 'region_slug' => $post->region_slug, |
| 1570 | 1570 | 'city_slug' => $post->city_slug |
| 1571 | 1571 | ); |
@@ -1578,7 +1578,7 @@ discard block |
||
| 1578 | 1578 | |
| 1579 | 1579 | $post_location_sql = $wpdb->get_results( |
| 1580 | 1580 | $wpdb->prepare( |
| 1581 | - "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1581 | + "SELECT post_locations from ".$plugin_prefix.$post->post_type."_detail WHERE post_id = %d ", |
|
| 1582 | 1582 | array($post->ID) |
| 1583 | 1583 | ) |
| 1584 | 1584 | ); |
@@ -1594,7 +1594,7 @@ discard block |
||
| 1594 | 1594 | $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
| 1595 | 1595 | $post->country_slug = str_replace(']', '', $post->country_slug);
|
| 1596 | 1596 | |
| 1597 | - $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1597 | + $post_location = (object) array('country_slug' => $post->country_slug,
|
|
| 1598 | 1598 | 'region_slug' => $post->region_slug, |
| 1599 | 1599 | 'city_slug' => $post->city_slug |
| 1600 | 1600 | ); |
@@ -1623,7 +1623,7 @@ discard block |
||
| 1623 | 1623 | } |
| 1624 | 1624 | $location_slug[] = $city_slug; |
| 1625 | 1625 | |
| 1626 | - $location_request .= implode('/', $location_slug) . '/';
|
|
| 1626 | + $location_request .= implode('/', $location_slug).'/';
|
|
| 1627 | 1627 | } |
| 1628 | 1628 | } |
| 1629 | 1629 | |
@@ -1639,9 +1639,9 @@ discard block |
||
| 1639 | 1639 | } else {
|
| 1640 | 1640 | $post_terms = ''; |
| 1641 | 1641 | |
| 1642 | - if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
|
|
| 1642 | + if (isset($_POST['post_default_category']) && $_POST['post_default_category']) {
|
|
| 1643 | 1643 | $post_terms = absint($_POST['post_default_category']); |
| 1644 | - }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
|
|
| 1644 | + }elseif (isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
|
|
| 1645 | 1645 | $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
|
| 1646 | 1646 | $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0; |
| 1647 | 1647 | }elseif (isset($post->{$taxonomies})) {
|
@@ -1687,14 +1687,14 @@ discard block |
||
| 1687 | 1687 | $request_term = trim($request_term, '/'); |
| 1688 | 1688 | |
| 1689 | 1689 | // Fix with WPML the location terms added twice when CPT slug is translated. |
| 1690 | - if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
|
|
| 1690 | + if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/'.$request_term.$detailurl_separator) !== false) {
|
|
| 1691 | 1691 | $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
|
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | 1694 | if (!empty($request_term)) |
| 1695 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1695 | + $post_link = str_replace('%gd_taxonomy%', $request_term.$detailurl_separator, $post_link);
|
|
| 1696 | 1696 | else |
| 1697 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1697 | + $post_link = str_replace('/%gd_taxonomy%', $request_term.$detailurl_separator, $post_link);
|
|
| 1698 | 1698 | //echo $post_link ; |
| 1699 | 1699 | } |
| 1700 | 1700 | // temp cache the permalink |
@@ -1769,9 +1769,9 @@ discard block |
||
| 1769 | 1769 | $url_separator = ''; |
| 1770 | 1770 | |
| 1771 | 1771 | if (get_option('permalink_structure') != '') {
|
| 1772 | - $old_listing_slug = '/' . $listing_slug . '/'; |
|
| 1772 | + $old_listing_slug = '/'.$listing_slug.'/'; |
|
| 1773 | 1773 | $request_term = implode("/", $location_terms);
|
| 1774 | - $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
| 1774 | + $new_listing_slug = '/'.$listing_slug.'/'.$request_term.'/'; |
|
| 1775 | 1775 | |
| 1776 | 1776 | $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
| 1777 | 1777 | } else {
|
@@ -1791,25 +1791,25 @@ discard block |
||
| 1791 | 1791 | // Alter the CPT slug if WPML is set to do so |
| 1792 | 1792 | if (geodir_is_wpml()) {
|
| 1793 | 1793 | $post_types = get_option('geodir_post_types');
|
| 1794 | - $post_type = str_replace("category","",$taxonomy);
|
|
| 1795 | - $post_type = str_replace("_tags","",$post_type);
|
|
| 1794 | + $post_type = str_replace("category", "", $taxonomy);
|
|
| 1795 | + $post_type = str_replace("_tags", "", $post_type);
|
|
| 1796 | 1796 | $slug = $post_types[$post_type]['rewrite']['slug']; |
| 1797 | 1797 | if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) {
|
| 1798 | 1798 | global $sitepress; |
| 1799 | 1799 | $default_lang = $sitepress->get_default_language(); |
| 1800 | 1800 | $language_code = gd_wpml_get_lang_from_url($termlink); |
| 1801 | - if (!$language_code ) {
|
|
| 1802 | - $language_code = $default_lang; |
|
| 1801 | + if (!$language_code) {
|
|
| 1802 | + $language_code = $default_lang; |
|
| 1803 | 1803 | } |
| 1804 | 1804 | |
| 1805 | 1805 | $org_slug = $slug; |
| 1806 | - $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
|
|
| 1806 | + $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: '.$slug, $language_code);
|
|
| 1807 | 1807 | |
| 1808 | 1808 | if (!$slug) {
|
| 1809 | 1809 | $slug = $org_slug; |
| 1810 | 1810 | } |
| 1811 | 1811 | |
| 1812 | - $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1));
|
|
| 1812 | + $termlink = trailingslashit(preg_replace("/".preg_quote($org_slug, "/")."/", $slug, $termlink, 1));
|
|
| 1813 | 1813 | } |
| 1814 | 1814 | } |
| 1815 | 1815 | } |
@@ -1839,7 +1839,7 @@ discard block |
||
| 1839 | 1839 | |
| 1840 | 1840 | if (in_array($post_type, geodir_get_posttypes())) {
|
| 1841 | 1841 | if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
|
| 1842 | - if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
|
|
| 1842 | + if (geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
|
|
| 1843 | 1843 | $location_terms = array( |
| 1844 | 1844 | 'gd_country' => $post->country_slug, |
| 1845 | 1845 | 'gd_region' => $post->region_slug, |
@@ -1856,7 +1856,7 @@ discard block |
||
| 1856 | 1856 | $location_terms = implode("/", $location_terms);
|
| 1857 | 1857 | $location_terms = rtrim($location_terms, '/'); |
| 1858 | 1858 | |
| 1859 | - $link .= urldecode($location_terms) . '/'; |
|
| 1859 | + $link .= urldecode($location_terms).'/'; |
|
| 1860 | 1860 | } else {
|
| 1861 | 1861 | $link = geodir_getlink($link, $location_terms); |
| 1862 | 1862 | } |
@@ -1944,9 +1944,9 @@ discard block |
||
| 1944 | 1944 | return 0; |
| 1945 | 1945 | $where = 't.term_id = %d'; |
| 1946 | 1946 | if (!empty($taxonomy)) |
| 1947 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1947 | + return $wpdb->get_row($wpdb->prepare($tax_select.$where." AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1948 | 1948 | else |
| 1949 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1949 | + return $wpdb->get_var($wpdb->prepare($select.$where, $term)); |
|
| 1950 | 1950 | } |
| 1951 | 1951 | |
| 1952 | 1952 | $term = trim(wp_unslash($term)); |
@@ -1958,7 +1958,7 @@ discard block |
||
| 1958 | 1958 | |
| 1959 | 1959 | $where_fields = array($slug); |
| 1960 | 1960 | if (!empty($taxonomy)) {
|
| 1961 | - $parent = (int)$parent; |
|
| 1961 | + $parent = (int) $parent; |
|
| 1962 | 1962 | if ($parent > 0) {
|
| 1963 | 1963 | $where_fields[] = $parent; |
| 1964 | 1964 | $else_where_fields[] = $parent; |
@@ -2022,13 +2022,13 @@ discard block |
||
| 2022 | 2022 | $post_types = geodir_get_posttypes(); |
| 2023 | 2023 | $tax_arr = array(); |
| 2024 | 2024 | foreach ($post_types as $post_type) {
|
| 2025 | - $tax_arr[] = "'" . $post_type . "category'"; |
|
| 2025 | + $tax_arr[] = "'".$post_type."category'"; |
|
| 2026 | 2026 | } |
| 2027 | 2027 | $tax_c = implode(',', $tax_arr);
|
| 2028 | 2028 | $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
|
| 2029 | 2029 | //$terms = get_terms( $taxonomy ); |
| 2030 | 2030 | |
| 2031 | - if($terms) {
|
|
| 2031 | + if ($terms) {
|
|
| 2032 | 2032 | foreach ($terms as $term) {
|
| 2033 | 2033 | $post_type = str_replace("category", "", $term->taxonomy);
|
| 2034 | 2034 | $a_terms[$post_type][] = $term; |
@@ -2036,7 +2036,7 @@ discard block |
||
| 2036 | 2036 | } |
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | - if($a_terms) {
|
|
| 2039 | + if ($a_terms) {
|
|
| 2040 | 2040 | foreach ($a_terms as $pt => $t2) {
|
| 2041 | 2041 | |
| 2042 | 2042 | foreach ($t2 as $term) {
|
@@ -2061,7 +2061,7 @@ discard block |
||
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | 2063 | if (is_ssl()) {
|
| 2064 | - $terms_icons = str_replace("http:","https:",$terms_icons );
|
|
| 2064 | + $terms_icons = str_replace("http:", "https:", $terms_icons);
|
|
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | 2067 | return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
|
@@ -13,29 +13,29 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | function geodir_register_taxonomies() |
| 15 | 15 | {
|
| 16 | - $taxonomies = array(); |
|
| 17 | - $taxonomies = get_option('geodir_taxonomies');
|
|
| 18 | - // If custom taxonomies are present, register them |
|
| 19 | - if (is_array($taxonomies)) {
|
|
| 20 | - // Sort taxonomies |
|
| 21 | - ksort($taxonomies); |
|
| 22 | - |
|
| 23 | - // Register taxonomies |
|
| 24 | - foreach ($taxonomies as $taxonomy => $args) {
|
|
| 25 | - // Allow taxonomy names to be translated |
|
| 26 | - if (!empty($args['args']['labels'])) {
|
|
| 27 | - foreach ($args['args']['labels'] as $key => $tax_label) {
|
|
| 28 | - $args['args']['labels'][$key] = __($tax_label, 'geodirectory'); |
|
| 29 | - } |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - $tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']); |
|
| 33 | - |
|
| 34 | - if (taxonomy_exists($taxonomy)) {
|
|
| 35 | - $tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']); |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - } |
|
| 16 | + $taxonomies = array(); |
|
| 17 | + $taxonomies = get_option('geodir_taxonomies');
|
|
| 18 | + // If custom taxonomies are present, register them |
|
| 19 | + if (is_array($taxonomies)) {
|
|
| 20 | + // Sort taxonomies |
|
| 21 | + ksort($taxonomies); |
|
| 22 | + |
|
| 23 | + // Register taxonomies |
|
| 24 | + foreach ($taxonomies as $taxonomy => $args) {
|
|
| 25 | + // Allow taxonomy names to be translated |
|
| 26 | + if (!empty($args['args']['labels'])) {
|
|
| 27 | + foreach ($args['args']['labels'] as $key => $tax_label) {
|
|
| 28 | + $args['args']['labels'][$key] = __($tax_label, 'geodirectory'); |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + $tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']); |
|
| 33 | + |
|
| 34 | + if (taxonomy_exists($taxonomy)) {
|
|
| 35 | + $tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
@@ -53,40 +53,40 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | function geodir_register_post_types() |
| 55 | 55 | {
|
| 56 | - global $wp_post_types; |
|
| 56 | + global $wp_post_types; |
|
| 57 | 57 | |
| 58 | - $post_types = array(); |
|
| 59 | - $post_types = get_option('geodir_post_types');
|
|
| 58 | + $post_types = array(); |
|
| 59 | + $post_types = get_option('geodir_post_types');
|
|
| 60 | 60 | |
| 61 | - // Register each post type if array of data is returned |
|
| 62 | - if (is_array($post_types)): |
|
| 61 | + // Register each post type if array of data is returned |
|
| 62 | + if (is_array($post_types)): |
|
| 63 | 63 | |
| 64 | - foreach ($post_types as $post_type => $args): |
|
| 64 | + foreach ($post_types as $post_type => $args): |
|
| 65 | 65 | |
| 66 | - if (!empty($args['rewrite']['slug'])) {
|
|
| 67 | - $args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory'); |
|
| 68 | - } |
|
| 69 | - $args = stripslashes_deep($args); |
|
| 66 | + if (!empty($args['rewrite']['slug'])) {
|
|
| 67 | + $args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory'); |
|
| 68 | + } |
|
| 69 | + $args = stripslashes_deep($args); |
|
| 70 | 70 | |
| 71 | - if (!empty($args['labels'])) {
|
|
| 72 | - foreach ($args['labels'] as $key => $val) {
|
|
| 73 | - $args['labels'][$key] = __($val, 'geodirectory');// allow translation |
|
| 74 | - } |
|
| 75 | - } |
|
| 71 | + if (!empty($args['labels'])) {
|
|
| 72 | + foreach ($args['labels'] as $key => $val) {
|
|
| 73 | + $args['labels'][$key] = __($val, 'geodirectory');// allow translation |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Filter post type args. |
|
| 79 | - * |
|
| 80 | - * @since 1.0.0 |
|
| 81 | - * @param string $args Post type args. |
|
| 82 | - * @param string $post_type The post type. |
|
| 83 | - */ |
|
| 84 | - $args = apply_filters('geodir_post_type_args', $args, $post_type);
|
|
| 77 | + /** |
|
| 78 | + * Filter post type args. |
|
| 79 | + * |
|
| 80 | + * @since 1.0.0 |
|
| 81 | + * @param string $args Post type args. |
|
| 82 | + * @param string $post_type The post type. |
|
| 83 | + */ |
|
| 84 | + $args = apply_filters('geodir_post_type_args', $args, $post_type);
|
|
| 85 | 85 | |
| 86 | - $post_type = register_post_type($post_type, $args); |
|
| 86 | + $post_type = register_post_type($post_type, $args); |
|
| 87 | 87 | |
| 88 | - endforeach; |
|
| 89 | - endif; |
|
| 88 | + endforeach; |
|
| 89 | + endif; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -100,72 +100,72 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | function geodir_post_type_args_modify($args, $post_type) |
| 102 | 102 | {
|
| 103 | - $geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
|
|
| 103 | + $geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
|
|
| 104 | 104 | if (isset($_REQUEST['geodir_listing_prefix']) && $_REQUEST['geodir_listing_prefix'] != '' && geodir_strtolower($_REQUEST['geodir_listing_prefix']) != geodir_strtolower($geodir_location_prefix)) {
|
| 105 | 105 | |
| 106 | - $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix'])); |
|
| 106 | + $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix'])); |
|
| 107 | 107 | |
| 108 | - if ($post_type == 'gd_place') {
|
|
| 109 | - if (array_key_exists('has_archive', $args))
|
|
| 110 | - $args['has_archive'] = $listing_slug; |
|
| 108 | + if ($post_type == 'gd_place') {
|
|
| 109 | + if (array_key_exists('has_archive', $args))
|
|
| 110 | + $args['has_archive'] = $listing_slug; |
|
| 111 | 111 | |
| 112 | - if (array_key_exists('rewrite', $args)) {
|
|
| 113 | - if (array_key_exists('slug', $args['rewrite']))
|
|
| 114 | - $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 115 | - } |
|
| 112 | + if (array_key_exists('rewrite', $args)) {
|
|
| 113 | + if (array_key_exists('slug', $args['rewrite']))
|
|
| 114 | + $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 117 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 118 | 118 | |
| 119 | - if (array_key_exists($post_type, $geodir_post_types)) {
|
|
| 119 | + if (array_key_exists($post_type, $geodir_post_types)) {
|
|
| 120 | 120 | |
| 121 | - if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
|
|
| 122 | - $geodir_post_types[$post_type]['has_archive'] = $listing_slug; |
|
| 121 | + if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
|
|
| 122 | + $geodir_post_types[$post_type]['has_archive'] = $listing_slug; |
|
| 123 | 123 | |
| 124 | - if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
|
|
| 125 | - if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
|
|
| 126 | - $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 124 | + if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
|
|
| 125 | + if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
|
|
| 126 | + $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 127 | 127 | |
| 128 | - update_option('geodir_post_types', $geodir_post_types);
|
|
| 128 | + update_option('geodir_post_types', $geodir_post_types);
|
|
| 129 | 129 | |
| 130 | - } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 132 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 133 | 133 | |
| 134 | - /* --- update taxonomies (category) --- */ |
|
| 134 | + /* --- update taxonomies (category) --- */ |
|
| 135 | 135 | |
| 136 | - $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 136 | + $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 137 | 137 | |
| 138 | - if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
|
|
| 139 | - $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug; |
|
| 138 | + if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
|
|
| 139 | + $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug; |
|
| 140 | 140 | |
| 141 | - if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
|
|
| 142 | - if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
|
|
| 143 | - if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
|
|
| 144 | - $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug; |
|
| 141 | + if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
|
|
| 142 | + if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
|
|
| 143 | + if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
|
|
| 144 | + $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug; |
|
| 145 | 145 | |
| 146 | - update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 146 | + update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 147 | 147 | |
| 148 | - } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /* --- update taxonomies (tags) --- */ |
|
| 151 | - $geodir_taxonomies_tag = get_option('geodir_taxonomies');
|
|
| 152 | - if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
|
|
| 153 | - $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags'; |
|
| 150 | + /* --- update taxonomies (tags) --- */ |
|
| 151 | + $geodir_taxonomies_tag = get_option('geodir_taxonomies');
|
|
| 152 | + if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
|
|
| 153 | + $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags'; |
|
| 154 | 154 | |
| 155 | - if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
|
|
| 156 | - if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
|
|
| 157 | - if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
|
|
| 158 | - $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags'; |
|
| 155 | + if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
|
|
| 156 | + if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
|
|
| 157 | + if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
|
|
| 158 | + $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags'; |
|
| 159 | 159 | |
| 160 | - update_option('geodir_taxonomies', $geodir_taxonomies_tag);
|
|
| 160 | + update_option('geodir_taxonomies', $geodir_taxonomies_tag);
|
|
| 161 | 161 | |
| 162 | - } |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - } |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - } |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - return $args; |
|
| 168 | + return $args; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | function geodir_flush_rewrite_rules() |
| 180 | 180 | {
|
| 181 | - global $wp_rewrite; |
|
| 182 | - $wp_rewrite->flush_rules(false); |
|
| 181 | + global $wp_rewrite; |
|
| 182 | + $wp_rewrite->flush_rules(false); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -194,35 +194,35 @@ discard block |
||
| 194 | 194 | * @return array Rewrite rules. |
| 195 | 195 | */ |
| 196 | 196 | function geodir_listing_rewrite_rules($rules) {
|
| 197 | - $newrules = array(); |
|
| 198 | - $taxonomies = get_option('geodir_taxonomies');
|
|
| 199 | - $detail_url_seprator = get_option('geodir_detailurl_separator');
|
|
| 197 | + $newrules = array(); |
|
| 198 | + $taxonomies = get_option('geodir_taxonomies');
|
|
| 199 | + $detail_url_seprator = get_option('geodir_detailurl_separator');
|
|
| 200 | 200 | |
| 201 | 201 | // create rules for post listing |
| 202 | - if (is_array($taxonomies)): |
|
| 203 | - foreach ($taxonomies as $taxonomy => $args): |
|
| 204 | - $post_type = $args['object_type']; |
|
| 205 | - $listing_slug = $args['listing_slug']; |
|
| 206 | - |
|
| 207 | - if (strpos($taxonomy, 'tags')) {
|
|
| 208 | - $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
|
|
| 209 | - $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]'; |
|
| 210 | - } else {
|
|
| 211 | - // use this loop to add paging for details page comments paging |
|
| 212 | - $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
|
|
| 213 | - } |
|
| 214 | - endforeach; |
|
| 215 | - endif; |
|
| 216 | - |
|
| 217 | - // create rules for location listing |
|
| 218 | - $location_page = get_option('geodir_location_page');
|
|
| 202 | + if (is_array($taxonomies)): |
|
| 203 | + foreach ($taxonomies as $taxonomy => $args): |
|
| 204 | + $post_type = $args['object_type']; |
|
| 205 | + $listing_slug = $args['listing_slug']; |
|
| 206 | + |
|
| 207 | + if (strpos($taxonomy, 'tags')) {
|
|
| 208 | + $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
|
|
| 209 | + $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]'; |
|
| 210 | + } else {
|
|
| 211 | + // use this loop to add paging for details page comments paging |
|
| 212 | + $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
|
|
| 213 | + } |
|
| 214 | + endforeach; |
|
| 215 | + endif; |
|
| 216 | + |
|
| 217 | + // create rules for location listing |
|
| 218 | + $location_page = get_option('geodir_location_page');
|
|
| 219 | 219 | |
| 220 | - if($location_page) {
|
|
| 221 | - global $wpdb; |
|
| 222 | - $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
|
|
| 223 | - } |
|
| 224 | - if (!isset($location_prefix)) |
|
| 225 | - $location_prefix = 'location'; |
|
| 220 | + if($location_page) {
|
|
| 221 | + global $wpdb; |
|
| 222 | + $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
|
|
| 223 | + } |
|
| 224 | + if (!isset($location_prefix)) |
|
| 225 | + $location_prefix = 'location'; |
|
| 226 | 226 | |
| 227 | 227 | $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
| 228 | 228 | if ($location_manager) {
|
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]'; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - if ($location_page && geodir_is_wpml()) {
|
|
| 270 | - foreach(icl_get_languages('skip_missing=N') as $lang){
|
|
| 271 | - $alt_page_id = ''; |
|
| 272 | - $alt_page_id = geodir_wpml_object_id($location_page, 'page', false,$lang['language_code']); |
|
| 273 | - if($alt_page_id){
|
|
| 274 | - $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
|
|
| 269 | + if ($location_page && geodir_is_wpml()) {
|
|
| 270 | + foreach(icl_get_languages('skip_missing=N') as $lang){
|
|
| 271 | + $alt_page_id = ''; |
|
| 272 | + $alt_page_id = geodir_wpml_object_id($location_page, 'page', false,$lang['language_code']); |
|
| 273 | + if($alt_page_id){
|
|
| 274 | + $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
|
|
| 275 | 275 | |
| 276 | 276 | if ($location_manager && ($hide_country_part || $hide_region_part)) {
|
| 277 | 277 | $matches2 = ''; |
@@ -307,14 +307,14 @@ discard block |
||
| 307 | 307 | $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]'; |
| 308 | 308 | $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]'; |
| 309 | 309 | } |
| 310 | - } |
|
| 311 | - } |
|
| 312 | - } |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page; |
|
| 314 | + $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page; |
|
| 315 | 315 | |
| 316 | - $rules = array_merge($newrules, $rules); |
|
| 317 | - return $rules; |
|
| 316 | + $rules = array_merge($newrules, $rules); |
|
| 317 | + return $rules; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -329,18 +329,18 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | function geodir_htaccess_contents($rules) |
| 331 | 331 | {
|
| 332 | - global $wpdb; |
|
| 333 | - $location_prefix = get_option('geodir_location_prefix');
|
|
| 334 | - // if location page slug changed then add redirect |
|
| 335 | - if ($location_prefix == 'location') {
|
|
| 336 | - return $rules; |
|
| 337 | - } |
|
| 338 | - $my_content = <<<EOD |
|
| 332 | + global $wpdb; |
|
| 333 | + $location_prefix = get_option('geodir_location_prefix');
|
|
| 334 | + // if location page slug changed then add redirect |
|
| 335 | + if ($location_prefix == 'location') {
|
|
| 336 | + return $rules; |
|
| 337 | + } |
|
| 338 | + $my_content = <<<EOD |
|
| 339 | 339 | \n# BEGIN GeoDirectory Rules |
| 340 | 340 | #Redirect 301 /location/ /$location_prefix/ |
| 341 | 341 | # END GeoDirectory Rules\n\n |
| 342 | 342 | EOD; |
| 343 | - return $my_content . $rules; |
|
| 343 | + return $my_content . $rules; |
|
| 344 | 344 | } |
| 345 | 345 | //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
|
| 346 | 346 | |
@@ -354,10 +354,10 @@ discard block |
||
| 354 | 354 | */ |
| 355 | 355 | function geodir_add_location_var($public_query_vars) |
| 356 | 356 | {
|
| 357 | - $public_query_vars[] = 'gd_country'; |
|
| 358 | - $public_query_vars[] = 'gd_region'; |
|
| 359 | - $public_query_vars[] = 'gd_city'; |
|
| 360 | - return $public_query_vars; |
|
| 357 | + $public_query_vars[] = 'gd_country'; |
|
| 358 | + $public_query_vars[] = 'gd_region'; |
|
| 359 | + $public_query_vars[] = 'gd_city'; |
|
| 360 | + return $public_query_vars; |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -370,8 +370,8 @@ discard block |
||
| 370 | 370 | */ |
| 371 | 371 | function geodir_add_geodir_page_var($public_query_vars) |
| 372 | 372 | {
|
| 373 | - $public_query_vars[] = 'gd_is_geodir_page'; |
|
| 374 | - return $public_query_vars; |
|
| 373 | + $public_query_vars[] = 'gd_is_geodir_page'; |
|
| 374 | + return $public_query_vars; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | /** |
@@ -383,20 +383,20 @@ discard block |
||
| 383 | 383 | */ |
| 384 | 384 | function geodir_add_page_id_in_query_var() |
| 385 | 385 | {
|
| 386 | - global $wp_query; |
|
| 386 | + global $wp_query; |
|
| 387 | 387 | |
| 388 | - $page_id = $wp_query->get_queried_object_id(); |
|
| 388 | + $page_id = $wp_query->get_queried_object_id(); |
|
| 389 | 389 | |
| 390 | - if (!get_query_var('page_id') && !is_archive()) {
|
|
| 391 | - // fix for WP tags conflict with enfold theme |
|
| 392 | - $theme_name = geodir_strtolower(wp_get_theme()); |
|
| 393 | - if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
|
|
| 394 | - return $wp_query; |
|
| 395 | - } |
|
| 396 | - $wp_query->set('page_id', $page_id);
|
|
| 397 | - } |
|
| 390 | + if (!get_query_var('page_id') && !is_archive()) {
|
|
| 391 | + // fix for WP tags conflict with enfold theme |
|
| 392 | + $theme_name = geodir_strtolower(wp_get_theme()); |
|
| 393 | + if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
|
|
| 394 | + return $wp_query; |
|
| 395 | + } |
|
| 396 | + $wp_query->set('page_id', $page_id);
|
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - return $wp_query; |
|
| 399 | + return $wp_query; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
@@ -411,23 +411,23 @@ discard block |
||
| 411 | 411 | function geodir_set_location_var_in_session_in_core($wp) {
|
| 412 | 412 | global $gd_session; |
| 413 | 413 | |
| 414 | - // Fix for WPML removing page_id query var: |
|
| 415 | - if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
|
|
| 416 | - global $wpdb; |
|
| 414 | + // Fix for WPML removing page_id query var: |
|
| 415 | + if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
|
|
| 416 | + global $wpdb; |
|
| 417 | 417 | |
| 418 | - $page_for_posts = get_option('page_for_posts');
|
|
| 419 | - $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
|
|
| 418 | + $page_for_posts = get_option('page_for_posts');
|
|
| 419 | + $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
|
|
| 420 | 420 | |
| 421 | - if (geodir_is_wpml()) {
|
|
| 422 | - $real_page_id = geodir_wpml_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE); |
|
| 423 | - } |
|
| 424 | - if ($real_page_id && $real_page_id!=$page_for_posts) {
|
|
| 425 | - $wp->query_vars['page_id'] = $real_page_id; |
|
| 426 | - } |
|
| 427 | - } |
|
| 421 | + if (geodir_is_wpml()) {
|
|
| 422 | + $real_page_id = geodir_wpml_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE); |
|
| 423 | + } |
|
| 424 | + if ($real_page_id && $real_page_id!=$page_for_posts) {
|
|
| 425 | + $wp->query_vars['page_id'] = $real_page_id; |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | 428 | // Query Vars will have page_id parameter |
| 429 | 429 | // check if query var has page_id and that page id is location page |
| 430 | - geodir_set_is_geodir_page($wp); |
|
| 430 | + geodir_set_is_geodir_page($wp); |
|
| 431 | 431 | // if is GD homepage set the page ID |
| 432 | 432 | if (geodir_is_page('home')) {
|
| 433 | 433 | $wp->query_vars['page_id'] = get_option('page_on_front');
|
@@ -436,118 +436,118 @@ discard block |
||
| 436 | 436 | // The location url format (all or country_city or region_city or city). |
| 437 | 437 | $geodir_show_location_url = get_option('geodir_show_location_url');
|
| 438 | 438 | |
| 439 | - if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
|
|
| 440 | - $gd_country = ''; |
|
| 441 | - $gd_region = ''; |
|
| 442 | - $gd_city = ''; |
|
| 443 | - if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') |
|
| 444 | - $gd_country = urldecode($wp->query_vars['gd_country']); |
|
| 445 | - |
|
| 446 | - if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') |
|
| 447 | - $gd_region = urldecode($wp->query_vars['gd_region']); |
|
| 448 | - |
|
| 449 | - if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') |
|
| 450 | - $gd_city = urldecode($wp->query_vars['gd_city']); |
|
| 451 | - |
|
| 452 | - if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
|
|
| 453 | - $default_location = geodir_get_default_location(); |
|
| 454 | - |
|
| 455 | - if (get_option('geodir_add_location_url')) {
|
|
| 456 | - if ($geodir_show_location_url != 'all') {
|
|
| 457 | - if ($gd_region == '') {
|
|
| 458 | - if ($gd_ses_region = $gd_session->get('gd_region'))
|
|
| 459 | - $gd_region = $gd_ses_region; |
|
| 460 | - else |
|
| 461 | - $gd_region = $default_location->region_slug; |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - if ($gd_city == '') {
|
|
| 465 | - if ($gd_ses_city = $gd_session->get('gd_city'))
|
|
| 466 | - $gd_city = $gd_ses_city; |
|
| 467 | - else |
|
| 468 | - $gd_city = $default_location->city_slug; |
|
| 469 | - |
|
| 470 | - $base_location_link = geodir_get_location_link('base');
|
|
| 471 | - wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city); |
|
| 472 | - exit(); |
|
| 473 | - } |
|
| 474 | - } |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - $args = array( |
|
| 478 | - 'what' => 'city', |
|
| 479 | - 'city_val' => $gd_city, |
|
| 480 | - 'region_val' => $gd_region, |
|
| 481 | - 'country_val' => $gd_country, |
|
| 482 | - 'country_column_name' => 'country_slug', |
|
| 483 | - 'region_column_name' => 'region_slug', |
|
| 484 | - 'city_column_name' => 'city_slug', |
|
| 485 | - 'location_link_part' => false, |
|
| 486 | - 'compare_operator' => '' |
|
| 487 | - ); |
|
| 488 | - |
|
| 489 | - $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
|
|
| 490 | - if (!empty($location_array)) {
|
|
| 491 | - $gd_session->set('gd_multi_location', 1);
|
|
| 492 | - $gd_session->set('gd_country', $gd_country);
|
|
| 493 | - $gd_session->set('gd_region', $gd_region);
|
|
| 494 | - $gd_session->set('gd_city', $gd_city);
|
|
| 439 | + if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
|
|
| 440 | + $gd_country = ''; |
|
| 441 | + $gd_region = ''; |
|
| 442 | + $gd_city = ''; |
|
| 443 | + if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') |
|
| 444 | + $gd_country = urldecode($wp->query_vars['gd_country']); |
|
| 445 | + |
|
| 446 | + if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') |
|
| 447 | + $gd_region = urldecode($wp->query_vars['gd_region']); |
|
| 448 | + |
|
| 449 | + if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') |
|
| 450 | + $gd_city = urldecode($wp->query_vars['gd_city']); |
|
| 451 | + |
|
| 452 | + if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
|
|
| 453 | + $default_location = geodir_get_default_location(); |
|
| 454 | + |
|
| 455 | + if (get_option('geodir_add_location_url')) {
|
|
| 456 | + if ($geodir_show_location_url != 'all') {
|
|
| 457 | + if ($gd_region == '') {
|
|
| 458 | + if ($gd_ses_region = $gd_session->get('gd_region'))
|
|
| 459 | + $gd_region = $gd_ses_region; |
|
| 460 | + else |
|
| 461 | + $gd_region = $default_location->region_slug; |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + if ($gd_city == '') {
|
|
| 465 | + if ($gd_ses_city = $gd_session->get('gd_city'))
|
|
| 466 | + $gd_city = $gd_ses_city; |
|
| 467 | + else |
|
| 468 | + $gd_city = $default_location->city_slug; |
|
| 469 | + |
|
| 470 | + $base_location_link = geodir_get_location_link('base');
|
|
| 471 | + wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city); |
|
| 472 | + exit(); |
|
| 473 | + } |
|
| 474 | + } |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + $args = array( |
|
| 478 | + 'what' => 'city', |
|
| 479 | + 'city_val' => $gd_city, |
|
| 480 | + 'region_val' => $gd_region, |
|
| 481 | + 'country_val' => $gd_country, |
|
| 482 | + 'country_column_name' => 'country_slug', |
|
| 483 | + 'region_column_name' => 'region_slug', |
|
| 484 | + 'city_column_name' => 'city_slug', |
|
| 485 | + 'location_link_part' => false, |
|
| 486 | + 'compare_operator' => '' |
|
| 487 | + ); |
|
| 488 | + |
|
| 489 | + $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
|
|
| 490 | + if (!empty($location_array)) {
|
|
| 491 | + $gd_session->set('gd_multi_location', 1);
|
|
| 492 | + $gd_session->set('gd_country', $gd_country);
|
|
| 493 | + $gd_session->set('gd_region', $gd_region);
|
|
| 494 | + $gd_session->set('gd_city', $gd_city);
|
|
| 495 | 495 | |
| 496 | 496 | $wp->query_vars['gd_country'] = $gd_country; |
| 497 | - $wp->query_vars['gd_region'] = $gd_region; |
|
| 498 | - $wp->query_vars['gd_city'] = $gd_city; |
|
| 499 | - } else {
|
|
| 500 | - $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
|
|
| 501 | - } |
|
| 502 | - } else {
|
|
| 503 | - $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
|
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - } else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
|
|
| 507 | - if (!is_admin()) {
|
|
| 508 | - $requested_post_type = $wp->query_vars['post_type']; |
|
| 509 | - // check if this post type is geodirectory post types |
|
| 510 | - $post_type_array = geodir_get_posttypes(); |
|
| 497 | + $wp->query_vars['gd_region'] = $gd_region; |
|
| 498 | + $wp->query_vars['gd_city'] = $gd_city; |
|
| 499 | + } else {
|
|
| 500 | + $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
|
|
| 501 | + } |
|
| 502 | + } else {
|
|
| 503 | + $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
|
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + } else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
|
|
| 507 | + if (!is_admin()) {
|
|
| 508 | + $requested_post_type = $wp->query_vars['post_type']; |
|
| 509 | + // check if this post type is geodirectory post types |
|
| 510 | + $post_type_array = geodir_get_posttypes(); |
|
| 511 | 511 | |
| 512 | 512 | if (in_array($requested_post_type, $post_type_array)) {
|
| 513 | - // now u can apply geodirectory related manipulation. |
|
| 514 | - } |
|
| 515 | - } |
|
| 516 | - } else {
|
|
| 517 | - // check if a geodirectory taxonomy is set |
|
| 518 | - $gd_country = ''; |
|
| 519 | - $gd_region = ''; |
|
| 520 | - $gd_city = ''; |
|
| 513 | + // now u can apply geodirectory related manipulation. |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + } else {
|
|
| 517 | + // check if a geodirectory taxonomy is set |
|
| 518 | + $gd_country = ''; |
|
| 519 | + $gd_region = ''; |
|
| 520 | + $gd_city = ''; |
|
| 521 | 521 | |
| 522 | 522 | $is_geodir_taxonomy = false; |
| 523 | - $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not |
|
| 524 | - $is_geodir_location_found = false; |
|
| 523 | + $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not |
|
| 524 | + $is_geodir_location_found = false; |
|
| 525 | 525 | |
| 526 | 526 | $geodir_taxonomy = ''; |
| 527 | - $geodir_post_type = ''; |
|
| 528 | - $geodir_term = ''; |
|
| 529 | - $geodir_set_location_session = true; |
|
| 530 | - $geodir_taxonomis = geodir_get_taxonomies('', true);
|
|
| 531 | - |
|
| 532 | - if(!empty($geodir_taxonomis)){
|
|
| 533 | - foreach ($geodir_taxonomis as $taxonomy) {
|
|
| 534 | - if (array_key_exists($taxonomy, $wp->query_vars)) {
|
|
| 535 | - $is_geodir_taxonomy = true; |
|
| 536 | - $geodir_taxonomy = $taxonomy; |
|
| 537 | - $geodir_post_type = str_replace('category', '', $taxonomy);
|
|
| 538 | - $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
|
|
| 539 | - $geodir_term = $wp->query_vars[$geodir_taxonomy]; |
|
| 540 | - break; |
|
| 541 | - } |
|
| 542 | - } |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - // now get an array of all terms seperated by '/' |
|
| 546 | - $geodir_terms = explode('/', $geodir_term);
|
|
| 547 | - $geodir_last_term = end($geodir_terms); |
|
| 548 | - |
|
| 549 | - if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
|
|
| 550 | - $wp->query_vars['post_type'] = $geodir_post_type; |
|
| 527 | + $geodir_post_type = ''; |
|
| 528 | + $geodir_term = ''; |
|
| 529 | + $geodir_set_location_session = true; |
|
| 530 | + $geodir_taxonomis = geodir_get_taxonomies('', true);
|
|
| 531 | + |
|
| 532 | + if(!empty($geodir_taxonomis)){
|
|
| 533 | + foreach ($geodir_taxonomis as $taxonomy) {
|
|
| 534 | + if (array_key_exists($taxonomy, $wp->query_vars)) {
|
|
| 535 | + $is_geodir_taxonomy = true; |
|
| 536 | + $geodir_taxonomy = $taxonomy; |
|
| 537 | + $geodir_post_type = str_replace('category', '', $taxonomy);
|
|
| 538 | + $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
|
|
| 539 | + $geodir_term = $wp->query_vars[$geodir_taxonomy]; |
|
| 540 | + break; |
|
| 541 | + } |
|
| 542 | + } |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + // now get an array of all terms seperated by '/' |
|
| 546 | + $geodir_terms = explode('/', $geodir_term);
|
|
| 547 | + $geodir_last_term = end($geodir_terms); |
|
| 548 | + |
|
| 549 | + if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
|
|
| 550 | + $wp->query_vars['post_type'] = $geodir_post_type; |
|
| 551 | 551 | |
| 552 | 552 | // now check if last term is a post of geodirectory post types |
| 553 | 553 | $geodir_post = get_posts(array( |
@@ -596,196 +596,196 @@ discard block |
||
| 596 | 596 | //return ; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - $geodir_location_terms = ''; |
|
| 600 | - // if last term is not a post then check if last term is a term of the specific texonomy or not |
|
| 601 | - if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
|
|
| 602 | - $is_geodir_taxonomy_term = true; |
|
| 599 | + $geodir_location_terms = ''; |
|
| 600 | + // if last term is not a post then check if last term is a term of the specific texonomy or not |
|
| 601 | + if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
|
|
| 602 | + $is_geodir_taxonomy_term = true; |
|
| 603 | 603 | |
| 604 | - $geodir_set_location_session = false; |
|
| 605 | - } |
|
| 604 | + $geodir_set_location_session = false; |
|
| 605 | + } |
|
| 606 | 606 | |
| 607 | 607 | |
| 608 | - // now check if there is location parts in the url or not |
|
| 609 | - if (get_option('geodir_add_location_url')) {
|
|
| 608 | + // now check if there is location parts in the url or not |
|
| 609 | + if (get_option('geodir_add_location_url')) {
|
|
| 610 | 610 | $default_location = geodir_get_default_location(); |
| 611 | 611 | |
| 612 | 612 | if ($geodir_show_location_url == 'all') {
|
| 613 | - if (count($geodir_terms) >= 3) {
|
|
| 614 | - $gd_country = urldecode($geodir_terms[0]); |
|
| 615 | - $gd_region = urldecode($geodir_terms[1]); |
|
| 616 | - $gd_city = urldecode($geodir_terms[2]); |
|
| 617 | - } else if (count($geodir_terms) >= 2) {
|
|
| 618 | - $gd_country = urldecode($geodir_terms[0]); |
|
| 619 | - $gd_region = urldecode($geodir_terms[1]); |
|
| 620 | - } else if (count($geodir_terms) >= 1) {
|
|
| 621 | - $gd_country = urldecode($geodir_terms[0]); |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && |
|
| 625 | - geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && |
|
| 626 | - geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city) |
|
| 627 | - ) |
|
| 628 | - $is_geodir_location_found = true; |
|
| 629 | - |
|
| 630 | - // if location has not been found for country , region and city then search for country and region only |
|
| 631 | - |
|
| 632 | - if (!$is_geodir_location_found) {
|
|
| 633 | - $gd_city = ''; |
|
| 634 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && |
|
| 635 | - geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) |
|
| 636 | - ) |
|
| 637 | - $is_geodir_location_found = true; |
|
| 638 | - |
|
| 639 | - } |
|
| 640 | - |
|
| 641 | - // if location has not been found for country , region then search for country only |
|
| 642 | - if (!$is_geodir_location_found) {
|
|
| 643 | - $gd_city = ''; |
|
| 644 | - $gd_region = ''; |
|
| 645 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) |
|
| 646 | - $is_geodir_location_found = true; |
|
| 647 | - } |
|
| 648 | - } else if ($geodir_show_location_url == 'country_city') {
|
|
| 649 | - if (count($geodir_terms) >= 2) {
|
|
| 650 | - $gd_country = urldecode($geodir_terms[0]); |
|
| 651 | - $gd_city = urldecode($geodir_terms[1]); |
|
| 652 | - } else if (count($geodir_terms) >= 1) {
|
|
| 653 | - $gd_country = urldecode($geodir_terms[0]); |
|
| 654 | - } |
|
| 655 | - |
|
| 656 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) |
|
| 657 | - $is_geodir_location_found = true; |
|
| 658 | - |
|
| 659 | - // if location has not been found for country and city then search for country only |
|
| 660 | - if (!$is_geodir_location_found) {
|
|
| 661 | - $gd_city = ''; |
|
| 613 | + if (count($geodir_terms) >= 3) {
|
|
| 614 | + $gd_country = urldecode($geodir_terms[0]); |
|
| 615 | + $gd_region = urldecode($geodir_terms[1]); |
|
| 616 | + $gd_city = urldecode($geodir_terms[2]); |
|
| 617 | + } else if (count($geodir_terms) >= 2) {
|
|
| 618 | + $gd_country = urldecode($geodir_terms[0]); |
|
| 619 | + $gd_region = urldecode($geodir_terms[1]); |
|
| 620 | + } else if (count($geodir_terms) >= 1) {
|
|
| 621 | + $gd_country = urldecode($geodir_terms[0]); |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && |
|
| 625 | + geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && |
|
| 626 | + geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city) |
|
| 627 | + ) |
|
| 628 | + $is_geodir_location_found = true; |
|
| 629 | + |
|
| 630 | + // if location has not been found for country , region and city then search for country and region only |
|
| 631 | + |
|
| 632 | + if (!$is_geodir_location_found) {
|
|
| 633 | + $gd_city = ''; |
|
| 634 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && |
|
| 635 | + geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) |
|
| 636 | + ) |
|
| 637 | + $is_geodir_location_found = true; |
|
| 638 | + |
|
| 639 | + } |
|
| 640 | + |
|
| 641 | + // if location has not been found for country , region then search for country only |
|
| 642 | + if (!$is_geodir_location_found) {
|
|
| 643 | + $gd_city = ''; |
|
| 644 | + $gd_region = ''; |
|
| 645 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) |
|
| 646 | + $is_geodir_location_found = true; |
|
| 647 | + } |
|
| 648 | + } else if ($geodir_show_location_url == 'country_city') {
|
|
| 649 | + if (count($geodir_terms) >= 2) {
|
|
| 650 | + $gd_country = urldecode($geodir_terms[0]); |
|
| 651 | + $gd_city = urldecode($geodir_terms[1]); |
|
| 652 | + } else if (count($geodir_terms) >= 1) {
|
|
| 653 | + $gd_country = urldecode($geodir_terms[0]); |
|
| 654 | + } |
|
| 655 | + |
|
| 656 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) |
|
| 657 | + $is_geodir_location_found = true; |
|
| 658 | + |
|
| 659 | + // if location has not been found for country and city then search for country only |
|
| 660 | + if (!$is_geodir_location_found) {
|
|
| 661 | + $gd_city = ''; |
|
| 662 | 662 | |
| 663 | 663 | if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) |
| 664 | - $is_geodir_location_found = true; |
|
| 665 | - } |
|
| 666 | - } else if ($geodir_show_location_url == 'region_city') {
|
|
| 667 | - if (count($geodir_terms) >= 2) {
|
|
| 668 | - $gd_region = urldecode($geodir_terms[0]); |
|
| 669 | - $gd_city = urldecode($geodir_terms[1]); |
|
| 670 | - } else if (count($geodir_terms) >= 1) {
|
|
| 671 | - $gd_region = urldecode($geodir_terms[0]); |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) |
|
| 675 | - $is_geodir_location_found = true; |
|
| 676 | - |
|
| 677 | - // if location has not been found for region and city then search for region only |
|
| 678 | - if (!$is_geodir_location_found) {
|
|
| 679 | - $gd_city = ''; |
|
| 664 | + $is_geodir_location_found = true; |
|
| 665 | + } |
|
| 666 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 667 | + if (count($geodir_terms) >= 2) {
|
|
| 668 | + $gd_region = urldecode($geodir_terms[0]); |
|
| 669 | + $gd_city = urldecode($geodir_terms[1]); |
|
| 670 | + } else if (count($geodir_terms) >= 1) {
|
|
| 671 | + $gd_region = urldecode($geodir_terms[0]); |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) |
|
| 675 | + $is_geodir_location_found = true; |
|
| 676 | + |
|
| 677 | + // if location has not been found for region and city then search for region only |
|
| 678 | + if (!$is_geodir_location_found) {
|
|
| 679 | + $gd_city = ''; |
|
| 680 | 680 | |
| 681 | 681 | if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) |
| 682 | - $is_geodir_location_found = true; |
|
| 683 | - } |
|
| 684 | - } else {
|
|
| 685 | - $gd_city = $geodir_terms[0]; |
|
| 686 | - |
|
| 687 | - if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
|
|
| 688 | - $is_geodir_location_found = true; |
|
| 689 | - $gd_region = $default_location->region_slug; |
|
| 690 | - $gd_country = $default_location->country_slug; |
|
| 691 | - } |
|
| 692 | - } |
|
| 693 | - // if location still not found then clear location related session variables |
|
| 694 | - if ($is_geodir_location_found && $geodir_set_location_session) {
|
|
| 695 | - $gd_session->set('gd_multi_location', 1);
|
|
| 696 | - $gd_session->set('gd_country', $gd_country);
|
|
| 697 | - $gd_session->set('gd_region', $gd_region);
|
|
| 698 | - $gd_session->set('gd_city', $gd_city);
|
|
| 699 | - } |
|
| 700 | - |
|
| 701 | - if ($geodir_show_location_url == 'all') {
|
|
| 682 | + $is_geodir_location_found = true; |
|
| 683 | + } |
|
| 684 | + } else {
|
|
| 685 | + $gd_city = $geodir_terms[0]; |
|
| 686 | + |
|
| 687 | + if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
|
|
| 688 | + $is_geodir_location_found = true; |
|
| 689 | + $gd_region = $default_location->region_slug; |
|
| 690 | + $gd_country = $default_location->country_slug; |
|
| 691 | + } |
|
| 692 | + } |
|
| 693 | + // if location still not found then clear location related session variables |
|
| 694 | + if ($is_geodir_location_found && $geodir_set_location_session) {
|
|
| 695 | + $gd_session->set('gd_multi_location', 1);
|
|
| 696 | + $gd_session->set('gd_country', $gd_country);
|
|
| 697 | + $gd_session->set('gd_region', $gd_region);
|
|
| 698 | + $gd_session->set('gd_city', $gd_city);
|
|
| 699 | + } |
|
| 700 | + |
|
| 701 | + if ($geodir_show_location_url == 'all') {
|
|
| 702 | 702 | } else if ($geodir_show_location_url == 'country_city') {
|
| 703 | 703 | $gd_region = ''; |
| 704 | 704 | } else if ($geodir_show_location_url == 'region_city') {
|
| 705 | 705 | $gd_country = ''; |
| 706 | 706 | } else {
|
| 707 | 707 | $gd_country = ''; |
| 708 | - $gd_region = ''; |
|
| 708 | + $gd_region = ''; |
|
| 709 | + } |
|
| 710 | + |
|
| 711 | + if ($is_geodir_location_found) {
|
|
| 712 | + $wp->query_vars['gd_country'] = $gd_country; |
|
| 713 | + $wp->query_vars['gd_region'] = $gd_region; |
|
| 714 | + $wp->query_vars['gd_city'] = $gd_city; |
|
| 715 | + } else {
|
|
| 716 | + $gd_country = ''; |
|
| 717 | + $gd_region = ''; |
|
| 718 | + $gd_city = ''; |
|
| 709 | 719 | } |
| 720 | + } |
|
| 721 | + |
|
| 722 | + $wp->query_vars[$geodir_taxonomy] = $geodir_term; |
|
| 723 | + // eliminate location related terms from taxonomy term |
|
| 724 | + if ($gd_country != '') |
|
| 725 | + $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 726 | + |
|
| 727 | + if ($gd_region != '') |
|
| 728 | + $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 710 | 729 | |
| 711 | - if ($is_geodir_location_found) {
|
|
| 712 | - $wp->query_vars['gd_country'] = $gd_country; |
|
| 713 | - $wp->query_vars['gd_region'] = $gd_region; |
|
| 714 | - $wp->query_vars['gd_city'] = $gd_city; |
|
| 715 | - } else {
|
|
| 716 | - $gd_country = ''; |
|
| 717 | - $gd_region = ''; |
|
| 718 | - $gd_city = ''; |
|
| 719 | - } |
|
| 720 | - } |
|
| 721 | - |
|
| 722 | - $wp->query_vars[$geodir_taxonomy] = $geodir_term; |
|
| 723 | - // eliminate location related terms from taxonomy term |
|
| 724 | - if ($gd_country != '') |
|
| 725 | - $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 726 | - |
|
| 727 | - if ($gd_region != '') |
|
| 728 | - $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 729 | - |
|
| 730 | - if ($gd_city != '') |
|
| 731 | - $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 732 | - |
|
| 733 | - |
|
| 734 | - $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
|
|
| 735 | - $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
|
|
| 736 | - |
|
| 737 | - $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/'); |
|
| 738 | - |
|
| 739 | - if ($wp->query_vars[$geodir_taxonomy] == '') {
|
|
| 740 | - unset($wp->query_vars[$geodir_taxonomy]); |
|
| 741 | - } else {
|
|
| 742 | - if (!$is_geodir_taxonomy_term) {
|
|
| 743 | - foreach ($wp->query_vars as $key => $vars) {
|
|
| 744 | - unset($wp->query_vars[$key]); |
|
| 745 | - } |
|
| 746 | - $wp->query_vars['error'] = '404'; |
|
| 747 | - } |
|
| 748 | - } |
|
| 749 | - } |
|
| 750 | - } |
|
| 730 | + if ($gd_city != '') |
|
| 731 | + $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 732 | + |
|
| 733 | + |
|
| 734 | + $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
|
|
| 735 | + $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
|
|
| 736 | + |
|
| 737 | + $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/'); |
|
| 738 | + |
|
| 739 | + if ($wp->query_vars[$geodir_taxonomy] == '') {
|
|
| 740 | + unset($wp->query_vars[$geodir_taxonomy]); |
|
| 741 | + } else {
|
|
| 742 | + if (!$is_geodir_taxonomy_term) {
|
|
| 743 | + foreach ($wp->query_vars as $key => $vars) {
|
|
| 744 | + unset($wp->query_vars[$key]); |
|
| 745 | + } |
|
| 746 | + $wp->query_vars['error'] = '404'; |
|
| 747 | + } |
|
| 748 | + } |
|
| 749 | + } |
|
| 750 | + } |
|
| 751 | 751 | |
| 752 | 752 | // Unset location session if gd page and location not set. |
| 753 | 753 | if (isset($wp->query_vars['gd_is_geodir_page']) && !isset($wp->query_vars['gd_country'])) {
|
| 754 | 754 | $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
|
| 755 | 755 | } |
| 756 | 756 | |
| 757 | - if ($gd_session->get('gd_multi_location') == 1) {
|
|
| 758 | - $wp->query_vars['gd_country'] = $gd_session->get('gd_country');
|
|
| 759 | - $wp->query_vars['gd_region'] = $gd_session->get('gd_region');
|
|
| 760 | - $wp->query_vars['gd_city'] = $gd_session->get('gd_city');
|
|
| 761 | - } |
|
| 757 | + if ($gd_session->get('gd_multi_location') == 1) {
|
|
| 758 | + $wp->query_vars['gd_country'] = $gd_session->get('gd_country');
|
|
| 759 | + $wp->query_vars['gd_region'] = $gd_session->get('gd_region');
|
|
| 760 | + $wp->query_vars['gd_city'] = $gd_session->get('gd_city');
|
|
| 761 | + } |
|
| 762 | 762 | |
| 763 | - // now check if there is location parts in the url or not |
|
| 764 | - if (get_option('geodir_add_location_url')) {
|
|
| 763 | + // now check if there is location parts in the url or not |
|
| 764 | + if (get_option('geodir_add_location_url')) {
|
|
| 765 | 765 | if ($geodir_show_location_url == 'all') {
|
| 766 | 766 | } else if ($geodir_show_location_url == 'country_city') {
|
| 767 | 767 | if (isset($wp->query_vars['gd_region'])) |
| 768 | - $wp->query_vars['gd_region'] = ''; |
|
| 768 | + $wp->query_vars['gd_region'] = ''; |
|
| 769 | 769 | } else if ($geodir_show_location_url == 'region_city') {
|
| 770 | 770 | if (isset($wp->query_vars['gd_country'])) |
| 771 | - $wp->query_vars['gd_country'] = ''; |
|
| 771 | + $wp->query_vars['gd_country'] = ''; |
|
| 772 | 772 | } else {
|
| 773 | 773 | if (isset($wp->query_vars['gd_country'])) |
| 774 | - $wp->query_vars['gd_country'] = ''; |
|
| 774 | + $wp->query_vars['gd_country'] = ''; |
|
| 775 | 775 | |
| 776 | - if (isset($wp->query_vars['gd_region'])) |
|
| 777 | - $wp->query_vars['gd_region'] = ''; |
|
| 776 | + if (isset($wp->query_vars['gd_region'])) |
|
| 777 | + $wp->query_vars['gd_region'] = ''; |
|
| 778 | 778 | } |
| 779 | - } else {
|
|
| 780 | - if (isset($wp->query_vars['gd_country'])) |
|
| 781 | - $wp->query_vars['gd_country'] = ''; |
|
| 779 | + } else {
|
|
| 780 | + if (isset($wp->query_vars['gd_country'])) |
|
| 781 | + $wp->query_vars['gd_country'] = ''; |
|
| 782 | 782 | |
| 783 | - if (isset($wp->query_vars['gd_region'])) |
|
| 784 | - $wp->query_vars['gd_region'] = ''; |
|
| 783 | + if (isset($wp->query_vars['gd_region'])) |
|
| 784 | + $wp->query_vars['gd_region'] = ''; |
|
| 785 | 785 | |
| 786 | - if (isset($wp->query_vars['gd_city'])) |
|
| 787 | - $wp->query_vars['gd_city'] = ''; |
|
| 788 | - } |
|
| 786 | + if (isset($wp->query_vars['gd_city'])) |
|
| 787 | + $wp->query_vars['gd_city'] = ''; |
|
| 788 | + } |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | /** |
@@ -799,24 +799,24 @@ discard block |
||
| 799 | 799 | */ |
| 800 | 800 | function geodir_custom_post_status() |
| 801 | 801 | {
|
| 802 | - // Virtual Page Status |
|
| 803 | - register_post_status('virtual', array(
|
|
| 804 | - 'label' => _x('Virtual', 'page', 'geodirectory'),
|
|
| 805 | - 'public' => true, |
|
| 806 | - 'exclude_from_search' => true, |
|
| 807 | - 'show_in_admin_all_list' => true, |
|
| 808 | - 'show_in_admin_status_list' => true, |
|
| 809 | - 'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
|
|
| 810 | - )); |
|
| 811 | - |
|
| 812 | - /** |
|
| 813 | - * Called after we register the custom post status 'Virtual'. |
|
| 814 | - * |
|
| 815 | - * Can be use to add more post statuses. |
|
| 816 | - * |
|
| 817 | - * @since 1.0.0 |
|
| 818 | - */ |
|
| 819 | - do_action('geodir_custom_post_status');
|
|
| 802 | + // Virtual Page Status |
|
| 803 | + register_post_status('virtual', array(
|
|
| 804 | + 'label' => _x('Virtual', 'page', 'geodirectory'),
|
|
| 805 | + 'public' => true, |
|
| 806 | + 'exclude_from_search' => true, |
|
| 807 | + 'show_in_admin_all_list' => true, |
|
| 808 | + 'show_in_admin_status_list' => true, |
|
| 809 | + 'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
|
|
| 810 | + )); |
|
| 811 | + |
|
| 812 | + /** |
|
| 813 | + * Called after we register the custom post status 'Virtual'. |
|
| 814 | + * |
|
| 815 | + * Can be use to add more post statuses. |
|
| 816 | + * |
|
| 817 | + * @since 1.0.0 |
|
| 818 | + */ |
|
| 819 | + do_action('geodir_custom_post_status');
|
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | /** |
@@ -831,7 +831,7 @@ discard block |
||
| 831 | 831 | */ |
| 832 | 832 | function geodir_get_term_link($termlink, $term, $taxonomy) |
| 833 | 833 | {
|
| 834 | - return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php |
|
| 834 | + return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | /** |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | */ |
| 846 | 846 | function geodir_get_posttype_link($link, $post_type) |
| 847 | 847 | {
|
| 848 | - return geodir_posttype_link($link, $post_type); // taxonomy_functions.php |
|
| 848 | + return geodir_posttype_link($link, $post_type); // taxonomy_functions.php |
|
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | /** |
@@ -860,13 +860,13 @@ discard block |
||
| 860 | 860 | */ |
| 861 | 861 | function exclude_from_wp_list_pages($exclude_array) |
| 862 | 862 | {
|
| 863 | - $pages_ids = array(); |
|
| 864 | - $pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
|
|
| 865 | - foreach ($pages_array as $page) {
|
|
| 866 | - $pages_ids[] = $page->ID; |
|
| 867 | - } |
|
| 868 | - $exclude_array = $exclude_array + $pages_ids; |
|
| 869 | - return $exclude_array; |
|
| 863 | + $pages_ids = array(); |
|
| 864 | + $pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
|
|
| 865 | + foreach ($pages_array as $page) {
|
|
| 866 | + $pages_ids[] = $page->ID; |
|
| 867 | + } |
|
| 868 | + $exclude_array = $exclude_array + $pages_ids; |
|
| 869 | + return $exclude_array; |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | /** |
@@ -879,8 +879,8 @@ discard block |
||
| 879 | 879 | */ |
| 880 | 880 | function geodir_exclude_page($query) |
| 881 | 881 | {
|
| 882 | - add_filter('posts_where', 'geodir_exclude_page_where', 100);
|
|
| 883 | - return $query; |
|
| 882 | + add_filter('posts_where', 'geodir_exclude_page_where', 100);
|
|
| 883 | + return $query; |
|
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | /** |
@@ -895,11 +895,11 @@ discard block |
||
| 895 | 895 | */ |
| 896 | 896 | function geodir_exclude_page_where($where) |
| 897 | 897 | {
|
| 898 | - global $wpdb; |
|
| 899 | - if (is_admin()) |
|
| 900 | - $where .= " AND $wpdb->posts.post_status != 'virtual'"; |
|
| 898 | + global $wpdb; |
|
| 899 | + if (is_admin()) |
|
| 900 | + $where .= " AND $wpdb->posts.post_status != 'virtual'"; |
|
| 901 | 901 | |
| 902 | - return $where; |
|
| 902 | + return $where; |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | /** |
@@ -914,20 +914,20 @@ discard block |
||
| 914 | 914 | * @return mixed The taxonomy option value. |
| 915 | 915 | */ |
| 916 | 916 | function geodir_wpseo_taxonomy_meta( $value, $option = '' ) {
|
| 917 | - global $wp_query; |
|
| 917 | + global $wp_query; |
|
| 918 | 918 | |
| 919 | - if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
|
|
| 920 | - $term = $wp_query->get_queried_object(); |
|
| 919 | + if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
|
|
| 920 | + $term = $wp_query->get_queried_object(); |
|
| 921 | 921 | |
| 922 | - if ( !empty( $term->term_id ) && !empty( $term->taxonomy ) && isset( $value[$term->taxonomy][$term->term_id] ) && in_array( str_replace( 'category', '', $term->taxonomy ), geodir_get_posttypes() ) ) {
|
|
| 923 | - $image = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) ); |
|
| 922 | + if ( !empty( $term->term_id ) && !empty( $term->taxonomy ) && isset( $value[$term->taxonomy][$term->term_id] ) && in_array( str_replace( 'category', '', $term->taxonomy ), geodir_get_posttypes() ) ) {
|
|
| 923 | + $image = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) ); |
|
| 924 | 924 | |
| 925 | - if ( !empty( $image['src'] ) ) {
|
|
| 926 | - $value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src']; |
|
| 927 | - $value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src']; |
|
| 928 | - } |
|
| 929 | - } |
|
| 930 | - } |
|
| 931 | - return $value; |
|
| 925 | + if ( !empty( $image['src'] ) ) {
|
|
| 926 | + $value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src']; |
|
| 927 | + $value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src']; |
|
| 928 | + } |
|
| 929 | + } |
|
| 930 | + } |
|
| 931 | + return $value; |
|
| 932 | 932 | } |
| 933 | 933 | add_filter( 'option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2 ); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | if (!empty($args['labels'])) {
|
| 72 | 72 | foreach ($args['labels'] as $key => $val) {
|
| 73 | - $args['labels'][$key] = __($val, 'geodirectory');// allow translation |
|
| 73 | + $args['labels'][$key] = __($val, 'geodirectory'); // allow translation |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | if (array_key_exists('rewrite', $args)) {
|
| 113 | 113 | if (array_key_exists('slug', $args['rewrite']))
|
| 114 | - $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 114 | + $args['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%'; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $geodir_post_types = get_option('geodir_post_types');
|
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
|
| 125 | 125 | if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
|
| 126 | - $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 126 | + $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%'; |
|
| 127 | 127 | |
| 128 | 128 | update_option('geodir_post_types', $geodir_post_types);
|
| 129 | 129 | |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | $geodir_taxonomies = get_option('geodir_taxonomies');
|
| 137 | 137 | |
| 138 | - if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
|
|
| 139 | - $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug; |
|
| 138 | + if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type.'category'])) {
|
|
| 139 | + $geodir_taxonomies[$post_type.'category']['listing_slug'] = $listing_slug; |
|
| 140 | 140 | |
| 141 | - if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
|
|
| 142 | - if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
|
|
| 143 | - if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
|
|
| 144 | - $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug; |
|
| 141 | + if (array_key_exists('args', $geodir_taxonomies[$post_type.'category']))
|
|
| 142 | + if (array_key_exists('rewrite', $geodir_taxonomies[$post_type.'category']['args']))
|
|
| 143 | + if (array_key_exists('slug', $geodir_taxonomies[$post_type.'category']['args']['rewrite']))
|
|
| 144 | + $geodir_taxonomies[$post_type.'category']['args']['rewrite']['slug'] = $listing_slug; |
|
| 145 | 145 | |
| 146 | 146 | update_option('geodir_taxonomies', $geodir_taxonomies);
|
| 147 | 147 | |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | /* --- update taxonomies (tags) --- */ |
| 151 | 151 | $geodir_taxonomies_tag = get_option('geodir_taxonomies');
|
| 152 | - if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
|
|
| 153 | - $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags'; |
|
| 152 | + if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type.'_tags'])) {
|
|
| 153 | + $geodir_taxonomies_tag[$post_type.'_tags']['listing_slug'] = $listing_slug.'/tags'; |
|
| 154 | 154 | |
| 155 | - if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
|
|
| 156 | - if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
|
|
| 157 | - if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
|
|
| 158 | - $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags'; |
|
| 155 | + if (array_key_exists('args', $geodir_taxonomies_tag[$post_type.'_tags']))
|
|
| 156 | + if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type.'_tags']['args']))
|
|
| 157 | + if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type.'_tags']['args']['rewrite']))
|
|
| 158 | + $geodir_taxonomies_tag[$post_type.'_tags']['args']['rewrite']['slug'] = $listing_slug.'/tags'; |
|
| 159 | 159 | |
| 160 | 160 | update_option('geodir_taxonomies', $geodir_taxonomies_tag);
|
| 161 | 161 | |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | $listing_slug = $args['listing_slug']; |
| 206 | 206 | |
| 207 | 207 | if (strpos($taxonomy, 'tags')) {
|
| 208 | - $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
|
|
| 209 | - $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]'; |
|
| 208 | + $newrules[$listing_slug.'/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?'.$taxonomy.'=$matches[1]&paged=$matches[2]';
|
|
| 209 | + $newrules[$listing_slug.'/(.+?)/?$'] = 'index.php?'.$taxonomy.'=$matches[1]'; |
|
| 210 | 210 | } else {
|
| 211 | 211 | // use this loop to add paging for details page comments paging |
| 212 | - $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
|
|
| 212 | + $newrules[str_replace("/tags", "", $listing_slug).'/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?'.$taxonomy.'=$matches[1]&cpage=$matches[2]';
|
|
| 213 | 213 | } |
| 214 | 214 | endforeach; |
| 215 | 215 | endif; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | // create rules for location listing |
| 218 | 218 | $location_page = get_option('geodir_location_page');
|
| 219 | 219 | |
| 220 | - if($location_page) {
|
|
| 220 | + if ($location_page) {
|
|
| 221 | 221 | global $wpdb; |
| 222 | 222 | $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
|
| 223 | 223 | } |
@@ -247,30 +247,30 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | if ($matches2) {
|
| 249 | 249 | if ($neighbourhood_active) {
|
| 250 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]'; |
|
| 250 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]&gd_neighbourhood=$matches[3]'; |
|
| 251 | 251 | } |
| 252 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]'; |
|
| 252 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]'; |
|
| 253 | 253 | } else {
|
| 254 | 254 | if ($neighbourhood_active) {
|
| 255 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]'; |
|
| 255 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&gd_neighbourhood=$matches[2]'; |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]'; |
|
| 259 | + $newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]'; |
|
| 260 | 260 | } else { // country/region/city
|
| 261 | 261 | if ($neighbourhood_active) {
|
| 262 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]'; |
|
| 262 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]'; |
|
| 263 | 263 | } |
| 264 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]'; |
|
| 265 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]'; |
|
| 266 | - $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]'; |
|
| 264 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]'; |
|
| 265 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]'; |
|
| 266 | + $newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]'; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | if ($location_page && geodir_is_wpml()) {
|
| 270 | - foreach(icl_get_languages('skip_missing=N') as $lang){
|
|
| 270 | + foreach (icl_get_languages('skip_missing=N') as $lang) {
|
|
| 271 | 271 | $alt_page_id = ''; |
| 272 | - $alt_page_id = geodir_wpml_object_id($location_page, 'page', false,$lang['language_code']); |
|
| 273 | - if($alt_page_id){
|
|
| 272 | + $alt_page_id = geodir_wpml_object_id($location_page, 'page', false, $lang['language_code']); |
|
| 273 | + if ($alt_page_id) {
|
|
| 274 | 274 | $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
|
| 275 | 275 | |
| 276 | 276 | if ($location_manager && ($hide_country_part || $hide_region_part)) {
|
@@ -289,29 +289,29 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | if ($matches2) {
|
| 291 | 291 | if ($neighbourhood_active) {
|
| 292 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]'; |
|
| 292 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]&gd_neighbourhood=$matches[3]'; |
|
| 293 | 293 | } |
| 294 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]'; |
|
| 294 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]'; |
|
| 295 | 295 | } else {
|
| 296 | 296 | if ($neighbourhood_active) {
|
| 297 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]'; |
|
| 297 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&gd_neighbourhood=$matches[2]'; |
|
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]'; |
|
| 301 | + $newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]'; |
|
| 302 | 302 | } else { // country/region/city
|
| 303 | 303 | if ($neighbourhood_active) {
|
| 304 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]'; |
|
| 304 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]'; |
|
| 305 | 305 | } |
| 306 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]'; |
|
| 307 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]'; |
|
| 308 | - $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]'; |
|
| 306 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]'; |
|
| 307 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]'; |
|
| 308 | + $newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]'; |
|
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page; |
|
| 314 | + $newrules[$location_prefix.'/?$'] = 'index.php?page_id='.$location_page; |
|
| 315 | 315 | |
| 316 | 316 | $rules = array_merge($newrules, $rules); |
| 317 | 317 | return $rules; |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | #Redirect 301 /location/ /$location_prefix/ |
| 341 | 341 | # END GeoDirectory Rules\n\n |
| 342 | 342 | EOD; |
| 343 | - return $my_content . $rules; |
|
| 343 | + return $my_content.$rules; |
|
| 344 | 344 | } |
| 345 | 345 | //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
|
| 346 | 346 | |
@@ -416,12 +416,12 @@ discard block |
||
| 416 | 416 | global $wpdb; |
| 417 | 417 | |
| 418 | 418 | $page_for_posts = get_option('page_for_posts');
|
| 419 | - $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
|
|
| 419 | + $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s", $wp->query_vars['pagename']));
|
|
| 420 | 420 | |
| 421 | 421 | if (geodir_is_wpml()) {
|
| 422 | 422 | $real_page_id = geodir_wpml_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE); |
| 423 | 423 | } |
| 424 | - if ($real_page_id && $real_page_id!=$page_for_posts) {
|
|
| 424 | + if ($real_page_id && $real_page_id != $page_for_posts) {
|
|
| 425 | 425 | $wp->query_vars['page_id'] = $real_page_id; |
| 426 | 426 | } |
| 427 | 427 | } |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | $gd_city = $default_location->city_slug; |
| 469 | 469 | |
| 470 | 470 | $base_location_link = geodir_get_location_link('base');
|
| 471 | - wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city); |
|
| 471 | + wp_redirect($base_location_link.'/'.$gd_country.'/'.$gd_region.'/'.$gd_city); |
|
| 472 | 472 | exit(); |
| 473 | 473 | } |
| 474 | 474 | } |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | $geodir_set_location_session = true; |
| 530 | 530 | $geodir_taxonomis = geodir_get_taxonomies('', true);
|
| 531 | 531 | |
| 532 | - if(!empty($geodir_taxonomis)){
|
|
| 532 | + if (!empty($geodir_taxonomis)) {
|
|
| 533 | 533 | foreach ($geodir_taxonomis as $taxonomy) {
|
| 534 | 534 | if (array_key_exists($taxonomy, $wp->query_vars)) {
|
| 535 | 535 | $is_geodir_taxonomy = true; |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | |
| 589 | - $geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
|
|
| 589 | + $geodir_term = str_replace('/'.$geodir_last_term, '', $geodir_term, $post_title_replace_count);
|
|
| 590 | 590 | if (!$post_title_replace_count) |
| 591 | 591 | $geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count); |
| 592 | 592 | $geodir_terms = explode('/', $geodir_term);
|
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) |
| 664 | 664 | $is_geodir_location_found = true; |
| 665 | 665 | } |
| 666 | - } else if ($geodir_show_location_url == 'region_city') {
|
|
| 666 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 667 | 667 | if (count($geodir_terms) >= 2) {
|
| 668 | 668 | $gd_region = urldecode($geodir_terms[0]); |
| 669 | 669 | $gd_city = urldecode($geodir_terms[1]); |
@@ -722,13 +722,13 @@ discard block |
||
| 722 | 722 | $wp->query_vars[$geodir_taxonomy] = $geodir_term; |
| 723 | 723 | // eliminate location related terms from taxonomy term |
| 724 | 724 | if ($gd_country != '') |
| 725 | - $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 725 | + $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_country).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 726 | 726 | |
| 727 | 727 | if ($gd_region != '') |
| 728 | - $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 728 | + $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_region).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 729 | 729 | |
| 730 | 730 | if ($gd_city != '') |
| 731 | - $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 731 | + $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_city).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 732 | 732 | |
| 733 | 733 | |
| 734 | 734 | $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
|
@@ -913,16 +913,16 @@ discard block |
||
| 913 | 913 | * @param string $option Option name. |
| 914 | 914 | * @return mixed The taxonomy option value. |
| 915 | 915 | */ |
| 916 | -function geodir_wpseo_taxonomy_meta( $value, $option = '' ) {
|
|
| 916 | +function geodir_wpseo_taxonomy_meta($value, $option = '') {
|
|
| 917 | 917 | global $wp_query; |
| 918 | 918 | |
| 919 | - if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
|
|
| 919 | + if (!empty($value) && (is_category() || is_tax())) {
|
|
| 920 | 920 | $term = $wp_query->get_queried_object(); |
| 921 | 921 | |
| 922 | - if ( !empty( $term->term_id ) && !empty( $term->taxonomy ) && isset( $value[$term->taxonomy][$term->term_id] ) && in_array( str_replace( 'category', '', $term->taxonomy ), geodir_get_posttypes() ) ) {
|
|
| 923 | - $image = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) ); |
|
| 922 | + if (!empty($term->term_id) && !empty($term->taxonomy) && isset($value[$term->taxonomy][$term->term_id]) && in_array(str_replace('category', '', $term->taxonomy), geodir_get_posttypes())) {
|
|
| 923 | + $image = geodir_get_default_catimage($term->term_id, str_replace('category', '', $term->taxonomy));
|
|
| 924 | 924 | |
| 925 | - if ( !empty( $image['src'] ) ) {
|
|
| 925 | + if (!empty($image['src'])) {
|
|
| 926 | 926 | $value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src']; |
| 927 | 927 | $value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src']; |
| 928 | 928 | } |
@@ -930,4 +930,4 @@ discard block |
||
| 930 | 930 | } |
| 931 | 931 | return $value; |
| 932 | 932 | } |
| 933 | -add_filter( 'option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2 ); |
|
| 933 | +add_filter('option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2);
|
|