Plugin Directory

Changeset 1419216


Ignore:
Timestamp:
05/17/2016 11:37:49 PM (10 years ago)
Author:
edpittol
Message:

updated the plugin version to 0.6.0

Location:
hookit-related-products
Files:
55 added
14 edited

Legend:

Unmodified
Added
Removed
  • hookit-related-products/trunk/admin/actions.php

    r1363622 r1419216  
    99 * @param WP_Post $post The post object.
    1010 * @param bool $update Whether this is an existing post being updated or not.
     11 * @return The saved post meta
    1112 */
    1213function hookit_recommended_products_save_post( $post_id, $post, $update ) {
     
    4344        add_post_meta( $post_id, 'hookit_recommended_products', $save );
    4445    }
     46   
     47    return $save;
    4548}
    4649add_action( 'save_post', 'hookit_recommended_products_save_post', 10, 3 );
     
    8083}
    8184add_action( 'admin_enqueue_scripts', 'hookit_recommended_products_admin_enqueue_scripts' );
     85
     86function hookit_recommended_products_admin_menu() {
     87    add_menu_page(
     88        __( 'Hookit Recommended Products', 'hookit-recommended-products' ),
     89        __( 'Hookit', 'hookit-recommended-products'),
     90        'manage_options',
     91        'hookit_recommended_products',
     92        'hookit_recommended_products_settings',
     93        '',
     94        100
     95    );
     96   
     97    add_submenu_page(
     98        'hookit_recommended_products',
     99        __( 'Settings', 'hookit-recommended-products'),
     100        __( 'Settings', 'hookit-recommended-products'),
     101        'manage_options',
     102        'hookit_recommended_products',
     103        'hookit_recommended_products_settings'
     104    );
     105
     106    add_submenu_page(
     107        'hookit_recommended_products',
     108        __( 'Update Posts', 'hookit-recommended-products' ),
     109        __( 'Update Posts', 'hookit-recommended-products' ),
     110        'edit_posts',
     111        'hookit_recommended_products_tool',
     112        'hookit_recommended_products_tool'
     113    );
     114}
     115add_action( 'admin_menu', 'hookit_recommended_products_admin_menu' );
  • hookit-related-products/trunk/admin/functions.php

    r1358531 r1419216  
    1010 */
    1111function hookit_recommended_products_get_recommended( $post ) {
     12    $hookit_categories = array();
     13    $gender = hookit_recommended_products_get_gender();
     14    switch ($gender) {
     15        case 'Male' :
     16            $hookit_categories[] = 'Masculino';
     17            break;
     18
     19        case 'Female' :
     20            $hookit_categories[] = 'Feminino';
     21            break;
     22    }
     23   
    1224    return hookit_recommended_products_consume_ws( 'get-post-recommended-products', array(
    1325        'id' => $post->ID,
    1426        'title' => $post->post_title,
    1527        'content' => strip_tags( $post->post_content ),
    16         'tags' => wp_get_post_tags( $post->ID, array( 'fields' => 'names' ) )
     28        'tags' => wp_get_post_tags( $post->ID, array( 'fields' => 'names' ) ),
     29        'hookit_categories' => $hookit_categories,
    1730    ) );
    1831}
     32
     33/**
     34 * Get all posts that has active the recommended product view.
     35 *
     36 * @return WP_Post[] The posts objects.
     37 */
     38function hookit_recommended_products_get_posts() {
     39    // create a WP_Query without args to not execute the query on create
     40    $query = new WP_Query();
     41   
     42    // get all posts
     43    $query->set( 'posts_per_page', -1 );
     44   
     45    // don't select deactivated post
     46    $query->set( 'meta_query', array(
     47        'relation' => 'OR',
     48        array(
     49            'key' => 'hookit_recommended_products',
     50            'value' => 'deactivated',
     51            'compare' => '!=',
     52        ),
     53        array(
     54            'key' => 'hookit_recommended_products',
     55            'compare' => 'NOT EXISTS'
     56        ),
     57    ) );
     58   
     59    // if has active categories, filter them
     60    $categories = hookit_recommended_products_get_categories();
     61    if( ! empty( $categories ) ) {
     62        $query->set( 'category__in', $categories );
     63    }
     64   
     65    // execute the query
     66    return $query->get_posts();
     67}
     68
     69/**
     70 * Get all posts that has active the recommended product view.
     71 *
     72 * @return integer[] The posts id.
     73 */
     74function hookit_recommended_products_get_posts_id() {
     75    return wp_list_pluck( hookit_recommended_products_get_posts(), 'ID' );
     76}
  • hookit-related-products/trunk/admin/settings.php

    r1414834 r1419216  
    3333    register_setting( 'hookit-recommended-products', 'hookit_recommended_products_token' );
    3434    register_setting( 'hookit-recommended-products', 'hookit_recommended_products_categories' );
     35    register_setting( 'hookit-recommended-products', 'hookit_recommended_products_sign' );
     36    register_setting( 'hookit-recommended-products', 'hookit_recommended_products_gender' );
    3537}
    3638add_action( 'admin_init', 'hookit_recommended_products_settings_admin_init' );
    37 
    38 /**
    39  * Add a settings page to set view parameters
    40  */
    41 function hookit_recommended_products_settings_admin_menu() {
    42     $title = __( 'Hookit Recommended Products' , 'hookit-recommended-products' );
    43    
    44     add_submenu_page(
    45         'options-general.php',
    46         $title,
    47         $title,
    48         'manage_options',
    49         'hookit_recommended_products_settings',
    50         'hookit_recommended_products_settings'
    51     );
    52 }
    53 add_action( 'admin_menu', 'hookit_recommended_products_settings_admin_menu' );
    5439
    5540/**
  • hookit-related-products/trunk/admin/views/settings.php

    r1414834 r1419216  
    11<div class="wrap">
    2     <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
     2    <?php require __DIR__ . '/header.php'; ?>
    33
    44    <form method="post" action="options.php" novalidate="novalidate">
     
    6565            <tr>
    6666                <th scope="row">
    67                     <label for=view-title"><?php _e( 'Categories' ) ?></label>
     67                    <label for=view-title"><?php _e( 'Categories', 'hookit-recommended-products' ) ?></label>
    6868                </th>
    6969                <td>
     
    8181                </td>
    8282            </tr>
     83            <tr>
     84                <th scope="row">
     85                    <label for=view-title"><?php _e( 'Signature', 'hookit-recommended-products' ) ?></label>
     86                </th>
     87                <td>
     88                    <fieldset>
     89                        <legend class="screen-reader-text">
     90                            <span><?php _e( 'Signature', 'hookit-recommended-products' ) ?></span>
     91                        </legend>
     92                        <label for="hookit_recommended_products_sign">
     93                            <input
     94                                name="hookit_recommended_products_sign"
     95                                id="hookit_recommended_products_sign"
     96                                value="1"
     97                                <?php echo hookit_recommended_products_get_sign() ? 'checked="checked"' : '' ?>
     98                                type="checkbox">
     99                                <?php _e( 'Add Hookit signature in the recommended products list.', 'hookit-recommended-products' ) ?>
     100                        </label>
     101                    </fieldset>
     102                </td>
     103            </tr>
     104            <tr>
     105                <th scope="row">
     106                    <label for=view-title"><?php _e( 'Gender', 'hookit-recommended-products' ) ?></label>
     107                </th>
     108                <td>
     109                    <select id="viewproducts" name="hookit_recommended_products_gender" aria-describedby="view-products-description">
     110                        <?php
     111                            $values = array(
     112                                'Both' => __( 'Both', 'hookit-recommended-products' ),
     113                                'Female' => __( 'Female', 'hookit-recommended-products' ),
     114                                'Male' => __( 'Male', 'hookit-recommended-products' ),
     115                            );
     116                            $selected = hookit_recommended_products_get_gender();
     117                            foreach ( $values as $value => $label  ) :
     118                        ?>
     119                        <option value="<?php echo $value ?>" <?php if( $selected == $value ) : ?>selected="selected"<?php endif; ?>>
     120                            <?php echo $label ?>
     121                        </option>
     122                        <?php endforeach; ?>
     123                    </select>
     124                    <p class="description" id="view-products-description">
     125                        <?php _e( 'The gender of recommended products.', 'hookit-recommended-products' ) ?>
     126                    </p>
     127                </td>
     128            </tr>
    83129        </table>
    84130       
  • hookit-related-products/trunk/assets/css/admin.css

    r1408115 r1419216  
    1 /* line 1, ../../../sass/admin.scss */
     1@charset "UTF-8";
     2@font-face {
     3  font-family: 'hookit-icon';
     4  src: url("../fonts/hookit-icon.eot?bj5ce7");
     5  src: url("../fonts/hookit-icon.eot?bj5ce7#iefix") format("embedded-opentype"), url("../fonts/hookit-icon.ttf?bj5ce7") format("truetype"), url("../fonts/hookit-icon.woff?bj5ce7") format("woff"), url("../fonts/hookit-icon.svg?bj5ce7#hookit-icon") format("svg");
     6  font-weight: normal;
     7  font-style: normal;
     8}
     9/* line 14, ../../../fonts/hookit-icon/style.scss */
     10[class^="icon-"], [class*=" icon-"] {
     11  /* use !important to prevent issues with browser extensions that change fonts */
     12  font-family: 'hookit-icon' !important;
     13  speak: none;
     14  font-style: normal;
     15  font-weight: normal;
     16  font-variant: normal;
     17  text-transform: none;
     18  line-height: 1;
     19  /* Better Font Rendering =========== */
     20  -webkit-font-smoothing: antialiased;
     21  -moz-osx-font-smoothing: grayscale;
     22}
     23
     24/* line 30, ../../../fonts/hookit-icon/style.scss */
     25.icon-hookit:before {
     26  content: "";
     27}
     28
     29/* line 5, ../../../sass/admin.scss */
    230.hookit-recommended-product-deactivate {
    331  margin-bottom: 20px;
    432}
     33
     34/* line 11, ../../../sass/admin.scss */
     35#toplevel_page_hookit_recommended_products .wp-menu-image:before {
     36  content: "";
     37  font-family: 'hookit-icon';
     38}
  • hookit-related-products/trunk/assets/css/style.css

    r1363622 r1419216  
    1717  clear: both;
    1818}
     19/* line 18, ../../../sass/style.scss */
     20.hookit-recommended-products .sign {
     21  text-align: right;
     22}
  • hookit-related-products/trunk/hookit-recommended-products.php

    r1414834 r1419216  
    33/**
    44 * Plugin Name: Hookit Recommended Products
    5  * Version: 0.5.4
     5 * Version: 0.6.0
    66 * Plugin URI: https://bitbucket.org/edpittol/hookit-recommended-products
    77 * Description: WordPress plugin to get Hookit related products from a post
  • hookit-related-products/trunk/includes/functions.php

    r1414834 r1419216  
    22
    33defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    4 
    5 
    64
    75/**
     
    215213    return get_option( 'hookit_recommended_products_categories', array() );
    216214}
     215
     216/**
     217 * Get the categories activated to show the recommended products. If not setted
     218 * get the default.
     219 *
     220 * @return boolean The setting.
     221 */
     222function hookit_recommended_products_get_sign() {   
     223    return '1' === get_option( 'hookit_recommended_products_sign', '' );
     224}
     225
     226/**
     227 * Get the gender of the products that must be showed.
     228 *
     229 * @return boolean The setting.
     230 */
     231function hookit_recommended_products_get_gender() {
     232    return get_option( 'hookit_recommended_products_gender', 'Both' );
     233}
  • hookit-related-products/trunk/init.php

    r1414834 r1419216  
    1313    require_once 'admin/metabox.php';
    1414    require_once 'admin/settings.php';
     15    require_once 'admin/tool.php';
    1516}
  • hookit-related-products/trunk/languages/hookit-recommended-products-pt_BR.po

    r1363622 r1419216  
    22msgstr ""
    33"Project-Id-Version: Hookit Related Products\n"
    4 "POT-Creation-Date: 2016-03-03 16:36-0300\n"
    5 "PO-Revision-Date: 2016-03-03 16:36-0300\n"
     4"POT-Creation-Date: 2016-05-17 19:41-0300\n"
     5"PO-Revision-Date: 2016-05-17 19:42-0300\n"
    66"Last-Translator: \n"
    77"Language-Team: Hookit <contato@hookit.cc>\n"
     
    1717"X-Poedit-SearchPath-0: .\n"
    1818
    19 #: admin/metabox.php:13 admin/settings.php:56
     19#: admin/actions.php:88 admin/metabox.php:13 admin/settings.php:44
    2020msgid "Hookit Recommended Products"
    2121msgstr "Hookit Produtos Recomendados"
    2222
    23 #: admin/settings.php:10
    24 msgid "Recommended Products"
    25 msgstr "Produtos Recomendados"
     23#: admin/actions.php:89
     24msgid "Hookit"
     25msgstr "Hookit"
     26
     27#: admin/actions.php:99 admin/actions.php:100 admin/views/header.php:6
     28msgid "Settings"
     29msgstr "Configurações"
     30
     31#: admin/actions.php:108 admin/actions.php:109 admin/views/header.php:11
     32msgid "Update Posts"
     33msgstr "Atualizar posts"
     34
     35#: admin/tool.php:44
     36msgid "Ok"
     37msgstr "Ok"
    2638
    2739#: admin/views/metabox.php:14
     
    2941msgstr "Desativar produtos recomendados para este post."
    3042
    31 #: admin/views/metabox.php:35
     43#: admin/views/metabox.php:34
    3244msgid "Inactive"
    3345msgstr "Inativo"
    3446
    35 #: admin/views/metabox.php:42
     47#: admin/views/metabox.php:41
    3648msgid "Any product found for this post."
    3749msgstr "Nenhum produto relacionado encontrado para esse post."
     
    8193"sejam exibidos."
    8294
    83 #: includes/functions.php:107
     95#: admin/views/settings.php:85 admin/views/settings.php:90
     96msgid "Signature"
     97msgstr "Assinatura"
     98
     99#: admin/views/settings.php:99
     100msgid "Add Hookit signature in the recommended products list."
     101msgstr "Adicionar assinatura da Hookit na lista de produtos recomendados."
     102
     103#: admin/views/settings.php:106
     104msgid "Gender"
     105msgstr "Gênero"
     106
     107#: admin/views/settings.php:112
     108msgid "Both"
     109msgstr "Ambos"
     110
     111#: admin/views/settings.php:113
     112msgid "Female"
     113msgstr "Feminino"
     114
     115#: admin/views/settings.php:114
     116msgid "Male"
     117msgstr "Masculino"
     118
     119#: admin/views/settings.php:125
     120msgid "The gender of recommended products."
     121msgstr "O gênero dos produtos recomendados."
     122
     123#: admin/views/tool.php:11
     124msgid "Getting recommended products..."
     125msgstr "Obtendo produtos recomendados…"
     126
     127#: admin/views/tool.php:16
     128msgid "Process all posts"
     129msgstr "Processar todos posts"
     130
     131#: includes/functions.php:120
    84132#, php-format
    85133msgid ""
     
    89137"problema."
    90138
    91 #: includes/functions.php:140
     139#: includes/functions.php:154
    92140#, php-format
    93141msgid "The Web Service returned the %d code."
    94142msgstr "O serviço da Web retornou o código %d."
     143
     144#~ msgid "Recommended Products"
     145#~ msgstr "Produtos Recomendados"
    95146
    96147#~ msgid "Select the categories that will show recommended products."
  • hookit-related-products/trunk/languages/hookit-recommended-products.pot

    r1363622 r1419216  
    33msgstr ""
    44"Project-Id-Version: Hookit Related Products\n"
    5 "POT-Creation-Date: 2016-03-03 16:35-0300\n"
     5"POT-Creation-Date: 2016-05-17 19:41-0300\n"
    66"PO-Revision-Date: 2015-09-02 17:13-0300\n"
    77"Last-Translator: \n"
     
    1818"X-Poedit-SearchPath-0: .\n"
    1919
    20 #: admin/metabox.php:13 admin/settings.php:56
     20#: admin/actions.php:88 admin/metabox.php:13 admin/settings.php:44
    2121msgid "Hookit Recommended Products"
    2222msgstr ""
    2323
    24 #: admin/settings.php:10
    25 msgid "Recommended Products"
     24#: admin/actions.php:89
     25msgid "Hookit"
     26msgstr ""
     27
     28#: admin/actions.php:99 admin/actions.php:100 admin/views/header.php:6
     29msgid "Settings"
     30msgstr ""
     31
     32#: admin/actions.php:108 admin/actions.php:109 admin/views/header.php:11
     33msgid "Update Posts"
     34msgstr ""
     35
     36#: admin/tool.php:44
     37msgid "Ok"
    2638msgstr ""
    2739
     
    3042msgstr ""
    3143
    32 #: admin/views/metabox.php:35
     44#: admin/views/metabox.php:34
    3345msgid "Inactive"
    3446msgstr ""
    3547
    36 #: admin/views/metabox.php:42
     48#: admin/views/metabox.php:41
    3749msgid "Any product found for this post."
    3850msgstr ""
     
    7183msgstr ""
    7284
    73 #: includes/functions.php:107
     85#: admin/views/settings.php:85 admin/views/settings.php:90
     86msgid "Signature"
     87msgstr ""
     88
     89#: admin/views/settings.php:99
     90msgid "Add Hookit signature in the recommended products list."
     91msgstr ""
     92
     93#: admin/views/settings.php:106
     94msgid "Gender"
     95msgstr ""
     96
     97#: admin/views/settings.php:112
     98msgid "Both"
     99msgstr ""
     100
     101#: admin/views/settings.php:113
     102msgid "Female"
     103msgstr ""
     104
     105#: admin/views/settings.php:114
     106msgid "Male"
     107msgstr ""
     108
     109#: admin/views/settings.php:125
     110msgid "The gender of recommended products."
     111msgstr ""
     112
     113#: admin/views/tool.php:11
     114msgid "Getting recommended products..."
     115msgstr ""
     116
     117#: admin/views/tool.php:16
     118msgid "Process all posts"
     119msgstr ""
     120
     121#: includes/functions.php:120
    74122#, php-format
    75123msgid "See the <a href=\"%s\" target=\"_blank\">Wiki page</a> to solve this problem."
    76124msgstr ""
    77125
    78 #: includes/functions.php:140
     126#: includes/functions.php:154
    79127#, php-format
    80128msgid "The Web Service returned the %d code."
  • hookit-related-products/trunk/readme.txt

    r1414834 r1419216  
    3434
    3535== Changelog ==
     36
     37= 0.6.0 =
     38* Seleção do gênero dos produtos recomendados
     39* Ferramenta para atualizar todos posts
     40* Assinatura "Recomendado por Hookit"
    3641
    3742= 0.5.4 =
  • hookit-related-products/trunk/views/recommended-products.php

    r1414834 r1419216  
    4444    <div class="clear"></div>
    4545   
     46    <?php if( hookit_recommended_products_get_sign() ) : ?>
     47    <div class="sign">
     48        <a href="http://hookit.cc" target="_blank">
     49            <?php global $hookit_recommended_products_base_url; ?>
     50            <img src="<?php echo $hookit_recommended_products_base_url ?>/assets/img/sign.png" alt="Hookit" />
     51        </a>
     52    </div>
     53    <?php endif; ?>
     54   
    4655    <?php do_action( 'hookit_recommended_products_after_products' ) ?>
    4756</div>
Note: See TracChangeset for help on using the changeset viewer.