Plugin Directory

Changeset 1233870


Ignore:
Timestamp:
08/29/2015 09:02:40 PM (11 years ago)
Author:
oriolo
Message:

version 0.10.0 sorting products

Location:
goods-catalog
Files:
45 added
8 edited

Legend:

Unmodified
Added
Removed
  • goods-catalog/trunk/goods-cat.php

    r1171371 r1233870  
    55  Plugin URI: http://oriolo.wordpress.com/2014/03/25/goods-catalog-wordpress-plugin-that-creates-catalog-of-products/
    66  Description: Plugin that creates simple catalog of goods.
    7   Version: 0.9.4
     7  Version: 0.10.0
    88  Author: Irina Sokolovskaya
    99  Author URI: http://oriolo.ru/
  • goods-catalog/trunk/inc/class.settings-page.php

    r1171371 r1233870  
    183183
    184184        add_settings_field(
     185                'goods_orderby', // ID
     186                __('Goods order by', 'gcat'), // Title
     187                array($this, 'goods_orderby_callback'), // Callback
     188                'goods-setting-admin', // Page
     189                'product_section_id' // Section           
     190        );
     191
     192        add_settings_field(
     193                'goods_order', // ID
     194                __('Goods order', 'gcat'), // Title
     195                array($this, 'goods_order_callback'), // Callback
     196                'goods-setting-admin', // Page
     197                'product_section_id' // Section           
     198        );
     199
     200        add_settings_field(
    185201                'show_product_descr', // ID
    186202                __("Show product's short description", 'gcat'), // Title
     
    264280        if (isset($input['items_per_page']))
    265281            $new_input['items_per_page'] = absint($input['items_per_page']);
     282
     283        if (isset($input['goods_orderby']))
     284            $new_input['goods_orderby'] = sanitize_text_field($input['goods_orderby']);
     285
     286        if (isset($input['goods_order']))
     287            $new_input['goods_order'] = sanitize_text_field($input['goods_order']);
    266288
    267289        if (isset($input['container_width']))
     
    392414                '<input type="number" step="1" id="items_per_page" class="small-text" name="goods_option_name[items_per_page]" value="%s" />', isset($this->options['items_per_page']) ? esc_attr($this->options['items_per_page']) : '12'
    393415        );
     416    }
     417
     418    public function goods_orderby_callback() {
     419        $orderby_options = array(
     420            'none' => __('none', 'gcat'),
     421            'ID' => __('ID', 'gcat'),
     422            'author' => __('author', 'gcat'),
     423            'title' => __('title', 'gcat'),
     424            'name' => __('slug', 'gcat'),
     425            'date' => __('date', 'gcat'),
     426            'modified' => __('last modified', 'gcat'),
     427            'rand' => __('random', 'gcat'),
     428            'comment_count' => __('number of comments', 'gcat'),
     429            'menu_order' => __('menu order', 'gcat'),
     430            'meta_value_num' => __('price', 'gcat')
     431        );
     432       
     433        echo '<select id="goods_orderby" name="goods_option_name[goods_orderby]" class="small-text">';
     434        foreach ($orderby_options as $key => $value) {
     435            echo '<option value="' . $key . '"' . selected( $this->options['goods_orderby'], $key ) . '>' . $value . '</option>';
     436        }
     437        echo '</select>';       
     438    }
     439
     440    public function goods_order_callback() {
     441        echo '<p>
     442        <input type="radio" id="goods_order_asc" name="goods_option_name[goods_order]" value="ASC" checked ' . checked ( $this->options['goods_order'], 'ASC', false) . '/>' . __('ASC', 'gcat') . '
     443        </p>
     444        <p>
     445        <input type="radio" id="goods_order_decs" name="goods_option_name[goods_order]" value="DESC" ' . checked ( $this->options['goods_order'], 'DESC', false) . '/>' . __('DESC', 'gcat') .
     446        '</p>';
    394447    }
    395448
  • goods-catalog/trunk/inc/functions.php

    r1157780 r1233870  
    3131
    3232/**
    33  * Set items per page
    34  *
    35  * @param $query
    36  */
    37 
    38 function goods_pagesize($query) {
     33 * Goods query settings
     34 *
     35 * @link https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
     36 * @param $query array
     37 */
     38
     39function goods_query($query) {
    3940    if (is_admin() || !$query->is_main_query())
    4041        return;
    4142
    42     if (is_tax('goods_category') || is_tax('goods_tag')) { // display number of posts
     43    if (is_tax('goods_category') || is_tax('goods_tag')) {
     44
    4345        global $catalog_option;
    44         $query->set('posts_per_page', $catalog_option['items_per_page']);
     46        $query->set('posts_per_page', $catalog_option['items_per_page']); // items per page
     47        $query->set('orderby', $catalog_option['goods_orderby']); // ID, date, title...
     48        if ($catalog_option['goods_orderby'] == 'meta_value_num') {
     49            $query->set('meta_key', 'gc_price'); //add meta key if sorting by meta value
     50        }
     51        $query->set('order', $catalog_option['goods_order']);// ASC, DESC
    4552        return;
    4653    }
    4754}
    4855
    49 add_action('pre_get_posts', 'goods_pagesize', 1); // Set items per page
     56add_action('pre_get_posts', 'goods_query', 1); // Set items per page
    5057
    5158/**
  • goods-catalog/trunk/languages/gcat-ru_RU.po

    r1171371 r1233870  
    33"Project-Id-Version: Goods Catalog\n"
    44"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/goods-catalog\n"
    5 "POT-Creation-Date: 2015-05-31 18:15+0300\n"
    6 "PO-Revision-Date: 2015-05-31 18:20+0300\n"
     5"POT-Creation-Date: 2015-08-29 23:48+0300\n"
     6"PO-Revision-Date: 2015-08-29 23:50+0300\n"
    77"Last-Translator: Irina Sokolovskaja <sokolovskaja.irina@gmail.com>\n"
    88"Language-Team: \n"
     
    8282
    8383#: ../inc/class.settings-page.php:186
     84msgid "Goods order by"
     85msgstr "Сортировка продуктов"
     86
     87#: ../inc/class.settings-page.php:194
     88msgid "Goods order"
     89msgstr "Порядок продуктов"
     90
     91#: ../inc/class.settings-page.php:202
    8492msgid "Show product's short description"
    8593msgstr "Показывать короткое описание продукта"
    8694
    87 #: ../inc/class.settings-page.php:194
     95#: ../inc/class.settings-page.php:210
    8896msgid "Show product's SKU"
    8997msgstr "Показывать артикул товара"
    9098
    91 #: ../inc/class.settings-page.php:201
     99#: ../inc/class.settings-page.php:217
    92100msgid "Product Price Prefix"
    93101msgstr "Префикс цены"
    94102
    95 #: ../inc/class.settings-page.php:208
     103#: ../inc/class.settings-page.php:224
    96104msgid "Product Price Postfix"
    97105msgstr "Постфикс цены"
    98106
    99 #: ../inc/class.settings-page.php:216
     107#: ../inc/class.settings-page.php:232
    100108msgid "Info Container Width on Product Page"
    101109msgstr "Ширина контейнера с информацией о продукте на странице продукта"
    102110
    103 #: ../inc/class.settings-page.php:225
     111#: ../inc/class.settings-page.php:241
    104112msgid "Sidebar Settings"
    105113msgstr "Настройки сайдбара"
    106114
    107 #: ../inc/class.settings-page.php:233
     115#: ../inc/class.settings-page.php:249
    108116msgid "Use special sidebar"
    109117msgstr "Использовать специальный сайдбар"
    110118
    111 #: ../inc/class.settings-page.php:240
     119#: ../inc/class.settings-page.php:256
    112120msgid "Sidebar Width"
    113121msgstr "Ширина сайдбара"
    114122
    115 #: ../inc/class.settings-page.php:322
     123#: ../inc/class.settings-page.php:344
    116124msgid "You can see the catalog on your site at:"
    117125msgstr "Каталог товаров на Вашем сайте расположен по адресу:"
    118126
    119 #: ../inc/class.settings-page.php:324
     127#: ../inc/class.settings-page.php:346
    120128msgid ""
    121129"Don't know how to set up the catalog? The instructions are available here: "
     
    129137"ru/dev/goods-catalog/quick-start'>по-русски</a>"
    130138
    131 #: ../inc/class.settings-page.php:327
     139#: ../inc/class.settings-page.php:349
    132140msgid ""
    133141"Any problems or questions? Visit the plugin's <a href='http://wordpress.org/"
     
    138146"WordPress.org"
    139147
    140 #: ../inc/class.settings-page.php:332
     148#: ../inc/class.settings-page.php:354
    141149#, php-format
    142150msgid ""
     
    149157"\">Постоянные сслыки</a>\", и, возможно, обновить соответствующие пункты меню"
    150158
    151 #: ../inc/class.settings-page.php:336
     159#: ../inc/class.settings-page.php:358
    152160msgid "The following settings will be applied to all catalog pages"
    153161msgstr "Настройки ниже будут применены ко всему каталогу"
    154162
    155 #: ../inc/class.settings-page.php:340
     163#: ../inc/class.settings-page.php:362
    156164msgid "Set up the goods categories here"
    157165msgstr "Настройте рубрики каталога"
    158166
    159 #: ../inc/class.settings-page.php:344
     167#: ../inc/class.settings-page.php:366
    160168msgid "Set up the products here"
    161169msgstr "Настройте продукты каталога"
    162170
    163 #: ../inc/class.settings-page.php:348
     171#: ../inc/class.settings-page.php:370
    164172msgid ""
    165173"You can use special sidebar only in catalog pages. Please remember that "
     
    170178"поддерживается, и на страницах каталога выведен не будет."
    171179
    172 #: ../inc/class.settings-page.php:358
     180#: ../inc/class.settings-page.php:380
    173181msgid " by default: catalog"
    174182msgstr "по-умолчанию: catalog"
    175183
    176 #: ../inc/class.settings-page.php:361
     184#: ../inc/class.settings-page.php:383
    177185msgid "Enter the slug of catalog home page"
    178186msgstr "Введите префикс для главной страницы каталога"
    179187
    180 #: ../inc/class.settings-page.php:370
     188#: ../inc/class.settings-page.php:392
    181189msgid " by default: goods_caregory"
    182190msgstr "по-умолчанию: goods_category"
    183191
    184 #: ../inc/class.settings-page.php:382
     192#: ../inc/class.settings-page.php:404
    185193msgid " by default: goods_tag"
    186194msgstr "по-умолчанию: goods_tag"
    187195
    188 #: ../inc/class.settings-page.php:400
     196#: ../inc/class.settings-page.php:420
     197msgid "none"
     198msgstr "нет"
     199
     200#: ../inc/class.settings-page.php:421
     201msgid "ID"
     202msgstr "ID"
     203
     204#: ../inc/class.settings-page.php:422
     205msgid "author"
     206msgstr "автор"
     207
     208#: ../inc/class.settings-page.php:423
     209msgid "title"
     210msgstr "название"
     211
     212#: ../inc/class.settings-page.php:424
     213msgid "slug"
     214msgstr "постоянная сслыка"
     215
     216#: ../inc/class.settings-page.php:425
     217msgid "date"
     218msgstr "дата"
     219
     220#: ../inc/class.settings-page.php:426
     221msgid "last modified"
     222msgstr "последнее изменение"
     223
     224#: ../inc/class.settings-page.php:427
     225msgid "random"
     226msgstr "случайно"
     227
     228#: ../inc/class.settings-page.php:428
     229msgid "number of comments"
     230msgstr "количество комментариев"
     231
     232#: ../inc/class.settings-page.php:429
     233msgid "menu order"
     234msgstr "порядок меню"
     235
     236#: ../inc/class.settings-page.php:430
     237msgid "price"
     238msgstr "цена"
     239
     240#: ../inc/class.settings-page.php:442
     241msgid "ASC"
     242msgstr "А-Я"
     243
     244#: ../inc/class.settings-page.php:445
     245msgid "DESC"
     246msgstr "Я-А"
     247
     248#: ../inc/class.settings-page.php:453
    189249msgid "by default 100"
    190250msgstr "по-умолчанию 100"
    191251
    192 #: ../inc/class.settings-page.php:401
     252#: ../inc/class.settings-page.php:454
    193253msgid ""
    194254"If the catalog's container is bigger than your theme's container, change it "
     
    198258"темы"
    199259
    200 #: ../inc/class.settings-page.php:408
     260#: ../inc/class.settings-page.php:461
    201261msgid ""
    202262"Add 'margin: 0 auto;' to the container. If you have changed container's "
     
    206266"контейнера, то скоре всего, нужно отметить и эту опцию"
    207267
    208 #: ../inc/class.settings-page.php:415
     268#: ../inc/class.settings-page.php:468
    209269msgid "by default 60"
    210270msgstr "по-умолчанию 60"
    211271
    212 #: ../inc/class.settings-page.php:416
     272#: ../inc/class.settings-page.php:469
    213273msgid ""
    214274"Set width of Product Info Container on single product page. In that "
     
    224284"изображением."
    225285
    226 #: ../inc/class.settings-page.php:427 ../inc/class.settings-page.php:451
    227 #: ../inc/class.settings-page.php:467 ../inc/class.settings-page.php:478
     286#: ../inc/class.settings-page.php:480 ../inc/class.settings-page.php:504
     287#: ../inc/class.settings-page.php:520 ../inc/class.settings-page.php:531
    228288msgid "in grid"
    229289msgstr "в сетке"
    230290
    231 #: ../inc/class.settings-page.php:428
     291#: ../inc/class.settings-page.php:481
    232292msgid ""
    233293"If you don't need thumbnails for the categories, please uncheck this option"
    234294msgstr "Если миниатюры для рубрик не нужны, отключите эту опцию"
    235295
    236 #: ../inc/class.settings-page.php:432
     296#: ../inc/class.settings-page.php:485
    237297msgid "Width: "
    238298msgstr "Ширина: "
    239299
    240 #: ../inc/class.settings-page.php:436 ../inc/class.settings-page.php:442
     300#: ../inc/class.settings-page.php:489 ../inc/class.settings-page.php:495
    241301msgid "px"
    242302msgstr "пикс. "
    243303
    244 #: ../inc/class.settings-page.php:438
     304#: ../inc/class.settings-page.php:491
    245305msgid "Height: "
    246306msgstr "Высота: "
    247307
    248 #: ../inc/class.settings-page.php:444
     308#: ../inc/class.settings-page.php:497
    249309msgid ""
    250310"Set size of thumbnails for categories and products. After that please use <a "
     
    259319"заглушек изменен не будет."
    260320
    261 #: ../inc/class.settings-page.php:455
     321#: ../inc/class.settings-page.php:508
    262322msgid "in category page"
    263323msgstr "на странице рубрики"
    264324
    265 #: ../inc/class.settings-page.php:456
     325#: ../inc/class.settings-page.php:509
    266326msgid ""
    267327"If you don't need description for the categories, please uncheck this option"
    268328msgstr "Если описания для рубрик не нужны, отключите эту опцию"
    269329
    270 #: ../inc/class.settings-page.php:471 ../inc/class.settings-page.php:482
     330#: ../inc/class.settings-page.php:524 ../inc/class.settings-page.php:535
    271331msgid "in single product page"
    272332msgstr "на странице товара"
    273333
    274 #: ../inc/class.settings-page.php:489 ../inc/class.settings-page.php:501
     334#: ../inc/class.settings-page.php:542 ../inc/class.settings-page.php:554
    275335msgid " by default: empty"
    276336msgstr "по-умолчанию: пусто"
    277337
    278 #: ../inc/class.settings-page.php:492
     338#: ../inc/class.settings-page.php:545
    279339msgid ""
    280340"Currency prefix, for ex.: &#36; or &#128;. Just leave it emply if you don't "
     
    284344"нужен"
    285345
    286 #: ../inc/class.settings-page.php:504
     346#: ../inc/class.settings-page.php:557
    287347msgid ""
    288348"Currency postfix, for ex.: RUB. Just leave it emply if you don't need postfix"
     
    290350"Постфикс валюты, например: руб. Оставьте пустым, если постфикс не нужен"
    291351
    292 #: ../inc/class.settings-page.php:517
     352#: ../inc/class.settings-page.php:570
    293353msgid ""
    294354"Please turn the option on, if you would like to use the special sidebar for "
     
    298358"страницах каталога"
    299359
    300 #: ../inc/class.settings-page.php:524
     360#: ../inc/class.settings-page.php:577
    301361msgid "by default 20"
    302362msgstr "по-умолчанию 20"
    303363
    304 #: ../inc/class.settings-page.php:525
     364#: ../inc/class.settings-page.php:578
    305365msgid "Set width of the Sidebar"
    306366msgstr "Установить ширину сайдбара"
     
    398458msgstr "Не найдено"
    399459
    400 #: ../inc/functions.php:109
     460#: ../inc/functions.php:116
    401461msgid "Price:"
    402462msgstr "Цена:"
    403463
    404 #: ../inc/functions.php:145
     464#: ../inc/functions.php:152
    405465msgid "SKU:"
    406466msgstr "Артикул:"
  • goods-catalog/trunk/readme.txt

    r1171371 r1233870  
    105105== Changelog ==
    106106
     107= 0.10.0 =
     108
     109* New feature: sorting the products
     110
    107111= 0.9.4 =
    108112
     
    274278== Upgrade Notice ==
    275279
     280= 0.10.0 =
     281
     282New feature: sorting the products
     283
    276284= 0.9.3 =
    277285
  • goods-catalog/trunk/templates/taxonomy-goods_category.php

    r1154409 r1233870  
    4747
    4848/**
    49  * Include the list of subcategories in grid.
     49 * Include the list of products in grid.
    5050 *
    5151 * If you edit this template by coping into your theme's folder, please change this functions with the following:
    5252 * load_template(WP_PLUGIN_DIR  . '/goods-catalog/templates/content-goods_grid.php');
    5353 */
     54
    5455load_template(dirname(__FILE__) . '/content-goods_grid.php');
    5556?>
  • goods-catalog/trunk/templates/taxonomy-goods_tag.php

    r1154409 r1233870  
    1717
    1818/**
    19  * Include the list of subcategories in grid.
     19 * Include the list of products in grid.
    2020 *
    2121 * If you edit this template by coping into your theme's folder, please change this functions with the following:
Note: See TracChangeset for help on using the changeset viewer.