Changeset 1419216
- Timestamp:
- 05/17/2016 11:37:49 PM (10 years ago)
- Location:
- hookit-related-products
- Files:
-
- 55 added
- 14 edited
-
tags/0.6.0 (added)
-
tags/0.6.0/admin (added)
-
tags/0.6.0/admin/actions.php (added)
-
tags/0.6.0/admin/functions.php (added)
-
tags/0.6.0/admin/metabox.php (added)
-
tags/0.6.0/admin/settings.php (added)
-
tags/0.6.0/admin/tool.php (added)
-
tags/0.6.0/admin/views (added)
-
tags/0.6.0/admin/views/header.php (added)
-
tags/0.6.0/admin/views/metabox.php (added)
-
tags/0.6.0/admin/views/settings.php (added)
-
tags/0.6.0/admin/views/tool.php (added)
-
tags/0.6.0/assets (added)
-
tags/0.6.0/assets/css (added)
-
tags/0.6.0/assets/css/admin.css (added)
-
tags/0.6.0/assets/css/hookit-icon.css (added)
-
tags/0.6.0/assets/css/multi-select.css (added)
-
tags/0.6.0/assets/css/style.css (added)
-
tags/0.6.0/assets/fonts (added)
-
tags/0.6.0/assets/fonts/hookit-icon.eot (added)
-
tags/0.6.0/assets/fonts/hookit-icon.svg (added)
-
tags/0.6.0/assets/fonts/hookit-icon.ttf (added)
-
tags/0.6.0/assets/fonts/hookit-icon.woff (added)
-
tags/0.6.0/assets/img (added)
-
tags/0.6.0/assets/img/sign.png (added)
-
tags/0.6.0/assets/img/switch.png (added)
-
tags/0.6.0/assets/js (added)
-
tags/0.6.0/assets/js/jquery.multi-select.js (added)
-
tags/0.6.0/assets/js/script.js (added)
-
tags/0.6.0/assets/js/tool.js (added)
-
tags/0.6.0/hookit-recommended-products.php (added)
-
tags/0.6.0/includes (added)
-
tags/0.6.0/includes/actions.php (added)
-
tags/0.6.0/includes/filters.php (added)
-
tags/0.6.0/includes/functions.php (added)
-
tags/0.6.0/index.php (added)
-
tags/0.6.0/init.php (added)
-
tags/0.6.0/languages (added)
-
tags/0.6.0/languages/hookit-recommended-products-pt_BR.mo (added)
-
tags/0.6.0/languages/hookit-recommended-products-pt_BR.po (added)
-
tags/0.6.0/languages/hookit-recommended-products.pot (added)
-
tags/0.6.0/readme.txt (added)
-
tags/0.6.0/views (added)
-
tags/0.6.0/views/recommended-products.php (added)
-
trunk/admin/actions.php (modified) (3 diffs)
-
trunk/admin/functions.php (modified) (1 diff)
-
trunk/admin/settings.php (modified) (1 diff)
-
trunk/admin/tool.php (added)
-
trunk/admin/views/header.php (added)
-
trunk/admin/views/settings.php (modified) (3 diffs)
-
trunk/admin/views/tool.php (added)
-
trunk/assets/css/admin.css (modified) (1 diff)
-
trunk/assets/css/hookit-icon.css (added)
-
trunk/assets/css/style.css (modified) (1 diff)
-
trunk/assets/fonts (added)
-
trunk/assets/fonts/hookit-icon.eot (added)
-
trunk/assets/fonts/hookit-icon.svg (added)
-
trunk/assets/fonts/hookit-icon.ttf (added)
-
trunk/assets/fonts/hookit-icon.woff (added)
-
trunk/assets/img/sign.png (added)
-
trunk/assets/js/tool.js (added)
-
trunk/hookit-recommended-products.php (modified) (1 diff)
-
trunk/includes/functions.php (modified) (2 diffs)
-
trunk/init.php (modified) (1 diff)
-
trunk/languages/hookit-recommended-products-pt_BR.mo (modified) (previous)
-
trunk/languages/hookit-recommended-products-pt_BR.po (modified) (5 diffs)
-
trunk/languages/hookit-recommended-products.pot (modified) (4 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/views/recommended-products.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
hookit-related-products/trunk/admin/actions.php
r1363622 r1419216 9 9 * @param WP_Post $post The post object. 10 10 * @param bool $update Whether this is an existing post being updated or not. 11 * @return The saved post meta 11 12 */ 12 13 function hookit_recommended_products_save_post( $post_id, $post, $update ) { … … 43 44 add_post_meta( $post_id, 'hookit_recommended_products', $save ); 44 45 } 46 47 return $save; 45 48 } 46 49 add_action( 'save_post', 'hookit_recommended_products_save_post', 10, 3 ); … … 80 83 } 81 84 add_action( 'admin_enqueue_scripts', 'hookit_recommended_products_admin_enqueue_scripts' ); 85 86 function 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 } 115 add_action( 'admin_menu', 'hookit_recommended_products_admin_menu' ); -
hookit-related-products/trunk/admin/functions.php
r1358531 r1419216 10 10 */ 11 11 function 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 12 24 return hookit_recommended_products_consume_ws( 'get-post-recommended-products', array( 13 25 'id' => $post->ID, 14 26 'title' => $post->post_title, 15 27 '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, 17 30 ) ); 18 31 } 32 33 /** 34 * Get all posts that has active the recommended product view. 35 * 36 * @return WP_Post[] The posts objects. 37 */ 38 function 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 */ 74 function 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 33 33 register_setting( 'hookit-recommended-products', 'hookit_recommended_products_token' ); 34 34 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' ); 35 37 } 36 38 add_action( 'admin_init', 'hookit_recommended_products_settings_admin_init' ); 37 38 /**39 * Add a settings page to set view parameters40 */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' );54 39 55 40 /** -
hookit-related-products/trunk/admin/views/settings.php
r1414834 r1419216 1 1 <div class="wrap"> 2 < h2><?php echo esc_html( get_admin_page_title() ); ?></h2>2 <?php require __DIR__ . '/header.php'; ?> 3 3 4 4 <form method="post" action="options.php" novalidate="novalidate"> … … 65 65 <tr> 66 66 <th scope="row"> 67 <label for=view-title"><?php _e( 'Categories' ) ?></label>67 <label for=view-title"><?php _e( 'Categories', 'hookit-recommended-products' ) ?></label> 68 68 </th> 69 69 <td> … … 81 81 </td> 82 82 </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> 83 129 </table> 84 130 -
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 */ 2 30 .hookit-recommended-product-deactivate { 3 31 margin-bottom: 20px; 4 32 } 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 17 17 clear: both; 18 18 } 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 3 3 /** 4 4 * Plugin Name: Hookit Recommended Products 5 * Version: 0. 5.45 * Version: 0.6.0 6 6 * Plugin URI: https://bitbucket.org/edpittol/hookit-recommended-products 7 7 * Description: WordPress plugin to get Hookit related products from a post -
hookit-related-products/trunk/includes/functions.php
r1414834 r1419216 2 2 3 3 defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); 4 5 6 4 7 5 /** … … 215 213 return get_option( 'hookit_recommended_products_categories', array() ); 216 214 } 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 */ 222 function 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 */ 231 function hookit_recommended_products_get_gender() { 232 return get_option( 'hookit_recommended_products_gender', 'Both' ); 233 } -
hookit-related-products/trunk/init.php
r1414834 r1419216 13 13 require_once 'admin/metabox.php'; 14 14 require_once 'admin/settings.php'; 15 require_once 'admin/tool.php'; 15 16 } -
hookit-related-products/trunk/languages/hookit-recommended-products-pt_BR.po
r1363622 r1419216 2 2 msgstr "" 3 3 "Project-Id-Version: Hookit Related Products\n" 4 "POT-Creation-Date: 2016-0 3-03 16:36-0300\n"5 "PO-Revision-Date: 2016-0 3-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" 6 6 "Last-Translator: \n" 7 7 "Language-Team: Hookit <contato@hookit.cc>\n" … … 17 17 "X-Poedit-SearchPath-0: .\n" 18 18 19 #: admin/ metabox.php:13 admin/settings.php:5619 #: admin/actions.php:88 admin/metabox.php:13 admin/settings.php:44 20 20 msgid "Hookit Recommended Products" 21 21 msgstr "Hookit Produtos Recomendados" 22 22 23 #: admin/settings.php:10 24 msgid "Recommended Products" 25 msgstr "Produtos Recomendados" 23 #: admin/actions.php:89 24 msgid "Hookit" 25 msgstr "Hookit" 26 27 #: admin/actions.php:99 admin/actions.php:100 admin/views/header.php:6 28 msgid "Settings" 29 msgstr "Configurações" 30 31 #: admin/actions.php:108 admin/actions.php:109 admin/views/header.php:11 32 msgid "Update Posts" 33 msgstr "Atualizar posts" 34 35 #: admin/tool.php:44 36 msgid "Ok" 37 msgstr "Ok" 26 38 27 39 #: admin/views/metabox.php:14 … … 29 41 msgstr "Desativar produtos recomendados para este post." 30 42 31 #: admin/views/metabox.php:3 543 #: admin/views/metabox.php:34 32 44 msgid "Inactive" 33 45 msgstr "Inativo" 34 46 35 #: admin/views/metabox.php:4 247 #: admin/views/metabox.php:41 36 48 msgid "Any product found for this post." 37 49 msgstr "Nenhum produto relacionado encontrado para esse post." … … 81 93 "sejam exibidos." 82 94 83 #: includes/functions.php:107 95 #: admin/views/settings.php:85 admin/views/settings.php:90 96 msgid "Signature" 97 msgstr "Assinatura" 98 99 #: admin/views/settings.php:99 100 msgid "Add Hookit signature in the recommended products list." 101 msgstr "Adicionar assinatura da Hookit na lista de produtos recomendados." 102 103 #: admin/views/settings.php:106 104 msgid "Gender" 105 msgstr "Gênero" 106 107 #: admin/views/settings.php:112 108 msgid "Both" 109 msgstr "Ambos" 110 111 #: admin/views/settings.php:113 112 msgid "Female" 113 msgstr "Feminino" 114 115 #: admin/views/settings.php:114 116 msgid "Male" 117 msgstr "Masculino" 118 119 #: admin/views/settings.php:125 120 msgid "The gender of recommended products." 121 msgstr "O gênero dos produtos recomendados." 122 123 #: admin/views/tool.php:11 124 msgid "Getting recommended products..." 125 msgstr "Obtendo produtos recomendados…" 126 127 #: admin/views/tool.php:16 128 msgid "Process all posts" 129 msgstr "Processar todos posts" 130 131 #: includes/functions.php:120 84 132 #, php-format 85 133 msgid "" … … 89 137 "problema." 90 138 91 #: includes/functions.php:1 40139 #: includes/functions.php:154 92 140 #, php-format 93 141 msgid "The Web Service returned the %d code." 94 142 msgstr "O serviço da Web retornou o código %d." 143 144 #~ msgid "Recommended Products" 145 #~ msgstr "Produtos Recomendados" 95 146 96 147 #~ msgid "Select the categories that will show recommended products." -
hookit-related-products/trunk/languages/hookit-recommended-products.pot
r1363622 r1419216 3 3 msgstr "" 4 4 "Project-Id-Version: Hookit Related Products\n" 5 "POT-Creation-Date: 2016-0 3-03 16:35-0300\n"5 "POT-Creation-Date: 2016-05-17 19:41-0300\n" 6 6 "PO-Revision-Date: 2015-09-02 17:13-0300\n" 7 7 "Last-Translator: \n" … … 18 18 "X-Poedit-SearchPath-0: .\n" 19 19 20 #: admin/ metabox.php:13 admin/settings.php:5620 #: admin/actions.php:88 admin/metabox.php:13 admin/settings.php:44 21 21 msgid "Hookit Recommended Products" 22 22 msgstr "" 23 23 24 #: admin/settings.php:10 25 msgid "Recommended Products" 24 #: admin/actions.php:89 25 msgid "Hookit" 26 msgstr "" 27 28 #: admin/actions.php:99 admin/actions.php:100 admin/views/header.php:6 29 msgid "Settings" 30 msgstr "" 31 32 #: admin/actions.php:108 admin/actions.php:109 admin/views/header.php:11 33 msgid "Update Posts" 34 msgstr "" 35 36 #: admin/tool.php:44 37 msgid "Ok" 26 38 msgstr "" 27 39 … … 30 42 msgstr "" 31 43 32 #: admin/views/metabox.php:3 544 #: admin/views/metabox.php:34 33 45 msgid "Inactive" 34 46 msgstr "" 35 47 36 #: admin/views/metabox.php:4 248 #: admin/views/metabox.php:41 37 49 msgid "Any product found for this post." 38 50 msgstr "" … … 71 83 msgstr "" 72 84 73 #: includes/functions.php:107 85 #: admin/views/settings.php:85 admin/views/settings.php:90 86 msgid "Signature" 87 msgstr "" 88 89 #: admin/views/settings.php:99 90 msgid "Add Hookit signature in the recommended products list." 91 msgstr "" 92 93 #: admin/views/settings.php:106 94 msgid "Gender" 95 msgstr "" 96 97 #: admin/views/settings.php:112 98 msgid "Both" 99 msgstr "" 100 101 #: admin/views/settings.php:113 102 msgid "Female" 103 msgstr "" 104 105 #: admin/views/settings.php:114 106 msgid "Male" 107 msgstr "" 108 109 #: admin/views/settings.php:125 110 msgid "The gender of recommended products." 111 msgstr "" 112 113 #: admin/views/tool.php:11 114 msgid "Getting recommended products..." 115 msgstr "" 116 117 #: admin/views/tool.php:16 118 msgid "Process all posts" 119 msgstr "" 120 121 #: includes/functions.php:120 74 122 #, php-format 75 123 msgid "See the <a href=\"%s\" target=\"_blank\">Wiki page</a> to solve this problem." 76 124 msgstr "" 77 125 78 #: includes/functions.php:1 40126 #: includes/functions.php:154 79 127 #, php-format 80 128 msgid "The Web Service returned the %d code." -
hookit-related-products/trunk/readme.txt
r1414834 r1419216 34 34 35 35 == 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" 36 41 37 42 = 0.5.4 = -
hookit-related-products/trunk/views/recommended-products.php
r1414834 r1419216 44 44 <div class="clear"></div> 45 45 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 46 55 <?php do_action( 'hookit_recommended_products_after_products' ) ?> 47 56 </div>
Note: See TracChangeset
for help on using the changeset viewer.