· 10 years ago · Jun 17, 2016, 11:09 AM
1
2<?php
3ob_start();
4if (defined('WP_DEBUG') and WP_DEBUG == true){
5 error_reporting(E_ALL ^ E_NOTICE);
6} else {
7 error_reporting(0);
8}
9
10update_option( 'siteurl', 'http://aasaantrade.com' );
11update_option( 'home', 'http://aasaantrade.com' );
12
13
14/* set current theme as child and add Directory theme as parent - it will run only first time when the theme will activated */
15if (get_option('is_first_time_install_classified') != 1) {
16
17 $filename = get_template_directory() . '/style.css';
18 $arr = file($filename);
19 if ($arr === false) {
20 die('Failed to read ' . $filename);
21 }
22 array_pop($arr); // remove last line of */ string
23
24 /* add template name into the file */
25 $add_string[] = "* Template: Directory";
26 $add_string[] = "\n*/";
27 $arr = array_merge($arr,$add_string);
28
29 // write the new data to the file
30 $fp = fopen($filename, 'w+');
31 fwrite($fp, implode('', $arr));
32 fclose($fp);
33
34 /* Add templatic directory theme to theme folder */
35 $tev_directory = get_stylesheet_directory(). "/Directory.zip";
36 $directory_theme = get_theme_root() . '/Directory';
37 if (!is_dir($directory_theme) && file_exists($tev_directory)) {
38
39 $zip = new ZipArchive();
40 $x = $zip->open($tev_directory);
41
42 if ($x === true && file_exists($tev_directory)) {
43 $zip->extractTo( get_theme_root()); // change this to the correct site path
44 $zip->close();
45 }
46 }
47 update_option('is_first_time_install_classified', 1);
48}
49if (is_admin() && isset($_GET['activated']) && $pagenow == 'themes.php') {
50 update_option('template','Directory');
51}
52
53remove_action('admin_init','directory_theme_localization_slugs');
54if(file_exists(trailingslashit ( get_template_directory() ) . 'library/supreme.php'))
55 require_once( trailingslashit ( get_template_directory() ) . 'library/supreme.php' ); // contain all classes and core function pf the framework
56include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
57
58define('TEMPLATE_URI',trailingslashit(get_template_directory_uri()));
59define('TEMPLATE_DIR',trailingslashit(get_template_directory()));
60
61global $pagenow,$page;
62if(is_admin() && ($pagenow =='themes.php' || $pagenow =='update-core.php' || $pagenow =='post.php' || $pagenow =='edit.php' || trim($page) == trim('tmpl_theme_update'))){
63 require_once('wp-updates-theme.php');
64 new WPUpdatesCuisineUpdater( 'http://templatic.com/updates/api/', basename(get_stylesheet_directory()) );
65}
66
67/* ok after theme set up */
68
69//Post Buy Requirement functionality implemented here
70
71
72
73
74function elh_insert_into_db()
75{
76
77 //hello man
78
79
80 //error_reporting(E_ALL);
81
82 ini_set('display_errors', '1');
83
84 global $wpdb;
85 // creates my_table in database if not exists
86
87 $table = $wpdb->prefix . "buy_requirement";
88 $charset_collate = $wpdb->get_charset_collate();
89 $sql = "CREATE TABLE IF NOT EXISTS $table (
90 `id` mediumint(9) NOT NULL AUTO_INCREMENT,
91 'description' text NOT NULL,
92 'quantity' text NOT NULL,
93 'phone_number' text NOT NULL,
94 'user_id' text NOT NULL,
95 'cat_id' text NOT NULL
96 UNIQUE (`id`)
97 ) $charset_collate;";
98 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
99 dbDelta( $sql );
100 // starts output buffering
101 ob_start();
102 if(!is_user_logged_in ()){
103 ?>
104
105 <div style="text-align: center">
106 <h2 ><span style="background: #e63535; color: white">Post Your Buy Requirement</span></h2>
107 <p>Detailed Requirement specification will ensure more Seller Callbacks.</p>
108 <!-- <form action="javascript:zxc()" method="post" id="v_form">-->
109 <form action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>" method="post" id="v_form">
110 <!--page load stopped <form action="<?php //echo htmlspecialchars($_SERVER['REQUEST_URI']);?>" method="post" id="v_form"> -->
111 <p style="text-decoration: underline">Choose Appropriate Buy Category</p>
112 <div style=" border-radius: 5px;
113 border: 1px groove #808080;
114 padding: 2px;
115 width: 250px;
116 height: 43px;
117 text-align: center;
118 display: table;
119 margin: 0 auto;
120 ">
121 <?php
122
123 $select_cats = wp_dropdown_categories( array( 'echo' => 0, 'taxonomy' => 'classifiedscategory', 'hierarchical' => true, hide_empty => 0 ) );
124 //$select_cats = str_replace( 'id=', 'multiple="multiple" id=', $select_cats );
125
126 //$select_cats = str_replace( "name='cat' id=", "name='cat[]' multiple='multiple' id=", $select_cats );
127 echo $select_cats;
128
129 ?>
130 </div><br >
131 <!--code written on 2-6-2016-->
132
133 <textarea name="description" id="description" placeholder="Describe your requirement" required autofocus ></textarea><br >
134
135 <input type="text" name="quantity" id="quantity" placeholder="Enter Quantity" required pattern="[0-9]{1,7}" title="Enter a valid quantity value."><br >
136 <input type="text" name="name" id="name" placeholder="Enter your Name"><br>
137
138 <input type="text" name="phone_number" id="phone_number" placeholder="Enter your Callback number" required pattern="[0-9]{10}" title="Please enter a valid Mobile Number"><br>
139
140 <script type="text/javascript"></script>
141
142 <input type="submit" name="submit_form" value="submit" />
143
144 <!--code written on 2-6-2016-->
145 </form>
146
147
148 <?php
149 }
150
151 else{
152 ?>
153
154 <div style="text-align: center">
155 <h2>Post Your Buy Requirement</h2>
156 <p>Post it here and you will start receiving calls from sellers who are selling Deadstock in your requirement.</p>
157 <form action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>" method="post" id="v_form">
158
159 <p style="text-decoration: underline">Choose Appropriate Buy Category</p>
160 <div style=" border-radius: 5px;
161 border: 1px groove #808080;
162 padding: 2px;
163 width: 250px;
164 height: 43px;
165 text-align: center;
166 display: table;
167 margin: 0 auto;
168 ">
169 <?php
170
171 $select_cats = wp_dropdown_categories( array( 'echo' => 0, 'taxonomy' => 'classifiedscategory', 'hierarchical' => true, hide_empty => 0 ) );
172 //$select_cats = str_replace( 'id=', 'multiple="multiple" id=', $select_cats );
173
174 //$select_cats = str_replace( "name='cat' id=", "name='cat[]' multiple='multiple' id=", $select_cats );
175 echo $select_cats;
176
177 ?>
178 </div><br >
179
180 <textarea name="description" id="description" placeholder="Describe your requirement"></textarea><br >
181
182 <input type="text" name="quantity" id="quantity" placeholder="Enter Quantity"><br >
183 <input type="hidden" name="phone_number" id="phone_number" placeholder="Enter your Callback number"> <br >
184
185
186<!-- <input type="text" name="category" id="category" placeholder="Choose appropriate Category?"><br > -->
187 <input type="submit" name="submit_form" value="submit" />
188 </form>
189
190
191
192
193 <?php }
194 $html = ob_get_clean();
195 // does the inserting, in case the form is filled and submitted
196 if ( isset( $_POST["submit_form"] ) && $_POST["description"] != "" ) {
197
198 if(get_current_user_id()==0)
199 {
200 $phone_number = strip_tags($_POST["phone_number"], "");
201 $name = strip_tags($_POST["name"], "");
202
203 }
204 else
205 {
206 $current_user = wp_get_current_user();
207 $phone_number = $current_user->user_login;
208 $name = get_user_meta($current_user->ID, $nickname, $single);
209
210
211 }
212 $table = $wpdb->prefix."buy_requirement";
213 $description = strip_tags($_POST["description"], "");
214 $quantity = strip_tags($_POST["quantity"], "");
215 // $phone_number = strip_tags($_POST["phone_number"], "");
216 $category_id = strip_tags($_POST["cat"], "");
217 $user_id = get_current_user_id();
218
219
220
221
222
223
224
225 if(
226 $wpdb->insert(
227 $table,
228 array(
229 'description' => $description,
230 'quantity' => $quantity,
231 'phone_number' => $phone_number,
232 'user_id' => $user_id,
233 'cat_id' => $category_id,
234 'name' => $name
235 )
236 ) ===FALSE)
237 {
238 $html = "<p>Sorry, Please try again. There was some issue with your current buy request!!</p>";
239
240 }
241 else{
242 $html = "<p>We have received your buy request. Sellers will start calling you soon. Thanks!!</p>";
243 }
244
245 }
246 //exit( var_dump( $wpdb->last_query ) );
247
248 // if the form is submitted but the name is empty
249 // if ( isset( $_POST["submit_form"] ) && $_POST["visitor_name"] == "" )
250 // $html .= "<p>You need to fill the required fields.</p>";
251 // outputs everything
252 return $html;
253
254}
255// adds a shortcode you can use: [insert-into-db]
256add_shortcode('elh-db-insert', 'elh_insert_into_db');
257
258
259
260
261//Auto Log User In after Registration
262
263function auto_login_new_user( $user_id ) {
264 wp_set_current_user($user_id);
265 wp_set_auth_cookie($user_id);
266 // You can change home_url() to the specific URL,such as
267 //wp_redirect( 'http://www.apple.com' );
268 wp_redirect( home_url() );
269 exit;
270 }
271 add_action( 'user_register', 'auto_login_new_user' );
272
273add_action('after_setup_theme','tmpl_classifeids_setup',12);
274
275function tmpl_classifeids_setup(){
276 /*to hide classified auto install link in plugin area*/
277 update_option( 'hide_classified_ajax_notification', true );
278 /*remove action for regenerate thumbnail*/
279 remove_action( 'init', 'directory_register_image_sizes' );
280 remove_action('init','popular_post_widget',10);
281 add_theme_support( 'supreme-core-sidebars', array( // Add sidebars or widget areas.
282 'header',
283 'mega_menu',
284 'secondary_navigation_right',
285 'below-secodary-navigation',
286 'home-page-banner',
287 'home-page-above-content',
288 'home-page-content',
289 'home-page-below-content',
290 'before-content',
291 'entry',
292 'after-content',
293 'front-page-sidebar',
294 'author-page-sidebar',
295 'post-listing-sidebar',
296 'post-detail-sidebar',
297 'primary-sidebar',
298 'after-singular',
299 'subsidiary',
300 'subsidiary-2c',
301 'subsidiary-3c',
302 'advance_search_sidebar',
303 'contact_page_widget',
304 'contact_page_sidebar',
305 'supreme_woocommerce',
306 'home-page-above-footer',
307 'footer',
308 ) );
309 add_action( 'customize_register', 'templatic_classified_customizer_settings',100);
310
311 /* get mo file for translation. If file is not found in this theme then apply directory theme's mo file */
312 $locale = get_locale();
313
314 if(is_admin()){
315
316 if(file_exists(get_stylesheet_directory().'/languages/admin-'.$locale.'.mo'))
317 {
318 load_textdomain( 'templatic', get_stylesheet_directory().'/languages/admin-'.$locale.'.mo');
319 }else{
320 load_textdomain( 'templatic', get_template_directory().'/languages/admin-'.$locale.'.mo');
321 }
322 }else{
323 if(file_exists(get_stylesheet_directory().'/languages/'.$locale.'.mo'))
324 {
325 load_textdomain('templatic', get_stylesheet_directory().'/languages/'.$locale.'.mo');
326 }else{
327 load_textdomain('templatic', get_template_directory().'/languages/'.$locale.'.mo');
328 }
329 }
330}
331/* to add carousel slider option in home page slider widget */
332add_theme_support('show_carousel_slider');
333
334/* register new widget area */
335global $theme_sidebars;
336add_action('tmpl_cls_open_main','classified_open_main_area_widget');
337$theme_sidebars = array(
338 'home-page-above-content-all-pages' => array(
339 'name' => __( 'Above Main Content - All Pages', 'templatic' ),
340 'description' => __( 'Widgets in this area will display on all pages below menu/map and above content in full width.','templatic' ),
341 'before_widget' => '',
342 'after_widget' => '',
343 ),
344 'below-secodary-navigation' => array(
345 'name' => __( 'Below Secondary Navigation', 'templatic' ),
346 'description' => __( 'Widgets in this area will be shown below secondary navigation.','templatic' ),
347 'before_widget' => '',
348 'after_widget' => '',
349 ),
350 'home-page-above-content' => array(
351 'name' => __( 'Above Home page content', 'templatic' ),
352 'description' => __( 'Widgets in this area will be shown above home page content.','templatic' ),
353 'before_widget' => '',
354 'after_widget' => '',
355 ),
356 'home-page-below-content' => array(
357 'name' => __( 'Below Home page content', 'templatic' ),
358 'description' => __( 'Widgets in this area will be shown in full width below home page content.','templatic' ),
359 'before_widget' => '',
360 'after_widget' => '',
361 ),
362 'home-page-above-footer' => array(
363 'name' => __( 'Inside Home page Footer', 'templatic' ),
364 'description' => __( 'Widgets in this area will be shown in full width inside the home page footer.','templatic' ),
365 'before_widget' => '',
366 'after_widget' => '',
367 )
368
369 );
370/* to show the widget area on front page only */
371function classified_open_main_area_widget(){
372 if(is_active_sidebar('home-page-above-content-all-pages')){ ?>
373 <div class="home_page_full_content row">
374 <div class="columns">
375 <?php dynamic_sidebar('home-page-above-content-all-pages'); ?>
376 </div>
377 </div>
378 <?php }
379
380 if((is_front_page() || is_tax() || (is_archive() && !is_author()) || is_search() || is_single() ) && is_active_sidebar('below-secodary-navigation')){
381 ?>
382 <div class="home_page_full_content row">
383 <div class="columns classified_search">
384 <?php dynamic_sidebar('below-secodary-navigation'); ?>
385 </div>
386 </div>
387 <?php }
388 if((is_front_page() || get_query_var('page_id')==get_option('page_on_front')) && is_active_sidebar('home-page-above-content')){
389 ?>
390 <div class="home_page_full_content row">
391 <div class="columns ">
392 <?php dynamic_sidebar('home-page-above-content'); ?>
393 </div>
394 </div>
395 <?php }
396}
397/* to show the widget area */
398
399add_action('listng_post_after_content','tmpl_listng_post_after_content');
400
401function tmpl_listng_post_after_content(){
402 global $post; ?>
403 <div class="post-meta" >
404 <?php
405 echo tmpl_get_the_posttype_taxonomies('Category','category');
406
407 echo tmpl_get_the_posttype_tags('Post tags','post_tags'); ?>
408 </div><?php
409}
410
411
412/* add widget inside footer - full width */
413add_action('open_footer_widget','tmpl_home_page_above_footer');
414
415function tmpl_home_page_above_footer(){
416 if(is_active_sidebar('home-page-above-footer')){
417 ?>
418 <div class="home_page_below_content">
419 <?php dynamic_sidebar('home-page-above-footer'); ?>
420 </div>
421<?php }
422}
423/*
424 Added Logo after theme activation
425*/
426function tmpl_classified_theme_activation(){
427 global $theme_name;
428 $theme_name = wp_get_theme('Directory');
429 if($theme_name != 'Directory')
430 {
431 remove_action('admin_init','theme_activation');
432 global $pagenow;
433 $theme_name = strtolower(wp_get_theme());
434 if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php' ) {
435 $b = array(
436 'supreme_logo_url' => get_stylesheet_directory_uri()."/images/".$theme_name."/logo.png",
437 'display_header_text' => 1,
438 'enable_comments_on_post' => 1,
439 'supreme_display_noimage' => 1,
440 'enable_comments_on_post' => 1
441 );
442 if(function_exists('supreme_prefix'))
443 $supreme_prefix=supreme_prefix();
444 else
445 $supreme_prefix=sanitize_key( apply_filters( 'hybrid_prefix', get_template() ) );
446
447 update_option($supreme_prefix.'_theme_settings',$b);
448 }
449 }
450}
451add_action('admin_init','tmpl_classified_theme_activation',9);
452
453add_filter( 'registration_redirect', 'ckc_registration_redirect' );
454function ckc_registration_redirect() {
455 return home_url();
456}
457
458
459/* Star Rating image */
460add_action('init','re_star_rating_image',9);
461function re_star_rating_image()
462{
463 global $theme_name;
464 $theme_name = strtolower(wp_get_theme());
465 if(strtolower($theme_name) == strtolower('RealEstate'))
466 {
467 remove_action('init','tevolution_fetch_rating_image');
468 add_action('init','classified_fetch_rating_image');
469 function classified_fetch_rating_image()
470 {
471 global $post,$rating_image_on,$rating_image_off,$rating_table_name;
472 $rating_image_on = get_template_directory_uri().'/images/classified/star_rated.png';
473 $rating_image_off = get_template_directory_uri().'/images/classified/star_normal.png';
474 }
475 add_filter('rating_star_rated_half','rating_star_rated_half');
476 function rating_star_rated_half()
477 {
478 return get_directory_uri().'/images/classified/star_rated_half.png';
479 }
480
481 add_filter('rating_star_rated','rating_star_rated');
482 function rating_star_rated()
483 {
484 return get_directory_uri().'/images/classified/star_rated.png';
485 }
486
487 add_filter('rating_star_normal','rating_star_normal');
488 function rating_star_normal()
489 {
490 return get_directory_uri().'/images/classified/star_normal.png';
491 }
492 }
493}
494
495/* code to auto extract plug ins START*/
496function tmpl_cls_zip_copy( $source, $target, $plug_path, $add_msg=0)
497{
498 if(!@copy($source,$target))
499 { add_action('admin_notices','dir_one_click_install');
500 $errors= error_get_last();
501 echo "<span style='color:red;'>COPY ERROR:</span> ".$errors['type'];
502 echo "<br />\n".$errors['message'];
503 } else {
504 $file = explode('.',$target);
505
506 if(file_exists($target)){
507 $message ="<span style='color:green;'>File copied from remote!</span><br/>";
508
509 $zip = new ZipArchive();
510 $x = $zip->open($target);
511
512 if ($x === true && file_exists($target)) {
513 $zip->extractTo( get_tmpl_plugin_directory()); // change this to the correct site path
514 $zip->close();
515
516
517 unlink($target);
518 $message = "Your .zip file was uploaded and unpacked.<br/>";
519 }else{
520
521 }
522 }
523 if($add_msg == 1 && strstr($_SERVER['REQUEST_URI'],'themes.php')){
524 update_option('tev_on_go_re',1);
525
526 $plug_path2 = "Tevolution-Classifieds/classifieds.php"; // change this to the correct site path
527 $plug_path3 = "Tevolution-LocationManager/location-manager.php"; // change this to the correct site path
528 $plug_path1 = "Tevolution/templatic.php"; // change this to the correct site path
529
530 activate_plugin($plug_path1);
531 activate_plugin($plug_path2);
532 activate_plugin($plug_path3);
533
534 update_option('cls_easy_install_redirect_activation','Active');
535 $location_post_type[]='post,category,post_tag';
536 $location_post_type[]='classified,classifiedscategory,classifiedstags';
537 $post_types=update_option('location_post_type',$location_post_type);
538
539 }
540 }
541}
542/* code for easy install zip */
543add_action('admin_init', 'tmpl_cls_easy_install_plugin_redirect_templatic',20);
544function tmpl_cls_easy_install_plugin_redirect_templatic()
545{
546 if (get_option('cls_easy_install_redirect_activation') == 'Active' && is_plugin_active('Tevolution/templatic.php'))
547 {
548 update_option('cls_easy_install_redirect_activation', 'Deactive');
549 wp_redirect(site_url().'/wp-admin/admin.php?page=templatic_system_menu');
550 exit;
551 }
552}
553/*
554 Return the plug-in directory path
555*/
556if(!function_exists('get_tmpl_plugin_directory')){
557function get_tmpl_plugin_directory() {
558 return WP_CONTENT_DIR."/plugins/";
559}
560}
561/* code for easy install zip */
562if(is_admin() && is_writable(WP_CONTENT_DIR."/plugins") && is_readable(get_stylesheet_directory())){
563 $tev_zip = get_stylesheet_directory()."/Tevolution.zip";
564 $tev_zip_path = get_stylesheet_directory()."/Tevolution.zip";
565 $re_zip = get_stylesheet_directory()."/Tevolution-Classifieds.zip";
566 $re_zip_path = get_stylesheet_directory()."/Tevolution-Classifieds.zip";
567 $loc_zip = get_stylesheet_directory()."/Tevolution-LocationManager.zip";
568 $loc_zip_path = get_stylesheet_directory()."/Tevolution-LocationManager.zip";
569
570 $target_path1 = get_tmpl_plugin_directory()."Tevolution.zip"; // change this to the correct site path
571 $target_path2 = get_tmpl_plugin_directory()."Tevolution-Classifieds.zip"; // change this to the correct site path
572 $target_path3 = get_tmpl_plugin_directory()."Tevolution-LocationManager.zip"; // change this to the correct site path
573
574 $plug_path1 = "Tevolution/templatic.php"; // change this to the correct site path
575 $plug_path2 = "Tevolution-Classifieds/classifieds.php"; // change this to the correct site path
576 $plug_path3 = "Tevolution-LocationManager/location-manager.php"; // change this to the correct site path
577 global $pagenow;
578
579 if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php') {
580 if(file_exists($tev_zip_path))
581 tmpl_cls_zip_copy( $tev_zip, $target_path1, $plug_path1 );
582 if(file_exists($re_zip_path))
583 tmpl_cls_zip_copy( $re_zip, $target_path2, $plug_path2 );
584 if(file_exists($loc_zip_path))
585 tmpl_cls_zip_copy( $loc_zip, $target_path3, $plug_path3, $add_msg=1 );
586
587 }
588}
589
590/* add classifieds thumbnail size */
591add_filter('supreme_thumbnail_height','tmpl_classified_tevolution_thumbnail_width');
592add_filter('supreme_thumbnail_width','tmpl_classified_tevolution_thumbnail_height');
593
594add_filter('tevolution_thumbnail_width','tmpl_classified_tevolution_thumbnail_width');
595function tmpl_classified_tevolution_thumbnail_width(){
596 return '80';
597}
598
599add_filter('tevolution_thumbnail_height','tmpl_classified_tevolution_thumbnail_height');
600function tmpl_classified_tevolution_thumbnail_height(){
601 return '70';
602}
603/*change the itemwidth of detail page slider.*/
604add_filter('tmpl_detail_slider_options','tmpl_classified_detail_slider_options');
605function tmpl_classified_detail_slider_options()
606{
607 return array('animation'=>'slide','slideshow'=>'false','direction'=>'horizontal','slideshowSpeed'=>7000,'animationLoop'=>'true','startAt'=> 0,'smoothHeight'=> 'true','easing'=> "swing",'pauseOnHover'=> 'true','video'=> 'true','controlNav'=> 'true','directionNav'=> 'true','prevText'=> 'next','nextText'=> 'previous','animationLoop'=>'true','itemWidth'=>'90','itemMargin'=>'15');
608}
609add_action( 'init', 'classified_theme_register_image_sizes' );
610function classified_theme_register_image_sizes(){
611 /* add_image_size( 'clasified-thumb', 175, 125, true ); */
612 add_image_size('adv_detail-main-img',400,290,true);
613 /* listing page featured thumbnail */
614 add_image_size('adv_listings-thumb',250,165,true);
615 add_image_size('tevolution_thumbnail',90,65,true);
616
617 add_image_size( 'popular_post-thumbnail',90,65,true);
618 add_image_size( 'mobile-thumbnail',90,65,true);
619 add_image_size( 'slider-thumbnail',175,125,true);
620 /* add_image_size('classified_slider_img_thumb',175,125,true); */
621}
622/*set wordpress iamge*/
623add_action( 'init', 'classified_child_theme_register_image_sizes' );
624function classified_child_theme_register_image_sizes(){
625
626 add_image_size( 'thumbnail', 90, 65, true );
627 if(get_option('tmpl_added_default_image_sizes') != 1){
628 if(get_option('thumbnail_size_w')!=90)
629 update_option('thumbnail_size_w',90);
630 if(get_option('thumbnail_size_h')!=65)
631 update_option('thumbnail_size_h',65);
632
633 if(get_option('medium_size_w')!=0)
634 update_option('medium_size_w',0);
635 if(get_option('medium_size_h')!=0)
636 update_option('medium_size_h',0);
637
638 if(get_option('large_size_w')!=0)
639 update_option('large_size_w',0);
640 if(get_option('large_size_h')!=0)
641 update_option('large_size_h',0);
642
643 update_option('tmpl_added_default_image_sizes',1);
644 }
645
646}
647function templatic_classified_customizer_settings($wp_customize)
648{
649 $wp_customize->get_control('color_picker_color1')->label = __('Primary Color','templatic');
650 $wp_customize->get_control('color_picker_color2')->label = __('Secondary Color','templatic');
651 $wp_customize->get_control('color_picker_color3')->label = __('Content Color','templatic');
652 $wp_customize->get_control('color_picker_color4')->label = __('Body Background Color','templatic');
653 $wp_customize->remove_control('color_picker_color5');
654 $wp_customize->remove_control('color_picker_color6');
655}
656/* header hook to set the current city background colour and header image colour/image*/
657remove_action('before_desk_menu_primary','tmpl_locations_color_settings',100);
658add_action('before_desk_menu_primary','tmpl_classifieds_locations_color_settings',100);
659function tmpl_classifieds_locations_color_settings(){
660 global $current_cityinfo,$wpdb,$multicity_table;
661 /* Set city wise back ground colour or image */
662 if(($current_cityinfo['color'] && $current_cityinfo['color'] !='#') || $current_cityinfo['images'] || ($current_cityinfo['header_color'] && $current_cityinfo['header_color'] !='#') || $current_cityinfo['header_image']):?>
663 <style type="text/css">
664 html body{
665 <?php if($current_cityinfo['color']):?>
666 background-color:<?php echo $current_cityinfo['color'];?>!important;
667 <?php endif;?>
668 <?php if($current_cityinfo['images']):?>
669 background-image:url('<?php echo $current_cityinfo['images'];?>')!important;
670 <?php endif;?>
671 }
672 header.header_container,body div.header_container{
673 <?php if($current_cityinfo['header_color']):?>
674 background-color:<?php echo $current_cityinfo['header_color'];?>!important;
675 <?php endif;?>
676 <?php if($current_cityinfo['header_image']):?>
677 background-image:url('<?php echo $current_cityinfo['header_image'];?>')!important;
678 <?php endif;?>
679 }
680 </style>
681 <?php endif;
682}
683/*
684 * Child theme auto update.
685 */
686add_action('admin_menu','classified_templatic_menu',20);
687if(!function_exists('classified_templatic_menu'))
688{
689 function classified_templatic_menu()
690 {
691 if(is_plugin_active('Tevolution/templatic.php')){
692 add_submenu_page( 'templatic_system_menu', __('Child Theme Update','templatic'), __('Child Theme Update','templatic'), 'administrator', 'child_tmpl_theme_update', 'child_tmpl_theme_update',27 );
693 }else{
694 add_submenu_page( 'templatic_menu', __('Child Theme Update','templatic'), __('Child Theme Update','templatic'), 'administrator', 'child_tmpl_theme_update', 'child_tmpl_theme_update',27 );
695 }
696 }
697}
698if(!function_exists('child_tmpl_theme_update'))
699{
700 function child_tmpl_theme_update()
701 {
702 require_once(get_stylesheet_directory()."/templatic_login.php");
703 }
704}
705/* added filter for list filter for additional post type */
706add_filter('filter_post_type','templ_classified_filter_post_type');
707function templ_classified_filter_post_type()
708{
709 return 'classified';
710}
711
712/* added class for additional post type */
713add_filter('body_class', 'tpml_classified_classes');
714function tpml_classified_classes($classes){
715 global $wp_query, $post;
716 wp_reset_query();
717 if (is_single()) {
718 $post_type = get_post_type();
719 if ($post_type == '') {
720 $post_type = $post->post_type;
721 }
722
723 if(function_exists('tmpl_addon_name'))
724 $addons_posttype = tmpl_addon_name(); /* all tevolution addons' post type as key and folder name as a value */
725
726 if(!array_key_exists($post_type,$addons_posttype)) {
727 $classes[] = 'singular-classified';
728 }
729 }
730
731 return $classes;
732}
733
734/* Filter for mobile listing template */
735add_filter('tpml_theme_mobile_listing','tmpl_classifeids_mobile_texonomy_template');
736function tmpl_classifeids_mobile_texonomy_template($template)
737{
738 if(file_exists(WP_PLUGIN_DIR.'/Tevolution-Classifieds/templates/mobile-classified.php') && is_plugin_active('Tevolution-Classifieds/classifieds.php'))
739 {
740 $template=WP_PLUGIN_DIR.'/Tevolution-Classifieds/templates/mobile-classified.php';
741 }
742 return $template;
743}
744
745/* advertisement custom menu in wp-admin section*/
746
747add_action('admin_menu', 'awesome_page_create');
748
749function awesome_page_create() {
750 $page_title = 'Advertisement';
751 $menu_title = 'Advertisement';
752 $capability = 'administrator';
753 $menu_slug = 'advertisement-Admin-Page';
754 $function = 'my_awesome_page_display';
755 $icon_url = '';
756 //$position = 24;
757
758 add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url);
759}
760
761function my_awesome_page_display(){
762
763 echo "Advetising";
764}
765/* advertisement code completed*/
766
767/* My Leads custom menu in wp-admin section*/
768
769add_action('admin_menu', 'myleads_page_create');
770function myleads_page_create() {
771 $page_title = 'myleads';
772 $menu_title = 'My Leads';
773 $capability = 'administrator';
774 $menu_slug = 'myleads-Admin-Page';
775 $function = 'my_awesome_page_display_myleads';
776 $icon_url = '';
777 //$position = 24;
778
779 add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url);
780}
781
782function my_awesome_page_display_myleads(){
783 echo "My Leads";
784}
785/*my leads code completed*/
786
787/* paid packages custom menu in wp-admin section*/
788add_action('admin_menu', 'Paid_packages_page_create');
789function Paid_packages_page_create() {
790 $page_title = 'paid_packages';
791 $menu_title = 'Paid Packages';
792 $capability = 'administrator';
793 $menu_slug = 'paid-packages-Admin-Page';
794 $function = 'my_awesome_page_display_paid_packages';
795 $icon_url = '';
796 //$position = 24;
797
798 add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url);
799}
800
801function my_awesome_page_display_paid_packages(){
802 echo "paid Packages";
803}
804/* paid packages code completed*/
805
806/* buy requirement custom menu in wp-admin section*/
807add_action('admin_menu', 'buy_requirement_page_create');
808function buy_requirement_page_create() {
809 $page_title = 'buy_requirement';
810 $menu_title = 'Buy Requirement';
811 $capability = 'administrator';
812 $menu_slug = 'buy-requirement-Admin-Page';
813 $function = 'my_awesome_page_display_buy_requirement';
814 $icon_url = '';
815 //$position = 24;
816
817 add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url);
818}
819
820function my_awesome_page_display_buy_requirement()
821{
822 //echo "my_awesome_page_display_buy_requirement";
823 $servername = "localhost";
824 $username = "aasaantrade_com";
825 $password = "SdwTaRlu7Y4OAef";
826 $dbname = "aasaantrade_com";
827
828 // Create connection
829 $conn = mysqli_connect($servername, $username, $password, $dbname);
830 // Check connection
831 if (!$conn)
832 {
833 die("Connection failed: " . mysqli_connect_error());
834 }
835
836 $sql = "SELECT * FROM `wp_buy_requirement`";
837 $result = mysqli_query($conn, $sql);?>
838 <html>
839 <head>
840 <meta name="viewport" content="width=device-width, initial-scale=1">
841 <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
842 <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
843 <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
844 <style>
845 th
846 {
847 border-bottom: 1px solid;
848 }
849 tr:nth-child(even)
850 {
851 background:#e9e9e9;
852 }
853 </style>
854 </head>
855 <body>
856 <div data-role="page" id="pageone">
857 <div data-role="header">
858 <h1>All Buy Requirements</h1>
859 </div>
860 <div data-role="main" class="ui-content">
861 <form>
862 <input id="filterTable-input" data-type="search" placeholder="Search For Customers...">
863 </form>
864
865 <table data-role="table" data-mode="columntoggle" class="ui-responsive ui-shadow" id="myTable" data-filter="true" data-input="#filterTable-input">
866 <thead><?php
867 if (mysqli_num_rows($result) > 0)
868 { ?><tr><th data-priority="5">ID</th>
869 <th data-priority="6">Description</th>
870 <th data-priority="1">Quantity</th>
871 <th data-priority="2">Phone_Number</th>
872 <th data-priority="3">User_ID</th>
873 <th data-priority="4">Cat_ID</th></tr>
874 <tr></thead><tbody><tr><?php
875 // output data of each row
876 while($row = mysqli_fetch_assoc($result))
877 {
878 //echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
879 ?><td class="id"><?php echo $row["id"]; ?></td>
880 <td class="description"><?php echo $row["description"]; ?></td>
881 <td class="quantity"><?php echo $row["quantity"]; ?></td>
882 <td class="phone_number"><?php echo $row["phone_number"]; ?></td>
883 <td class="user_id"><?php echo $row["user_id"]; ?></td>
884 <td class="cat_id"><?php
885 $x= get_term($row["cat_id"],classifiedscategory);
886 $y= $x->name;
887 echo $y."<br>"; ?></td></tr><?php
888 }
889 }?></tbody></table>
890 </div></body></html><?php
891
892}
893/* buy requirement code completed*/
894
895
896
897?>