Plugin Directory

Changeset 1408030


Ignore:
Timestamp:
04/30/2016 11:15:48 AM (10 years ago)
Author:
Pigrecolab
Message:

Added featured vehicle in column
added new shortcode [cde_featured_vehicles]

Location:
pl-car-dealer/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pl-car-dealer/trunk/PL-car-dealer.php

    r1404810 r1408030  
    44Plugin URI: https://wordpress.org/plugins/pl-car-dealer/
    55Description: Car dealer custom plugin
    6 Version: 1.2
     6Version: 1.3
    77Author: Roberto Bruno
    88Author URI: http://www.pigrecolab.com
     
    203203        'price' => __( 'Price', 'cde_pgl'  ),
    204204        'year' => __( 'Year', 'cde_pgl'  ),
    205         'mileage' => __( 'Mileage', 'cde_pgl'  )
     205        'mileage' => __( 'Mileage', 'cde_pgl'  ),
     206        'featured' => __( 'Featured', 'cde_pgl'  )
     207
    206208
    207209        );
     
    274276        echo the_post_thumbnail( array(80,80) );
    275277
     278        break;
     279
     280        case 'featured' :
     281            $feat= get_post_meta( $post_id, $prefix.'featured', true );
     282            //echo var_dump($feat);
     283            echo ($feat==0) ? '<span class="dashicons dashicons-star-empty pb" pid="'.$post_id.'"></span>' : '<span class="dashicons dashicons-star-filled pb" pid="'.$post_id.'"></span>';
    276284        break;
    277285       
     
    284292}
    285293
     294/****** VEHICLE FEATURED CHANGE STATUS ****/
     295
     296global $pagenow,$typenow; //&& $typenow =='page'
     297
     298 if (is_admin()   && $typenow='vehicle'){
     299               // add_filter('admin_footer','insert_ajax_status_script');
     300                add_action( 'admin_footer', 'changefeat_javascript' ); // Write our JS below here
     301                add_action( 'wp_ajax_changefeat', 'changefeat_callback' );
     302            }
     303
     304
     305function changefeat_javascript() { ?>
     306          <div id="status_update_working" style="background-color: green; color: #fff; font-wieght: bolder;   font-size: 22px;   height: 33px;   left: 40%;   padding: 35px;   position: fixed;   top: 100px;   width: 350px; display:none !important; ">Changing status...</div>
     307
     308           
     309    <script type="text/javascript">
     310    function chf(p){
     311                jQuery("#status_update_working").show('fast');
     312                       
     313                        params={};
     314                        params.post_id=p.attr("pid");
     315                        params.action="changefeat";//IMPORTANT: THE VALUE ACTION SHOULD BE THE SAME IN 'WP_AJAX_...'
     316                        jQuery.post(ajaxurl,params,
     317                    function(response) {
     318                        if (response.error){
     319                            alert(response.error);                     
     320                        }else{
     321                            console.log(response)
     322                            p.toggleClass("dashicons dashicons-star-empty dashicons dashicons-star-filled");;
     323                        }
     324                    }
     325                );
     326                jQuery("#status_update_working").hide('9500');
     327            }
     328
     329    jQuery(document).ready(function($) {
     330
     331
     332          jQuery(".pb").click(function(){
     333                    chf(jQuery(this));
     334                });
     335
     336    });
     337    </script> <?php
     338}
     339
     340//js/jquery code to call ajax
     341        function insert_ajax_status_script(){
     342            ?>
     343            <div id="status_update_working" style="background-color: green; color: #fff; font-size: 22px;   height: 33px;   left: 40%;   padding: 35px;   position: fixed;   top: 100px;   width: 350px; display:none !important; ">Changing status...</div>
     344            <script type="text/javascript">
     345
     346            function changefeat(p){
     347                jQuery("#status_update_working").show();
     348                jQuery.getJSON(ajaxurl,
     349                    {   post_id: p.attr("pid"),
     350                        action: "change_status",
     351                    },
     352                    function(data) {
     353                        if (data.error){
     354                            alert(data.error);                     
     355                        }else{
     356                            p.toggleClass("dashicons dashicons-star-empty dashicons dashicons-star-filled");;
     357                        }
     358                    }
     359                );
     360                jQuery("#status_update_working").hide();
     361            }
     362            jQuery(document).ready(function(){
     363                jQuery(".pb").click(function(){
     364                    ajax_change_status(jQuery(this));
     365                });
     366            });
     367            </script>
     368            <?php
     369        }
     370
     371        //ajax callback function
     372        function changefeat_callback() {
     373     
     374            if (!isset($_POST['post_id'])){
     375                $re = 'something went wrong ...';
     376                echo json_encode($re);
     377                die();
     378            }
     379            if (isset($_POST['action'])){
     380
     381                change_feat_db($_POST['post_id']);
     382
     383            }else{
     384                $re = 'something went wrong ...';
     385            }
     386            echo "ok";
     387              wp_die(); // this is required to terminate immediately and return a proper response
     388        }
     389
     390
     391        function change_feat_db($psid){
     392            $prefix="_cde_";
     393            $current_meta = get_post_meta( $psid);
     394           $newval =  1-intval($current_meta[$prefix.'featured'][0]);
     395           echo var_dump($current_meta);
     396            update_post_meta($psid, $prefix.'featured',$newval  );
     397        }
     398
     399
     400 
    286401/****** VEHICLE CUSTOM TEMPLATE ****/
    287402
     
    714829
    715830/*-----------------------------------------------------------------------------------*/
    716 /* LAST VEHICLES SHORTCODE - MAINTAINED FOR COMPATIBILITY*/
     831/* LATEST VEHICLES SHORTCODE
    717832/*-----------------------------------------------------------------------------------*/
    718833
     
    786901}
    787902
     903
     904/*-----------------------------------------------------------------------------------*/
     905/* FEATURED VEHICLES SHORTCODE
     906/*-----------------------------------------------------------------------------------*/
     907
     908add_shortcode( 'cde_featured_vehicles', 'cde_feat_vehicles' );
     909
     910function cde_feat_vehicles( $atts ) {
     911
     912cde_scripts_styles();
     913
     914$r = new WP_Query( array(
     915   'no_found_rows' => true, /*suppress found row count*/
     916   'post_status' => 'publish',
     917   'post_type' => 'vehicle',
     918   'ignore_sticky_posts' => true,
     919   'meta_query'    =>  array(
     920                                array(
     921                                    'key'     => '_cde_featured',
     922                                    'value'   => 1,
     923                                    'compare' => '='
     924                                )
     925                         )
     926           )
     927);
     928
     929
     930global $cde_mil_abb;
     931global $cde_mon_sym;
     932
     933    $cnt=0;
     934    $shrt="";
     935    if ($r->have_posts()){
     936     while ($r->have_posts()) : $r->the_post();
     937         $shrt.=" <div class=\"cde_col-sm-4 cde_col-md-4 \">";
     938           $shrt.="<div class=\"cde_thumbnail cde_grid\">";
     939              if ( has_post_thumbnail()) {
     940//Get the Thumbnail URL
     941                $src_orig = wp_get_attachment_image_src( get_post_thumbnail_id($r->post->ID), 'full', false, '' );
     942                $src_thumb = wp_get_attachment_image_src( get_post_thumbnail_id($r->post->ID), 'cde_size', false, '' );
     943
     944               
     945                $shrt.="<figure><a href=\"".$src_orig[0]."\" rel=\"gallery\" class=\"thumb\"><img src=\"".$src_thumb[0]."\" /></a>";
     946                   } else {
     947                  $shrt.="<div style=\"background:url(".plugins_url( '/car-dealer/images/pattern-1.png' ) .");width:".get_option('cde_thumb_size_w', '303')."px;height:". get_option('cde_thumb_size_h', '210')."px\" title=\"". __( 'No Image', 'cde_pgl' )."\"></div>";
     948                 }
     949                  $shrt.="<figcaption>
     950                    <h4>";
     951                $prefix = '_cde_';
     952                     $mileage = get_post_meta( get_the_ID(), $prefix.'mileage', true );
     953                     $year = get_post_meta( get_the_ID(), $prefix.'year', true );
     954                     $price = get_post_meta( get_the_ID(), $prefix.'price', true );
     955                     if ($price!='0,00') $shrt.= $cde_mon_sym." ".$price;
     956                   $shrt.="</h4><br /><span>".sprintf( __( '<strong>Year: </strong> %s', "cde_pgl" ), $year );
     957                    $shrt.="<br>";
     958                      $shrt.=sprintf( __( '<strong>'.$cde_mil_abb.' : </strong> %s', "cde_pgl" ), $mileage )."</span><br>
     959                    <a href=\"".get_the_permalink()."\">".__("Take a look", "cde_pgl")."</a>";
     960                 $shrt.=" </figcaption>";
     961                $shrt.="</figure>";
     962                $shrt.="<div class=\"caption\">
     963                  <h3>        <a href=\"".get_the_permalink()."\" title=\"". get_the_title()."\">". get_the_title()."</a></h3>";
     964                  $shrt.="<p>".get_the_excerpt()."</p>";
     965                $shrt.="</div>";
     966             $shrt.=" </div>";
     967           $shrt.=" </div>";
     968
     969            $cnt+=1;
     970            if ($cnt==3) {
     971                         $shrt.="<div class=\"cde_clearfix\"></div>";
     972                        $cnt=0;
     973            }
     974           
     975          endwhile;
     976
     977          $shrt.="<div class=\"cde_clearfix\"></div>";
     978}
     979return $shrt;
     980}
  • pl-car-dealer/trunk/README.txt

    r1404810 r1408030  
    55Tags: car dealer, car seller, cars, autostock, selling cars
    66Requires at least: 3.0.1
    7 Tested up to: 4.4.2
    8 Stable tag: 1.2.1
     7Tested up to: 4.5.2
     8Stable tag: 1.3
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    28285. A shortcode for latest vehicles [cde_latest_vehicles]
    2929
    30 6. Three templates for archive vehicle, advanced vehicle result and a single vehicle
     306. A shortcode for featured vehicles [cde_featured_vehicles]
    3131
    32 7. Translation ready (Italian language included)
     327. Three templates for archive vehicle, advanced search vehicle result and a single vehicle
    3333
    34 8. Mileage abbreviation and money symbol setting
     348. Translation ready (Italian language included)
     35
     369. Mileage abbreviation and money symbol setting
    3537
    3638A demo is available at http://www.autobarbara.it/
  • pl-car-dealer/trunk/languages/cde_pgl-it_IT.po

    r1344095 r1408030  
    22msgstr ""
    33"Project-Id-Version: Car dealer\n"
    4 "POT-Creation-Date: 2016-02-05 16:15+0100\n"
    5 "PO-Revision-Date: 2016-02-05 16:15+0100\n"
     4"POT-Creation-Date: 2016-04-30 13:14+0100\n"
     5"PO-Revision-Date: 2016-04-30 13:14+0100\n"
    66"Last-Translator: \n"
    77"Language-Team: \n"
     
    314314
    315315#: PL-car-dealer.php:167 PL-car-dealer.php:203
    316 #: templates/single-vehicle.php:40
     316#: templates/single-vehicle.php:41
    317317msgid "Price"
    318318msgstr "Prezzo"
     
    322322msgstr "Prezzo del veicolo"
    323323
    324 #: PL-car-dealer.php:176 templates/single-vehicle.php:55
     324#: PL-car-dealer.php:176 templates/single-vehicle.php:58
    325325msgid "Photos"
    326326msgstr "Foto"
     
    330330msgstr ""
    331331
    332 #: PL-car-dealer.php:230 PL-car-dealer.php:246 PL-car-dealer.php:262
     332#: PL-car-dealer.php:206
     333msgid "Featured"
     334msgstr "In evidenza"
     335
     336#: PL-car-dealer.php:232 PL-car-dealer.php:248 PL-car-dealer.php:264
    333337msgid "Unknown"
    334338msgstr "Sconosciuto"
    335339
    336 #: PL-car-dealer.php:234 PL-car-dealer.php:266
     340#: PL-car-dealer.php:236 PL-car-dealer.php:268
    337341#, php-format
    338342msgid " %s"
    339343msgstr ""
    340344
    341 #: PL-car-dealer.php:250
     345#: PL-car-dealer.php:252
    342346#, php-format
    343347msgid "%s"
    344348msgstr ""
    345349
    346 #: PL-car-dealer.php:398
     350#: PL-car-dealer.php:513
    347351msgid "Vehicle Search Widget"
    348352msgstr "Widget Ricerca Veicoli"
    349353
    350 #: PL-car-dealer.php:401
     354#: PL-car-dealer.php:516
    351355msgid "widget for searching a vehicle"
    352356msgstr "Widget Ricerca Veicoli"
    353357
    354 #: PL-car-dealer.php:421 PL-car-dealer.php:681
     358#: PL-car-dealer.php:536 PL-car-dealer.php:796
    355359msgid "Name: "
    356360msgstr "Nome:"
    357361
    358 #: PL-car-dealer.php:422 PL-car-dealer.php:682
     362#: PL-car-dealer.php:537 PL-car-dealer.php:797
    359363msgid "Type the Car Name"
    360364msgstr "Digitare il nome della vettura"
    361365
    362 #: PL-car-dealer.php:424 PL-car-dealer.php:684
     366#: PL-car-dealer.php:539 PL-car-dealer.php:799
    363367msgid "Make: "
    364368msgstr "Marche:"
    365369
    366 #: PL-car-dealer.php:430 PL-car-dealer.php:690
     370#: PL-car-dealer.php:545 PL-car-dealer.php:805
    367371msgid "All the makes"
    368372msgstr "Tutte le marche"
    369373
    370 #: PL-car-dealer.php:437 PL-car-dealer.php:697
     374#: PL-car-dealer.php:552 PL-car-dealer.php:812
    371375msgid "Max Mileage: "
    372376msgstr "Max Chilometraggio:"
    373377
    374 #: PL-car-dealer.php:438 PL-car-dealer.php:698
     378#: PL-car-dealer.php:553 PL-car-dealer.php:813
    375379msgid "Maximum mileage"
    376380msgstr "Chilometraggio massimo"
    377381
    378 #: PL-car-dealer.php:440 PL-car-dealer.php:700
     382#: PL-car-dealer.php:555 PL-car-dealer.php:815
    379383msgid "Max price: "
    380384msgstr "Prezzo max:"
    381385
    382 #: PL-car-dealer.php:441 PL-car-dealer.php:701
     386#: PL-car-dealer.php:556 PL-car-dealer.php:816
    383387msgid "Maximum Price"
    384388msgstr "Prezzo massimo"
    385389
    386 #: PL-car-dealer.php:443 PL-car-dealer.php:703
     390#: PL-car-dealer.php:558 PL-car-dealer.php:818
    387391msgid "Min Year: "
    388392msgstr "Min Anno:"
    389393
    390 #: PL-car-dealer.php:444 PL-car-dealer.php:704
     394#: PL-car-dealer.php:559 PL-car-dealer.php:819
    391395msgid "Minimum Year of Constr."
    392396msgstr "Minimo Anno di costr."
    393397
    394 #: PL-car-dealer.php:462
     398#: PL-car-dealer.php:577
    395399msgid "New title"
    396400msgstr "Nuovo titolo"
    397401
    398 #: PL-car-dealer.php:467 PL-car-dealer.php:574
     402#: PL-car-dealer.php:582 PL-car-dealer.php:689
    399403msgid "Title:"
    400404msgstr "Titolo:"
    401405
    402 #: PL-car-dealer.php:497
     406#: PL-car-dealer.php:612
    403407msgid "Allows you to create a new Sidebar widget to display makes!"
    404408msgstr "Consente di creare un nuovo widget per visualizzare le marche!"
    405409
    406 #: PL-car-dealer.php:538
     410#: PL-car-dealer.php:653
    407411msgid "New Title"
    408412msgstr "Nuovo titolo"
    409413
    410 #: PL-car-dealer.php:579
     414#: PL-car-dealer.php:694
    411415msgid "Options:"
    412416msgstr "Opzioni:"
    413417
    414 #: PL-car-dealer.php:583
     418#: PL-car-dealer.php:698
    415419msgid "Hide Widget If There Are No Makes To Be Displayed?"
    416420msgstr "Nascondi il widget se non vi sono marche da mostrare ?"
    417421
    418 #: PL-car-dealer.php:588
     422#: PL-car-dealer.php:703
    419423msgid "Hide Makes That Have No Related Vehicles?"
    420424msgstr "Nascondi marche che non hanno veicoli ?"
    421425
    422 #: PL-car-dealer.php:592
     426#: PL-car-dealer.php:707
    423427msgid "Order Makes By:"
    424428msgstr "Ordina marche per:"
    425429
    426 #: PL-car-dealer.php:594
     430#: PL-car-dealer.php:709
    427431msgid "ID Ascending"
    428432msgstr "ID Crescente"
    429433
    430 #: PL-car-dealer.php:595
     434#: PL-car-dealer.php:710
    431435msgid "ID Descending"
    432436msgstr "ID decrescente"
    433437
    434 #: PL-car-dealer.php:596
     438#: PL-car-dealer.php:711
    435439msgid "Count Ascending"
    436440msgstr "Numero Crescente"
    437441
    438 #: PL-car-dealer.php:597
     442#: PL-car-dealer.php:712
    439443msgid "Count Descending"
    440444msgstr "Numero decrescente"
    441445
    442 #: PL-car-dealer.php:598
     446#: PL-car-dealer.php:713
    443447msgid "Name Ascending"
    444448msgstr "Nome Crescente"
    445449
    446 #: PL-car-dealer.php:599
     450#: PL-car-dealer.php:714
    447451msgid "Name Descending"
    448452msgstr "Nome Decrescente"
    449453
    450 #: PL-car-dealer.php:600
     454#: PL-car-dealer.php:715
    451455msgid "Slug Ascending"
    452456msgstr "Slug Crescente"
    453457
    454 #: PL-car-dealer.php:601
     458#: PL-car-dealer.php:716
    455459msgid "Slug Descending"
    456460msgstr "Slug decrescente"
    457461
    458 #: PL-car-dealer.php:606
     462#: PL-car-dealer.php:721
    459463msgid "Maximum Number Of Makes To Return:"
    460464msgstr "Numero massimo di marche da mostrare:"
    461465
    462 #: PL-car-dealer.php:607
     466#: PL-car-dealer.php:722
    463467msgid "Keep Empty To Display All"
    464468msgstr "Lasciare Vuoto Per visualizzare tutti"
    465469
    466 #: PL-car-dealer.php:611
     470#: PL-car-dealer.php:726
    467471msgid "Ids To Exclude From Being Displayed:"
    468472msgstr "ID da escludere dalla visualizzazione:"
    469473
    470 #: PL-car-dealer.php:612 PL-car-dealer.php:617
     474#: PL-car-dealer.php:727 PL-car-dealer.php:732
    471475msgid "Separate ids with a comma ,"
    472476msgstr "Separa gli ID con una virgola,"
    473477
    474 #: PL-car-dealer.php:616
     478#: PL-car-dealer.php:731
    475479msgid "Only Display Makes With The Following Ids:"
    476480msgstr "Mostra marche con i seguenti ID:"
    477481
    478 #: PL-car-dealer.php:751 templates/advanced-vehicle-results.php:78
     482#: PL-car-dealer.php:868 PL-car-dealer.php:947
     483#: templates/advanced-vehicle-results.php:108
    479484#: templates/archive-vehicle.php:72
    480485msgid "No Image"
    481486msgstr "Nessuna immagine"
    482487
    483 #: PL-car-dealer.php:760 templates/advanced-vehicle-results.php:88
     488#: PL-car-dealer.php:877 PL-car-dealer.php:956
     489#: templates/advanced-vehicle-results.php:118
    484490#: templates/archive-vehicle.php:82
    485491#, php-format
     
    487493msgstr "<strong>Anno: </strong> %s"
    488494
    489 #: PL-car-dealer.php:762 templates/advanced-vehicle-results.php:90
     495#: PL-car-dealer.php:879 PL-car-dealer.php:958
     496#: templates/advanced-vehicle-results.php:120
    490497#: templates/archive-vehicle.php:84
    491498msgid "<strong>"
    492499msgstr ""
    493500
    494 #: PL-car-dealer.php:763 templates/advanced-vehicle-results.php:91
     501#: PL-car-dealer.php:880 PL-car-dealer.php:959
     502#: templates/advanced-vehicle-results.php:121
    495503#: templates/archive-vehicle.php:85
    496504msgid "Take a look"
     
    521529msgstr ""
    522530
    523 #: templates/advanced-vehicle-results.php:59
     531#: templates/advanced-vehicle-results.php:89
    524532msgid "Advanced results"
    525533msgstr "Risultati ricerca avanzata"
    526534
    527 #: templates/advanced-vehicle-results.php:111
     535#: templates/advanced-vehicle-results.php:141
    528536#: templates/archive-vehicle.php:105
    529537msgid "Nothing Found"
    530538msgstr "Non è stato trovato nulla"
    531539
    532 #: templates/advanced-vehicle-results.php:115
     540#: templates/advanced-vehicle-results.php:145
    533541msgid "Apologies, but no results were found."
    534542msgstr "Siamo spiacenti, ma non è stato trovato alcun risultato."
Note: See TracChangeset for help on using the changeset viewer.