├── .editorconfig ├── .gitignore ├── .jshintrc ├── Gruntfile.js ├── assets ├── css │ ├── editor.css │ └── editor.scss └── js │ ├── editor.js │ └── editor.min.js ├── includes ├── class-wc-shortcodes-admin.php └── wc-shortcodes-editor-i18n.php ├── languages └── woocommerce-shortcodes.pot ├── package.json ├── readme.txt └── woocommerce-shortcodes.php /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 4 8 | tab_width = 4 9 | indent_style = tab 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | 13 | [*.md] 14 | trim_trailing_whitespace = false 15 | 16 | [*.txt] 17 | trim_trailing_whitespace = false 18 | 19 | [*.json] 20 | insert_final_newline = false 21 | indent_size = 2 22 | tab_width = 2 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .sass-cache/ 3 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "boss": true, 3 | "curly": true, 4 | "eqeqeq": true, 5 | "eqnull": true, 6 | "es3": true, 7 | "expr": true, 8 | "immed": true, 9 | "noarg": true, 10 | "onevar": true, 11 | "quotmark": "single", 12 | "trailing": true, 13 | "undef": true, 14 | "unused": true, 15 | 16 | "browser": true, 17 | 18 | "globals": { 19 | "_": false, 20 | "Backbone": false, 21 | "jQuery": false, 22 | "wp": false 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* jshint node:true */ 2 | module.exports = function( grunt ){ 3 | 'use strict'; 4 | 5 | grunt.initConfig({ 6 | 7 | // Setting folder templates 8 | dirs: { 9 | css: 'assets/css', 10 | fonts: 'assets/fonts', 11 | images: 'assets/images', 12 | js: 'assets/js' 13 | }, 14 | 15 | // Javascript linting with jshint 16 | jshint: { 17 | options: { 18 | jshintrc: '.jshintrc' 19 | }, 20 | all: [ 21 | 'Gruntfile.js', 22 | '<%= dirs.js %>/*.js', 23 | '!<%= dirs.js %>/*.min.js' 24 | ] 25 | }, 26 | 27 | // Minify .js files. 28 | uglify: { 29 | options: { 30 | preserveComments: 'some' 31 | }, 32 | dist: { 33 | files: [{ 34 | expand: true, 35 | cwd: '<%= dirs.js %>/', 36 | src: [ 37 | '*.js', 38 | '!*.min.js' 39 | ], 40 | dest: '<%= dirs.js %>/', 41 | ext: '.min.js' 42 | }] 43 | } 44 | }, 45 | 46 | // Compile all .scss files. 47 | sass: { 48 | compile: { 49 | options: { 50 | style: 'compressed' 51 | }, 52 | files: [{ 53 | expand: true, 54 | cwd: '<%= dirs.css %>/', 55 | src: ['*.scss'], 56 | dest: '<%= dirs.css %>/', 57 | ext: '.css' 58 | }] 59 | } 60 | }, 61 | 62 | // Watch changes for assets 63 | watch: { 64 | sass: { 65 | files: ['<%= dirs.css %>/*.scss'], 66 | tasks: ['sass'] 67 | }, 68 | js: { 69 | files: [ 70 | '<%= dirs.js %>/*js', 71 | '!<%= dirs.js %>/*.min.js' 72 | ], 73 | tasks: ['jshint', 'uglify'] 74 | } 75 | } 76 | }); 77 | 78 | // Load NPM tasks to be used here 79 | grunt.loadNpmTasks( 'grunt-contrib-jshint' ); 80 | grunt.loadNpmTasks( 'grunt-contrib-uglify' ); 81 | grunt.loadNpmTasks( 'grunt-contrib-sass' ); 82 | grunt.loadNpmTasks( 'grunt-contrib-watch' ); 83 | 84 | // Register tasks 85 | grunt.registerTask( 'default', [ 86 | 'sass', 87 | 'jshint', 88 | 'uglify' 89 | ]); 90 | }; 91 | -------------------------------------------------------------------------------- /assets/css/editor.css: -------------------------------------------------------------------------------- 1 | i.mce-i-woocommerce-shortcodes{position:relative}i.mce-i-woocommerce-shortcodes:before{font-family:'WooCommerce';speak:none;-webkit-font-smoothing:antialiased;position:absolute;top:0;left:0;width:100%;height:100%;text-align:center;content:"\e03d"} 2 | -------------------------------------------------------------------------------- /assets/css/editor.scss: -------------------------------------------------------------------------------- 1 | i.mce-i-woocommerce-shortcodes { 2 | position: relative; 3 | 4 | &:before { 5 | font-family: 'WooCommerce'; 6 | speak: none; 7 | -webkit-font-smoothing: antialiased; 8 | position: absolute; 9 | top: 0; 10 | left: 0; 11 | width: 100%; 12 | height: 100%; 13 | text-align: center; 14 | content: "\e03d"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /assets/js/editor.js: -------------------------------------------------------------------------------- 1 | /*global tinymce */ 2 | ( function () { 3 | 4 | /** 5 | * Check is empty. 6 | * 7 | * @param {string} value 8 | * @return {bool} 9 | */ 10 | function wcShortcodesIsEmpty( value ) { 11 | value = value.toString(); 12 | 13 | if ( 0 !== value.length ) { 14 | return false; 15 | } 16 | 17 | return true; 18 | } 19 | 20 | /** 21 | * Add the shortcodes downdown. 22 | */ 23 | tinymce.PluginManager.add( 'woocommerce_shortcodes', function ( editor ) { 24 | var ed = tinymce.activeEditor; 25 | editor.addButton( 'woocommerce_shortcodes', { 26 | text: ed.getLang( 'woocommerce_shortcodes.shortcode_title' ), 27 | icon: 'woocommerce-shortcodes', 28 | type: 'menubutton', 29 | menu: [ 30 | { 31 | text: ed.getLang( 'woocommerce_shortcodes.product' ), 32 | menu: [ 33 | { 34 | text: ed.getLang( 'woocommerce_shortcodes.add_to_cart' ), 35 | onclick: function () { 36 | editor.windowManager.open({ 37 | title: ed.getLang( 'woocommerce_shortcodes.product' ) + ' ' + ed.getLang( 'woocommerce_shortcodes.add_to_cart' ), 38 | body: [ 39 | { 40 | type: 'textbox', 41 | name: 'id', 42 | label: ed.getLang( 'woocommerce_shortcodes.id' ) 43 | }, 44 | { 45 | type: 'textbox', 46 | name: 'sku', 47 | label: ed.getLang( 'woocommerce_shortcodes.sku' ) 48 | }, 49 | { 50 | type: 'textbox', 51 | name: 'style', 52 | label: ed.getLang( 'woocommerce_shortcodes.style' ) 53 | }, 54 | { 55 | type: 'checkbox', 56 | name: 'show_price', 57 | label: ed.getLang( 'woocommerce_shortcodes.show_price' ), 58 | checked: true 59 | } 60 | ], 61 | onsubmit: function ( e ) { 62 | var id = wcShortcodesIsEmpty( e.data.id ) ? '' : ' id="' + e.data.id + '"', 63 | sku = wcShortcodesIsEmpty( e.data.sku ) ? '' : ' sku="' + e.data.sku + '"', 64 | style = wcShortcodesIsEmpty( e.data.style ) ? '' : ' style="' + e.data.style + '"', 65 | show_price = e.data.show_price ? '' : ' show_price="' + e.data.show_price + '"'; 66 | 67 | if ( ! wcShortcodesIsEmpty( e.data.id ) || ! wcShortcodesIsEmpty( e.data.sku ) ) { 68 | editor.insertContent( '[add_to_cart' + id + sku + style + show_price + ']' ); 69 | } else { 70 | editor.windowManager.alert( ed.getLang( 'woocommerce_shortcodes.need_id_or_sku' ) ); 71 | } 72 | } 73 | }); 74 | } 75 | }, 76 | { 77 | text: ed.getLang( 'woocommerce_shortcodes.add_to_cart_url' ), 78 | onclick: function () { 79 | editor.windowManager.open({ 80 | title: ed.getLang( 'woocommerce_shortcodes.product' ) + ' ' + ed.getLang( 'woocommerce_shortcodes.add_to_cart_url' ), 81 | body: [ 82 | { 83 | type: 'textbox', 84 | name: 'id', 85 | label: ed.getLang( 'woocommerce_shortcodes.id' ) 86 | }, 87 | { 88 | type: 'textbox', 89 | name: 'sku', 90 | label: ed.getLang( 'woocommerce_shortcodes.sku' ) 91 | } 92 | ], 93 | onsubmit: function ( e ) { 94 | var id = wcShortcodesIsEmpty( e.data.id ) ? '' : ' id="' + e.data.id + '"', 95 | sku = wcShortcodesIsEmpty( e.data.sku ) ? '' : ' sku="' + e.data.sku + '"'; 96 | 97 | if ( ! wcShortcodesIsEmpty( e.data.id ) || ! wcShortcodesIsEmpty( e.data.sku ) ) { 98 | editor.insertContent( '[add_to_cart_url' + id + sku + ']' ); 99 | } else { 100 | editor.windowManager.alert( ed.getLang( 'woocommerce_shortcodes.need_id_or_sku' ) ); 101 | } 102 | } 103 | }); 104 | } 105 | }, 106 | { 107 | text: ed.getLang( 'woocommerce_shortcodes.product_by_sku' ), 108 | onclick: function () { 109 | editor.windowManager.open({ 110 | title: ed.getLang( 'woocommerce_shortcodes.product' ) + ' ' + ed.getLang( 'woocommerce_shortcodes.product_by_sku' ), 111 | body: [ 112 | { 113 | type: 'textbox', 114 | name: 'id', 115 | label: ed.getLang( 'woocommerce_shortcodes.id' ) 116 | }, 117 | { 118 | type: 'textbox', 119 | name: 'sku', 120 | label: ed.getLang( 'woocommerce_shortcodes.sku' ) 121 | } 122 | ], 123 | onsubmit: function ( e ) { 124 | var id = wcShortcodesIsEmpty( e.data.id ) ? '' : ' id="' + e.data.id + '"', 125 | sku = wcShortcodesIsEmpty( e.data.sku ) ? '' : ' sku="' + e.data.sku + '"'; 126 | 127 | if ( ! wcShortcodesIsEmpty( e.data.id ) || ! wcShortcodesIsEmpty( e.data.sku ) ) { 128 | editor.insertContent( '[product' + id + sku + ']' ); 129 | } else { 130 | editor.windowManager.alert( ed.getLang( 'woocommerce_shortcodes.need_id_or_sku' ) ); 131 | } 132 | } 133 | }); 134 | } 135 | } 136 | ] 137 | }, 138 | { 139 | text: ed.getLang( 'woocommerce_shortcodes.list' ), 140 | menu: [ 141 | { 142 | text: ed.getLang( 'woocommerce_shortcodes.products_by_sku' ), 143 | onclick: function () { 144 | editor.windowManager.open({ 145 | title: ed.getLang( 'woocommerce_shortcodes.product_by_sku' ), 146 | body: [ 147 | { 148 | type: 'textbox', 149 | name: 'ids', 150 | label: ed.getLang( 'woocommerce_shortcodes.ids' ), 151 | tooltip: ed.getLang( 'woocommerce_shortcodes.comma_tooltip' ) 152 | }, 153 | { 154 | type: 'textbox', 155 | name: 'skus', 156 | label: ed.getLang( 'woocommerce_shortcodes.skus' ), 157 | tooltip: ed.getLang( 'woocommerce_shortcodes.comma_tooltip' ) 158 | } 159 | ], 160 | onsubmit: function ( e ) { 161 | var ids = wcShortcodesIsEmpty( e.data.ids ) ? '' : ' ids="' + e.data.ids + '"', 162 | skus = wcShortcodesIsEmpty( e.data.skus ) ? '' : ' skus="' + e.data.skus + '"'; 163 | 164 | if ( ! wcShortcodesIsEmpty( e.data.ids ) || ! wcShortcodesIsEmpty( e.data.skus ) ) { 165 | editor.insertContent( '[products' + ids + skus + ']' ); 166 | } else { 167 | editor.windowManager.alert( ed.getLang( 'woocommerce_shortcodes.need_id_or_sku' ) ); 168 | } 169 | } 170 | }); 171 | } 172 | }, 173 | { 174 | text: ed.getLang( 'woocommerce_shortcodes.product_categories' ), 175 | onclick: function () { 176 | editor.windowManager.open({ 177 | title: ed.getLang( 'woocommerce_shortcodes.product_categories' ), 178 | body: [ 179 | { 180 | type: 'textbox', 181 | name: 'number', 182 | label: ed.getLang( 'woocommerce_shortcodes.number' ) 183 | }, 184 | { 185 | type: 'listbox', 186 | name: 'orderby', 187 | label: ed.getLang( 'woocommerce_shortcodes.orderby' ), 188 | values: [ 189 | { 190 | text: ed.getLang( 'woocommerce_shortcodes.name' ), 191 | value: 'name' 192 | }, 193 | { 194 | text: ed.getLang( 'woocommerce_shortcodes.id' ), 195 | value: 'id' 196 | }, 197 | { 198 | text: ed.getLang( 'woocommerce_shortcodes.count' ), 199 | value: 'count' 200 | }, 201 | { 202 | text: ed.getLang( 'woocommerce_shortcodes.slug' ), 203 | value: 'slug' 204 | }, 205 | { 206 | text: ed.getLang( 'woocommerce_shortcodes.none' ), 207 | value: 'none' 208 | } 209 | ] 210 | }, 211 | { 212 | type: 'listbox', 213 | name: 'order', 214 | label: ed.getLang( 'woocommerce_shortcodes.order' ), 215 | values: [ 216 | { 217 | text: ed.getLang( 'woocommerce_shortcodes.asc' ), 218 | value: 'ASC' 219 | }, 220 | { 221 | text: ed.getLang( 'woocommerce_shortcodes.desc' ), 222 | value: 'DESC' 223 | } 224 | ] 225 | }, 226 | { 227 | type: 'textbox', 228 | name: 'columns', 229 | label: ed.getLang( 'woocommerce_shortcodes.columns' ) 230 | }, 231 | { 232 | type: 'checkbox', 233 | name: 'hide_empty', 234 | label: ed.getLang( 'woocommerce_shortcodes.hide_empty' ), 235 | checked: true 236 | }, 237 | { 238 | type: 'textbox', 239 | name: 'parent_id', 240 | label: ed.getLang( 'woocommerce_shortcodes.parent_id' ) 241 | }, 242 | { 243 | type: 'textbox', 244 | name: 'ids', 245 | label: ed.getLang( 'woocommerce_shortcodes.ids' ), 246 | tooltip: ed.getLang( 'woocommerce_shortcodes.comma_tooltip' ) 247 | } 248 | ], 249 | onsubmit: function ( e ) { 250 | var number = wcShortcodesIsEmpty( e.data.number ) ? '' : ' number="' + e.data.number + '"', 251 | columns = wcShortcodesIsEmpty( e.data.columns ) ? '' : ' columns="' + e.data.columns + '"', 252 | hide_empty = e.data.hide_empty ? '' : ' hide_empty="' + e.data.hide_empty + '"', 253 | parent_id = wcShortcodesIsEmpty( e.data.parent_id ) ? '' : ' parent="' + e.data.parent_id + '"', 254 | ids = wcShortcodesIsEmpty( e.data.ids ) ? '' : ' ids="' + e.data.ids + '"'; 255 | 256 | editor.insertContent( '[product_categories' + number + columns + ' orderby="' + e.data.orderby + '" order="' + e.data.order + '"' + hide_empty + parent_id + ids + ']' ); 257 | } 258 | }); 259 | } 260 | }, 261 | { 262 | text: ed.getLang( 'woocommerce_shortcodes.products_by_cat_slug' ), 263 | onclick: function () { 264 | editor.windowManager.open({ 265 | title: ed.getLang( 'woocommerce_shortcodes.products_by_cat_slug' ), 266 | body: [ 267 | { 268 | type: 'textbox', 269 | name: 'category_slug', 270 | label: ed.getLang( 'woocommerce_shortcodes.category_slug' ) 271 | }, 272 | { 273 | type: 'textbox', 274 | name: 'per_page', 275 | label: ed.getLang( 'woocommerce_shortcodes.categories_per_page' ), 276 | value: '12' 277 | }, 278 | { 279 | type: 'textbox', 280 | name: 'columns', 281 | label: ed.getLang( 'woocommerce_shortcodes.columns' ), 282 | value: '4' 283 | }, 284 | { 285 | type: 'listbox', 286 | name: 'orderby', 287 | label: ed.getLang( 'woocommerce_shortcodes.orderby' ), 288 | values: [ 289 | { 290 | text: ed.getLang( 'woocommerce_shortcodes.default' ), 291 | value: 'default' 292 | }, 293 | { 294 | text: ed.getLang( 'woocommerce_shortcodes.rand' ), 295 | value: 'rand' 296 | }, 297 | { 298 | text: ed.getLang( 'woocommerce_shortcodes.date' ), 299 | value: 'date' 300 | }, 301 | { 302 | text: ed.getLang( 'woocommerce_shortcodes.price' ), 303 | value: 'price' 304 | }, 305 | { 306 | text: ed.getLang( 'woocommerce_shortcodes.popularity' ), 307 | value: 'popularity' 308 | }, 309 | { 310 | text: ed.getLang( 'woocommerce_shortcodes.rating' ), 311 | value: 'rating' 312 | }, 313 | { 314 | text: ed.getLang( 'woocommerce_shortcodes.title' ), 315 | value: 'title' 316 | } 317 | ] 318 | }, 319 | { 320 | type: 'listbox', 321 | name: 'order', 322 | label: ed.getLang( 'woocommerce_shortcodes.order' ), 323 | values: [ 324 | { 325 | text: ed.getLang( 'woocommerce_shortcodes.asc' ), 326 | value: 'ASC' 327 | }, 328 | { 329 | text: ed.getLang( 'woocommerce_shortcodes.desc' ), 330 | value: 'DESC' 331 | } 332 | ] 333 | }, 334 | { 335 | type: 'listbox', 336 | name: 'operator', 337 | label: ed.getLang( 'woocommerce_shortcodes.operator' ), 338 | values: [ 339 | { 340 | text: ed.getLang( 'woocommerce_shortcodes.in' ), 341 | value: 'IN' 342 | }, 343 | { 344 | text: ed.getLang( 'woocommerce_shortcodes.not_in' ), 345 | value: 'NOT IN' 346 | }, 347 | { 348 | text: ed.getLang( 'woocommerce_shortcodes.and' ), 349 | value: 'AND' 350 | } 351 | ] 352 | } 353 | ], 354 | onsubmit: function ( e ) { 355 | var category = wcShortcodesIsEmpty( e.data.category_slug ) ? '' : ' category="' + e.data.category_slug + '"'; 356 | 357 | if ( ! wcShortcodesIsEmpty( e.data.category_slug ) ) { 358 | editor.insertContent( '[product_category' + category + ' per_page="' + e.data.per_page + '" columns="' + e.data.columns + '" orderby="' + e.data.orderby + '" order="' + e.data.order + '" operator="' + e.data.operator + '"]' ); 359 | } else { 360 | editor.windowManager.alert( ed.getLang( 'woocommerce_shortcodes.need_category_slug' ) ); 361 | } 362 | } 363 | }); 364 | } 365 | }, 366 | { 367 | text: ed.getLang( 'woocommerce_shortcodes.products_by_attribute' ), 368 | onclick: function () { 369 | editor.windowManager.open({ 370 | title: ed.getLang( 'woocommerce_shortcodes.products_by_attribute' ), 371 | body: [ 372 | { 373 | type: 'textbox', 374 | name: 'attribute_slug', 375 | label: ed.getLang( 'woocommerce_shortcodes.attribute_slug' ) 376 | }, 377 | { 378 | type: 'textbox', 379 | name: 'terms_slug', 380 | label: ed.getLang( 'woocommerce_shortcodes.terms_slug' ), 381 | tooltip: ed.getLang( 'woocommerce_shortcodes.comma_tooltip' ) 382 | }, 383 | { 384 | type: 'textbox', 385 | name: 'per_page', 386 | label: ed.getLang( 'woocommerce_shortcodes.products_per_page' ), 387 | value: '12' 388 | }, 389 | { 390 | type: 'textbox', 391 | name: 'columns', 392 | label: ed.getLang( 'woocommerce_shortcodes.columns' ), 393 | value: '4' 394 | }, 395 | { 396 | type: 'listbox', 397 | name: 'orderby', 398 | label: ed.getLang( 'woocommerce_shortcodes.orderby' ), 399 | values: [ 400 | { 401 | text: ed.getLang( 'woocommerce_shortcodes.date' ), 402 | value: 'date' 403 | }, 404 | { 405 | text: ed.getLang( 'woocommerce_shortcodes.rand' ), 406 | value: 'rand' 407 | }, 408 | { 409 | text: ed.getLang( 'woocommerce_shortcodes.title' ), 410 | value: 'title' 411 | }, 412 | { 413 | text: ed.getLang( 'woocommerce_shortcodes.none' ), 414 | value: 'none' 415 | } 416 | ] 417 | }, 418 | { 419 | type: 'listbox', 420 | name: 'order', 421 | label: ed.getLang( 'woocommerce_shortcodes.order' ), 422 | values: [ 423 | { 424 | text: ed.getLang( 'woocommerce_shortcodes.asc' ), 425 | value: 'ASC' 426 | }, 427 | { 428 | text: ed.getLang( 'woocommerce_shortcodes.desc' ), 429 | value: 'DESC' 430 | } 431 | ] 432 | } 433 | ], 434 | onsubmit: function ( e ) { 435 | if ( ! wcShortcodesIsEmpty( e.data.attribute_slug ) && ! wcShortcodesIsEmpty( e.data.terms_slug ) ) { 436 | editor.insertContent( '[product_attribute attribute="' + e.data.attribute_slug + '" filter="' + e.data.terms_slug + '" per_page="' + e.data.per_page + '" columns="' + e.data.columns + '" orderby="' + e.data.orderby + '" order="' + e.data.order + '"]' ); 437 | } else { 438 | editor.windowManager.alert( ed.getLang( 'woocommerce_shortcodes.need_attribute_and_terms_slugs' ) ); 439 | } 440 | } 441 | }); 442 | } 443 | }, 444 | { 445 | text: ed.getLang( 'woocommerce_shortcodes.recent_products' ), 446 | onclick: function () { 447 | editor.windowManager.open({ 448 | title: ed.getLang( 'woocommerce_shortcodes.recent_products' ), 449 | body: [ 450 | { 451 | type: 'textbox', 452 | name: 'per_page', 453 | label: ed.getLang( 'woocommerce_shortcodes.products_per_page' ), 454 | value: '12' 455 | }, 456 | { 457 | type: 'textbox', 458 | name: 'columns', 459 | label: ed.getLang( 'woocommerce_shortcodes.columns' ), 460 | value: '4' 461 | }, 462 | { 463 | type: 'listbox', 464 | name: 'orderby', 465 | label: ed.getLang( 'woocommerce_shortcodes.orderby' ), 466 | values: [ 467 | { 468 | text: ed.getLang( 'woocommerce_shortcodes.date' ), 469 | value: 'date' 470 | }, 471 | { 472 | text: ed.getLang( 'woocommerce_shortcodes.rand' ), 473 | value: 'rand' 474 | }, 475 | { 476 | text: ed.getLang( 'woocommerce_shortcodes.title' ), 477 | value: 'title' 478 | }, 479 | { 480 | text: ed.getLang( 'woocommerce_shortcodes.none' ), 481 | value: 'none' 482 | } 483 | ] 484 | }, 485 | { 486 | type: 'listbox', 487 | name: 'order', 488 | label: ed.getLang( 'woocommerce_shortcodes.order' ), 489 | values: [ 490 | { 491 | text: ed.getLang( 'woocommerce_shortcodes.asc' ), 492 | value: 'ASC' 493 | }, 494 | { 495 | text: ed.getLang( 'woocommerce_shortcodes.desc' ), 496 | value: 'DESC' 497 | } 498 | ] 499 | } 500 | ], 501 | onsubmit: function ( e ) { 502 | editor.insertContent( '[recent_products per_page="' + e.data.per_page + '" columns="' + e.data.columns + '" orderby="' + e.data.orderby + '" order="' + e.data.order + '"]' ); 503 | } 504 | }); 505 | } 506 | }, 507 | { 508 | text: ed.getLang( 'woocommerce_shortcodes.featured_products' ), 509 | onclick: function () { 510 | editor.windowManager.open({ 511 | title: ed.getLang( 'woocommerce_shortcodes.featured_products' ), 512 | body: [ 513 | { 514 | type: 'textbox', 515 | name: 'per_page', 516 | label: ed.getLang( 'woocommerce_shortcodes.products_per_page' ), 517 | value: '12' 518 | }, 519 | { 520 | type: 'textbox', 521 | name: 'columns', 522 | label: ed.getLang( 'woocommerce_shortcodes.columns' ), 523 | value: '4' 524 | }, 525 | { 526 | type: 'listbox', 527 | name: 'orderby', 528 | label: ed.getLang( 'woocommerce_shortcodes.orderby' ), 529 | values: [ 530 | { 531 | text: ed.getLang( 'woocommerce_shortcodes.date' ), 532 | value: 'date' 533 | }, 534 | { 535 | text: ed.getLang( 'woocommerce_shortcodes.rand' ), 536 | value: 'rand' 537 | }, 538 | { 539 | text: ed.getLang( 'woocommerce_shortcodes.title' ), 540 | value: 'title' 541 | }, 542 | { 543 | text: ed.getLang( 'woocommerce_shortcodes.none' ), 544 | value: 'none' 545 | } 546 | ] 547 | }, 548 | { 549 | type: 'listbox', 550 | name: 'order', 551 | label: ed.getLang( 'woocommerce_shortcodes.order' ), 552 | values: [ 553 | { 554 | text: ed.getLang( 'woocommerce_shortcodes.asc' ), 555 | value: 'ASC' 556 | }, 557 | { 558 | text: ed.getLang( 'woocommerce_shortcodes.desc' ), 559 | value: 'DESC' 560 | } 561 | ] 562 | } 563 | ], 564 | onsubmit: function ( e ) { 565 | editor.insertContent( '[featured_products per_page="' + e.data.per_page + '" columns="' + e.data.columns + '" orderby="' + e.data.orderby + '" order="' + e.data.order + '"]' ); 566 | } 567 | }); 568 | } 569 | }, 570 | { 571 | text: ed.getLang( 'woocommerce_shortcodes.sale_products' ), 572 | onclick: function () { 573 | editor.windowManager.open({ 574 | title: ed.getLang( 'woocommerce_shortcodes.sale_products' ), 575 | body: [ 576 | { 577 | type: 'textbox', 578 | name: 'per_page', 579 | label: ed.getLang( 'woocommerce_shortcodes.products_per_page' ), 580 | value: '12' 581 | }, 582 | { 583 | type: 'textbox', 584 | name: 'columns', 585 | label: ed.getLang( 'woocommerce_shortcodes.columns' ), 586 | value: '4' 587 | }, 588 | { 589 | type: 'listbox', 590 | name: 'orderby', 591 | label: ed.getLang( 'woocommerce_shortcodes.orderby' ), 592 | values: [ 593 | { 594 | text: ed.getLang( 'woocommerce_shortcodes.date' ), 595 | value: 'date' 596 | }, 597 | { 598 | text: ed.getLang( 'woocommerce_shortcodes.rand' ), 599 | value: 'rand' 600 | }, 601 | { 602 | text: ed.getLang( 'woocommerce_shortcodes.title' ), 603 | value: 'title' 604 | }, 605 | { 606 | text: ed.getLang( 'woocommerce_shortcodes.none' ), 607 | value: 'none' 608 | } 609 | ] 610 | }, 611 | { 612 | type: 'listbox', 613 | name: 'order', 614 | label: ed.getLang( 'woocommerce_shortcodes.order' ), 615 | values: [ 616 | { 617 | text: ed.getLang( 'woocommerce_shortcodes.asc' ), 618 | value: 'ASC' 619 | }, 620 | { 621 | text: ed.getLang( 'woocommerce_shortcodes.desc' ), 622 | value: 'DESC' 623 | } 624 | ] 625 | } 626 | ], 627 | onsubmit: function ( e ) { 628 | editor.insertContent( '[sale_products per_page="' + e.data.per_page + '" columns="' + e.data.columns + '" orderby="' + e.data.orderby + '" order="' + e.data.order + '"]' ); 629 | } 630 | }); 631 | } 632 | }, 633 | { 634 | text: ed.getLang( 'woocommerce_shortcodes.best_selling_products' ), 635 | onclick: function () { 636 | editor.windowManager.open({ 637 | title: ed.getLang( 'woocommerce_shortcodes.best_selling_products' ), 638 | body: [ 639 | { 640 | type: 'textbox', 641 | name: 'per_page', 642 | label: ed.getLang( 'woocommerce_shortcodes.products_per_page' ), 643 | value: '12' 644 | }, 645 | { 646 | type: 'textbox', 647 | name: 'columns', 648 | label: ed.getLang( 'woocommerce_shortcodes.columns' ), 649 | value: '4' 650 | }, 651 | { 652 | type: 'listbox', 653 | name: 'orderby', 654 | label: ed.getLang( 'woocommerce_shortcodes.orderby' ), 655 | values: [ 656 | { 657 | text: ed.getLang( 'woocommerce_shortcodes.date' ), 658 | value: 'date' 659 | }, 660 | { 661 | text: ed.getLang( 'woocommerce_shortcodes.rand' ), 662 | value: 'rand' 663 | }, 664 | { 665 | text: ed.getLang( 'woocommerce_shortcodes.title' ), 666 | value: 'title' 667 | }, 668 | { 669 | text: ed.getLang( 'woocommerce_shortcodes.none' ), 670 | value: 'none' 671 | } 672 | ] 673 | }, 674 | { 675 | type: 'listbox', 676 | name: 'order', 677 | label: ed.getLang( 'woocommerce_shortcodes.order' ), 678 | values: [ 679 | { 680 | text: ed.getLang( 'woocommerce_shortcodes.asc' ), 681 | value: 'ASC' 682 | }, 683 | { 684 | text: ed.getLang( 'woocommerce_shortcodes.desc' ), 685 | value: 'DESC' 686 | } 687 | ] 688 | } 689 | ], 690 | onsubmit: function ( e ) { 691 | editor.insertContent( '[best_selling_products per_page="' + e.data.per_page + '" columns="' + e.data.columns + '" orderby="' + e.data.orderby + '" order="' + e.data.order + '"]' ); 692 | } 693 | }); 694 | } 695 | }, 696 | { 697 | text: ed.getLang( 'woocommerce_shortcodes.top_rated_products' ), 698 | onclick: function () { 699 | editor.windowManager.open({ 700 | title: ed.getLang( 'woocommerce_shortcodes.top_rated_products' ), 701 | body: [ 702 | { 703 | type: 'textbox', 704 | name: 'per_page', 705 | label: ed.getLang( 'woocommerce_shortcodes.products_per_page' ), 706 | value: '12' 707 | }, 708 | { 709 | type: 'textbox', 710 | name: 'columns', 711 | label: ed.getLang( 'woocommerce_shortcodes.columns' ), 712 | value: '4' 713 | }, 714 | { 715 | type: 'listbox', 716 | name: 'orderby', 717 | label: ed.getLang( 'woocommerce_shortcodes.orderby' ), 718 | values: [ 719 | { 720 | text: ed.getLang( 'woocommerce_shortcodes.date' ), 721 | value: 'date' 722 | }, 723 | { 724 | text: ed.getLang( 'woocommerce_shortcodes.rand' ), 725 | value: 'rand' 726 | }, 727 | { 728 | text: ed.getLang( 'woocommerce_shortcodes.title' ), 729 | value: 'title' 730 | }, 731 | { 732 | text: ed.getLang( 'woocommerce_shortcodes.none' ), 733 | value: 'none' 734 | } 735 | ] 736 | }, 737 | { 738 | type: 'listbox', 739 | name: 'order', 740 | label: ed.getLang( 'woocommerce_shortcodes.order' ), 741 | values: [ 742 | { 743 | text: ed.getLang( 'woocommerce_shortcodes.asc' ), 744 | value: 'ASC' 745 | }, 746 | { 747 | text: ed.getLang( 'woocommerce_shortcodes.desc' ), 748 | value: 'DESC' 749 | } 750 | ] 751 | } 752 | ], 753 | onsubmit: function ( e ) { 754 | editor.insertContent( '[top_rated_products per_page="' + e.data.per_page + '" columns="' + e.data.columns + '" orderby="' + e.data.orderby + '" order="' + e.data.order + '"]' ); 755 | } 756 | }); 757 | } 758 | } 759 | ] 760 | }, 761 | { 762 | text: ed.getLang( 'woocommerce_shortcodes.shop_messages' ), 763 | onclick: function () { 764 | editor.insertContent( '[' + ed.getLang( 'woocommerce_shortcodes.shop_messages_shortcode' ) + ']' ); 765 | } 766 | }, 767 | { 768 | text: ed.getLang( 'woocommerce_shortcodes.order_tracking' ), 769 | onclick: function () { 770 | editor.insertContent( '[' + ed.getLang( 'woocommerce_shortcodes.order_tracking_shortcode' ) + ']' ); 771 | } 772 | } 773 | ] 774 | }); 775 | }); 776 | })(); 777 | -------------------------------------------------------------------------------- /assets/js/editor.min.js: -------------------------------------------------------------------------------- 1 | !function(){function a(a){return a=a.toString(),0!==a.length?!1:!0}tinymce.PluginManager.add("woocommerce_shortcodes",function(b){var c=tinymce.activeEditor;b.addButton("woocommerce_shortcodes",{text:c.getLang("woocommerce_shortcodes.shortcode_title"),icon:"woocommerce-shortcodes",type:"menubutton",menu:[{text:c.getLang("woocommerce_shortcodes.product"),menu:[{text:c.getLang("woocommerce_shortcodes.add_to_cart"),onclick:function(){b.windowManager.open({title:c.getLang("woocommerce_shortcodes.product")+" "+c.getLang("woocommerce_shortcodes.add_to_cart"),body:[{type:"textbox",name:"id",label:c.getLang("woocommerce_shortcodes.id")},{type:"textbox",name:"sku",label:c.getLang("woocommerce_shortcodes.sku")},{type:"textbox",name:"style",label:c.getLang("woocommerce_shortcodes.style")},{type:"checkbox",name:"show_price",label:c.getLang("woocommerce_shortcodes.show_price"),checked:!0}],onsubmit:function(d){var e=a(d.data.id)?"":' id="'+d.data.id+'"',f=a(d.data.sku)?"":' sku="'+d.data.sku+'"',g=a(d.data.style)?"":' style="'+d.data.style+'"',h=d.data.show_price?"":' show_price="'+d.data.show_price+'"';a(d.data.id)&&a(d.data.sku)?b.windowManager.alert(c.getLang("woocommerce_shortcodes.need_id_or_sku")):b.insertContent("[add_to_cart"+e+f+g+h+"]")}})}},{text:c.getLang("woocommerce_shortcodes.add_to_cart_url"),onclick:function(){b.windowManager.open({title:c.getLang("woocommerce_shortcodes.product")+" "+c.getLang("woocommerce_shortcodes.add_to_cart_url"),body:[{type:"textbox",name:"id",label:c.getLang("woocommerce_shortcodes.id")},{type:"textbox",name:"sku",label:c.getLang("woocommerce_shortcodes.sku")}],onsubmit:function(d){var e=a(d.data.id)?"":' id="'+d.data.id+'"',f=a(d.data.sku)?"":' sku="'+d.data.sku+'"';a(d.data.id)&&a(d.data.sku)?b.windowManager.alert(c.getLang("woocommerce_shortcodes.need_id_or_sku")):b.insertContent("[add_to_cart_url"+e+f+"]")}})}},{text:c.getLang("woocommerce_shortcodes.product_by_sku"),onclick:function(){b.windowManager.open({title:c.getLang("woocommerce_shortcodes.product")+" "+c.getLang("woocommerce_shortcodes.product_by_sku"),body:[{type:"textbox",name:"id",label:c.getLang("woocommerce_shortcodes.id")},{type:"textbox",name:"sku",label:c.getLang("woocommerce_shortcodes.sku")}],onsubmit:function(d){var e=a(d.data.id)?"":' id="'+d.data.id+'"',f=a(d.data.sku)?"":' sku="'+d.data.sku+'"';a(d.data.id)&&a(d.data.sku)?b.windowManager.alert(c.getLang("woocommerce_shortcodes.need_id_or_sku")):b.insertContent("[product"+e+f+"]")}})}}]},{text:c.getLang("woocommerce_shortcodes.list"),menu:[{text:c.getLang("woocommerce_shortcodes.products_by_sku"),onclick:function(){b.windowManager.open({title:c.getLang("woocommerce_shortcodes.product_by_sku"),body:[{type:"textbox",name:"ids",label:c.getLang("woocommerce_shortcodes.ids"),tooltip:c.getLang("woocommerce_shortcodes.comma_tooltip")},{type:"textbox",name:"skus",label:c.getLang("woocommerce_shortcodes.skus"),tooltip:c.getLang("woocommerce_shortcodes.comma_tooltip")}],onsubmit:function(d){var e=a(d.data.ids)?"":' ids="'+d.data.ids+'"',f=a(d.data.skus)?"":' skus="'+d.data.skus+'"';a(d.data.ids)&&a(d.data.skus)?b.windowManager.alert(c.getLang("woocommerce_shortcodes.need_id_or_sku")):b.insertContent("[products"+e+f+"]")}})}},{text:c.getLang("woocommerce_shortcodes.product_categories"),onclick:function(){b.windowManager.open({title:c.getLang("woocommerce_shortcodes.product_categories"),body:[{type:"textbox",name:"number",label:c.getLang("woocommerce_shortcodes.number")},{type:"listbox",name:"orderby",label:c.getLang("woocommerce_shortcodes.orderby"),values:[{text:c.getLang("woocommerce_shortcodes.name"),value:"name"},{text:c.getLang("woocommerce_shortcodes.id"),value:"id"},{text:c.getLang("woocommerce_shortcodes.count"),value:"count"},{text:c.getLang("woocommerce_shortcodes.slug"),value:"slug"},{text:c.getLang("woocommerce_shortcodes.none"),value:"none"}]},{type:"listbox",name:"order",label:c.getLang("woocommerce_shortcodes.order"),values:[{text:c.getLang("woocommerce_shortcodes.asc"),value:"ASC"},{text:c.getLang("woocommerce_shortcodes.desc"),value:"DESC"}]},{type:"textbox",name:"columns",label:c.getLang("woocommerce_shortcodes.columns")},{type:"checkbox",name:"hide_empty",label:c.getLang("woocommerce_shortcodes.hide_empty"),checked:!0},{type:"textbox",name:"parent_id",label:c.getLang("woocommerce_shortcodes.parent_id")},{type:"textbox",name:"ids",label:c.getLang("woocommerce_shortcodes.ids"),tooltip:c.getLang("woocommerce_shortcodes.comma_tooltip")}],onsubmit:function(c){var d=a(c.data.number)?"":' number="'+c.data.number+'"',e=a(c.data.columns)?"":' columns="'+c.data.columns+'"',f=c.data.hide_empty?"":' hide_empty="'+c.data.hide_empty+'"',g=a(c.data.parent_id)?"":' parent="'+c.data.parent_id+'"',h=a(c.data.ids)?"":' ids="'+c.data.ids+'"';b.insertContent("[product_categories"+d+e+' orderby="'+c.data.orderby+'" order="'+c.data.order+'"'+f+g+h+"]")}})}},{text:c.getLang("woocommerce_shortcodes.products_by_cat_slug"),onclick:function(){b.windowManager.open({title:c.getLang("woocommerce_shortcodes.products_by_cat_slug"),body:[{type:"textbox",name:"category_slug",label:c.getLang("woocommerce_shortcodes.category_slug")},{type:"textbox",name:"per_page",label:c.getLang("woocommerce_shortcodes.categories_per_page"),value:"12"},{type:"textbox",name:"columns",label:c.getLang("woocommerce_shortcodes.columns"),value:"4"},{type:"listbox",name:"orderby",label:c.getLang("woocommerce_shortcodes.orderby"),values:[{text:c.getLang("woocommerce_shortcodes.default"),value:"default"},{text:c.getLang("woocommerce_shortcodes.rand"),value:"rand"},{text:c.getLang("woocommerce_shortcodes.date"),value:"date"},{text:c.getLang("woocommerce_shortcodes.price"),value:"price"},{text:c.getLang("woocommerce_shortcodes.popularity"),value:"popularity"},{text:c.getLang("woocommerce_shortcodes.rating"),value:"rating"},{text:c.getLang("woocommerce_shortcodes.title"),value:"title"}]},{type:"listbox",name:"order",label:c.getLang("woocommerce_shortcodes.order"),values:[{text:c.getLang("woocommerce_shortcodes.asc"),value:"ASC"},{text:c.getLang("woocommerce_shortcodes.desc"),value:"DESC"}]},{type:"listbox",name:"operator",label:c.getLang("woocommerce_shortcodes.operator"),values:[{text:c.getLang("woocommerce_shortcodes.in"),value:"IN"},{text:c.getLang("woocommerce_shortcodes.not_in"),value:"NOT IN"},{text:c.getLang("woocommerce_shortcodes.and"),value:"AND"}]}],onsubmit:function(d){var e=a(d.data.category_slug)?"":' category="'+d.data.category_slug+'"';a(d.data.category_slug)?b.windowManager.alert(c.getLang("woocommerce_shortcodes.need_category_slug")):b.insertContent("[product_category"+e+' per_page="'+d.data.per_page+'" columns="'+d.data.columns+'" orderby="'+d.data.orderby+'" order="'+d.data.order+'" operator="'+d.data.operator+'"]')}})}},{text:c.getLang("woocommerce_shortcodes.products_by_attribute"),onclick:function(){b.windowManager.open({title:c.getLang("woocommerce_shortcodes.products_by_attribute"),body:[{type:"textbox",name:"attribute_slug",label:c.getLang("woocommerce_shortcodes.attribute_slug")},{type:"textbox",name:"terms_slug",label:c.getLang("woocommerce_shortcodes.terms_slug"),tooltip:c.getLang("woocommerce_shortcodes.comma_tooltip")},{type:"textbox",name:"per_page",label:c.getLang("woocommerce_shortcodes.products_per_page"),value:"12"},{type:"textbox",name:"columns",label:c.getLang("woocommerce_shortcodes.columns"),value:"4"},{type:"listbox",name:"orderby",label:c.getLang("woocommerce_shortcodes.orderby"),values:[{text:c.getLang("woocommerce_shortcodes.date"),value:"date"},{text:c.getLang("woocommerce_shortcodes.rand"),value:"rand"},{text:c.getLang("woocommerce_shortcodes.title"),value:"title"},{text:c.getLang("woocommerce_shortcodes.none"),value:"none"}]},{type:"listbox",name:"order",label:c.getLang("woocommerce_shortcodes.order"),values:[{text:c.getLang("woocommerce_shortcodes.asc"),value:"ASC"},{text:c.getLang("woocommerce_shortcodes.desc"),value:"DESC"}]}],onsubmit:function(d){a(d.data.attribute_slug)||a(d.data.terms_slug)?b.windowManager.alert(c.getLang("woocommerce_shortcodes.need_attribute_and_terms_slugs")):b.insertContent('[product_attribute attribute="'+d.data.attribute_slug+'" filter="'+d.data.terms_slug+'" per_page="'+d.data.per_page+'" columns="'+d.data.columns+'" orderby="'+d.data.orderby+'" order="'+d.data.order+'"]')}})}},{text:c.getLang("woocommerce_shortcodes.recent_products"),onclick:function(){b.windowManager.open({title:c.getLang("woocommerce_shortcodes.recent_products"),body:[{type:"textbox",name:"per_page",label:c.getLang("woocommerce_shortcodes.products_per_page"),value:"12"},{type:"textbox",name:"columns",label:c.getLang("woocommerce_shortcodes.columns"),value:"4"},{type:"listbox",name:"orderby",label:c.getLang("woocommerce_shortcodes.orderby"),values:[{text:c.getLang("woocommerce_shortcodes.date"),value:"date"},{text:c.getLang("woocommerce_shortcodes.rand"),value:"rand"},{text:c.getLang("woocommerce_shortcodes.title"),value:"title"},{text:c.getLang("woocommerce_shortcodes.none"),value:"none"}]},{type:"listbox",name:"order",label:c.getLang("woocommerce_shortcodes.order"),values:[{text:c.getLang("woocommerce_shortcodes.asc"),value:"ASC"},{text:c.getLang("woocommerce_shortcodes.desc"),value:"DESC"}]}],onsubmit:function(a){b.insertContent('[recent_products per_page="'+a.data.per_page+'" columns="'+a.data.columns+'" orderby="'+a.data.orderby+'" order="'+a.data.order+'"]')}})}},{text:c.getLang("woocommerce_shortcodes.featured_products"),onclick:function(){b.windowManager.open({title:c.getLang("woocommerce_shortcodes.featured_products"),body:[{type:"textbox",name:"per_page",label:c.getLang("woocommerce_shortcodes.products_per_page"),value:"12"},{type:"textbox",name:"columns",label:c.getLang("woocommerce_shortcodes.columns"),value:"4"},{type:"listbox",name:"orderby",label:c.getLang("woocommerce_shortcodes.orderby"),values:[{text:c.getLang("woocommerce_shortcodes.date"),value:"date"},{text:c.getLang("woocommerce_shortcodes.rand"),value:"rand"},{text:c.getLang("woocommerce_shortcodes.title"),value:"title"},{text:c.getLang("woocommerce_shortcodes.none"),value:"none"}]},{type:"listbox",name:"order",label:c.getLang("woocommerce_shortcodes.order"),values:[{text:c.getLang("woocommerce_shortcodes.asc"),value:"ASC"},{text:c.getLang("woocommerce_shortcodes.desc"),value:"DESC"}]}],onsubmit:function(a){b.insertContent('[featured_products per_page="'+a.data.per_page+'" columns="'+a.data.columns+'" orderby="'+a.data.orderby+'" order="'+a.data.order+'"]')}})}},{text:c.getLang("woocommerce_shortcodes.sale_products"),onclick:function(){b.windowManager.open({title:c.getLang("woocommerce_shortcodes.sale_products"),body:[{type:"textbox",name:"per_page",label:c.getLang("woocommerce_shortcodes.products_per_page"),value:"12"},{type:"textbox",name:"columns",label:c.getLang("woocommerce_shortcodes.columns"),value:"4"},{type:"listbox",name:"orderby",label:c.getLang("woocommerce_shortcodes.orderby"),values:[{text:c.getLang("woocommerce_shortcodes.date"),value:"date"},{text:c.getLang("woocommerce_shortcodes.rand"),value:"rand"},{text:c.getLang("woocommerce_shortcodes.title"),value:"title"},{text:c.getLang("woocommerce_shortcodes.none"),value:"none"}]},{type:"listbox",name:"order",label:c.getLang("woocommerce_shortcodes.order"),values:[{text:c.getLang("woocommerce_shortcodes.asc"),value:"ASC"},{text:c.getLang("woocommerce_shortcodes.desc"),value:"DESC"}]}],onsubmit:function(a){b.insertContent('[sale_products per_page="'+a.data.per_page+'" columns="'+a.data.columns+'" orderby="'+a.data.orderby+'" order="'+a.data.order+'"]')}})}},{text:c.getLang("woocommerce_shortcodes.best_selling_products"),onclick:function(){b.windowManager.open({title:c.getLang("woocommerce_shortcodes.best_selling_products"),body:[{type:"textbox",name:"per_page",label:c.getLang("woocommerce_shortcodes.products_per_page"),value:"12"},{type:"textbox",name:"columns",label:c.getLang("woocommerce_shortcodes.columns"),value:"4"},{type:"listbox",name:"orderby",label:c.getLang("woocommerce_shortcodes.orderby"),values:[{text:c.getLang("woocommerce_shortcodes.date"),value:"date"},{text:c.getLang("woocommerce_shortcodes.rand"),value:"rand"},{text:c.getLang("woocommerce_shortcodes.title"),value:"title"},{text:c.getLang("woocommerce_shortcodes.none"),value:"none"}]},{type:"listbox",name:"order",label:c.getLang("woocommerce_shortcodes.order"),values:[{text:c.getLang("woocommerce_shortcodes.asc"),value:"ASC"},{text:c.getLang("woocommerce_shortcodes.desc"),value:"DESC"}]}],onsubmit:function(a){b.insertContent('[best_selling_products per_page="'+a.data.per_page+'" columns="'+a.data.columns+'" orderby="'+a.data.orderby+'" order="'+a.data.order+'"]')}})}},{text:c.getLang("woocommerce_shortcodes.top_rated_products"),onclick:function(){b.windowManager.open({title:c.getLang("woocommerce_shortcodes.top_rated_products"),body:[{type:"textbox",name:"per_page",label:c.getLang("woocommerce_shortcodes.products_per_page"),value:"12"},{type:"textbox",name:"columns",label:c.getLang("woocommerce_shortcodes.columns"),value:"4"},{type:"listbox",name:"orderby",label:c.getLang("woocommerce_shortcodes.orderby"),values:[{text:c.getLang("woocommerce_shortcodes.date"),value:"date"},{text:c.getLang("woocommerce_shortcodes.rand"),value:"rand"},{text:c.getLang("woocommerce_shortcodes.title"),value:"title"},{text:c.getLang("woocommerce_shortcodes.none"),value:"none"}]},{type:"listbox",name:"order",label:c.getLang("woocommerce_shortcodes.order"),values:[{text:c.getLang("woocommerce_shortcodes.asc"),value:"ASC"},{text:c.getLang("woocommerce_shortcodes.desc"),value:"DESC"}]}],onsubmit:function(a){b.insertContent('[top_rated_products per_page="'+a.data.per_page+'" columns="'+a.data.columns+'" orderby="'+a.data.orderby+'" order="'+a.data.order+'"]')}})}}]},{text:c.getLang("woocommerce_shortcodes.shop_messages"),onclick:function(){b.insertContent("["+c.getLang("woocommerce_shortcodes.shop_messages_shortcode")+"]")}},{text:c.getLang("woocommerce_shortcodes.order_tracking"),onclick:function(){b.insertContent("["+c.getLang("woocommerce_shortcodes.order_tracking_shortcode")+"]")}}]})})}(); -------------------------------------------------------------------------------- /includes/class-wc-shortcodes-admin.php: -------------------------------------------------------------------------------- 1 | \n" 14 | "Language-Team: LANGUAGE \n" 15 | 16 | #: includes/wc-shortcodes-editor-i18n.php:8 woocommerce-shortcodes.php:99 17 | msgid "WooCommerce" 18 | msgstr "" 19 | 20 | #: includes/wc-shortcodes-editor-i18n.php:9 21 | msgid "Product" 22 | msgstr "" 23 | 24 | #: includes/wc-shortcodes-editor-i18n.php:10 25 | msgid "List" 26 | msgstr "" 27 | 28 | #: includes/wc-shortcodes-editor-i18n.php:11 29 | msgid "Price/cart button" 30 | msgstr "" 31 | 32 | #: includes/wc-shortcodes-editor-i18n.php:12 33 | msgid "Add to cart URL" 34 | msgstr "" 35 | 36 | #: includes/wc-shortcodes-editor-i18n.php:13 37 | msgid "By SKU/ID" 38 | msgstr "" 39 | 40 | #: includes/wc-shortcodes-editor-i18n.php:14 41 | msgid "Products by SKU/ID" 42 | msgstr "" 43 | 44 | #: includes/wc-shortcodes-editor-i18n.php:15 45 | msgid "Product categories" 46 | msgstr "" 47 | 48 | #: includes/wc-shortcodes-editor-i18n.php:16 49 | msgid "Products by category slug" 50 | msgstr "" 51 | 52 | #: includes/wc-shortcodes-editor-i18n.php:17 53 | msgid "Products by attributes" 54 | msgstr "" 55 | 56 | #: includes/wc-shortcodes-editor-i18n.php:18 57 | msgid "Recent products" 58 | msgstr "" 59 | 60 | #: includes/wc-shortcodes-editor-i18n.php:19 61 | msgid "Featured products" 62 | msgstr "" 63 | 64 | #: includes/wc-shortcodes-editor-i18n.php:20 65 | msgid "Sale products" 66 | msgstr "" 67 | 68 | #: includes/wc-shortcodes-editor-i18n.php:21 69 | msgid "Best selling products" 70 | msgstr "" 71 | 72 | #: includes/wc-shortcodes-editor-i18n.php:22 73 | msgid "Top rated products" 74 | msgstr "" 75 | 76 | #: includes/wc-shortcodes-editor-i18n.php:23 77 | msgid "Shop Messages" 78 | msgstr "" 79 | 80 | #: includes/wc-shortcodes-editor-i18n.php:24 81 | msgid "Order tracking" 82 | msgstr "" 83 | 84 | #: includes/wc-shortcodes-editor-i18n.php:27 85 | msgid "ID" 86 | msgstr "" 87 | 88 | #: includes/wc-shortcodes-editor-i18n.php:28 89 | msgid "IDs" 90 | msgstr "" 91 | 92 | #: includes/wc-shortcodes-editor-i18n.php:29 93 | msgid "SKU" 94 | msgstr "" 95 | 96 | #: includes/wc-shortcodes-editor-i18n.php:30 97 | msgid "SKUs" 98 | msgstr "" 99 | 100 | #: includes/wc-shortcodes-editor-i18n.php:31 101 | msgid "Inline Style" 102 | msgstr "" 103 | 104 | #: includes/wc-shortcodes-editor-i18n.php:32 105 | msgid "Show Price" 106 | msgstr "" 107 | 108 | #: includes/wc-shortcodes-editor-i18n.php:33 109 | msgid "Separate the values with comma" 110 | msgstr "" 111 | 112 | #: includes/wc-shortcodes-editor-i18n.php:34 113 | msgid "Number" 114 | msgstr "" 115 | 116 | #: includes/wc-shortcodes-editor-i18n.php:35 117 | msgid "Order By" 118 | msgstr "" 119 | 120 | #: includes/wc-shortcodes-editor-i18n.php:36 121 | msgid "Name" 122 | msgstr "" 123 | 124 | #: includes/wc-shortcodes-editor-i18n.php:37 125 | msgid "Count" 126 | msgstr "" 127 | 128 | #: includes/wc-shortcodes-editor-i18n.php:38 129 | msgid "Slug" 130 | msgstr "" 131 | 132 | #: includes/wc-shortcodes-editor-i18n.php:39 133 | msgid "None" 134 | msgstr "" 135 | 136 | #: includes/wc-shortcodes-editor-i18n.php:40 137 | msgid "Order" 138 | msgstr "" 139 | 140 | #: includes/wc-shortcodes-editor-i18n.php:41 141 | msgid "ASC" 142 | msgstr "" 143 | 144 | #: includes/wc-shortcodes-editor-i18n.php:42 145 | msgid "DESC" 146 | msgstr "" 147 | 148 | #: includes/wc-shortcodes-editor-i18n.php:43 149 | msgid "Columns" 150 | msgstr "" 151 | 152 | #: includes/wc-shortcodes-editor-i18n.php:44 153 | msgid "Hide Empty" 154 | msgstr "" 155 | 156 | #: includes/wc-shortcodes-editor-i18n.php:45 157 | msgid "Parent ID" 158 | msgstr "" 159 | 160 | #: includes/wc-shortcodes-editor-i18n.php:46 161 | msgid "Category Slug" 162 | msgstr "" 163 | 164 | #: includes/wc-shortcodes-editor-i18n.php:47 165 | msgid "Default" 166 | msgstr "" 167 | 168 | #: includes/wc-shortcodes-editor-i18n.php:48 169 | msgid "Random" 170 | msgstr "" 171 | 172 | #: includes/wc-shortcodes-editor-i18n.php:49 173 | msgid "Date" 174 | msgstr "" 175 | 176 | #: includes/wc-shortcodes-editor-i18n.php:50 177 | msgid "Price" 178 | msgstr "" 179 | 180 | #: includes/wc-shortcodes-editor-i18n.php:51 181 | msgid "Popularity" 182 | msgstr "" 183 | 184 | #: includes/wc-shortcodes-editor-i18n.php:52 185 | msgid "Rating" 186 | msgstr "" 187 | 188 | #: includes/wc-shortcodes-editor-i18n.php:53 189 | msgid "Title" 190 | msgstr "" 191 | 192 | #: includes/wc-shortcodes-editor-i18n.php:54 193 | msgid "Operator" 194 | msgstr "" 195 | 196 | #: includes/wc-shortcodes-editor-i18n.php:55 197 | msgid "IN" 198 | msgstr "" 199 | 200 | #: includes/wc-shortcodes-editor-i18n.php:56 201 | msgid "NOT IN" 202 | msgstr "" 203 | 204 | #: includes/wc-shortcodes-editor-i18n.php:57 205 | msgid "AND" 206 | msgstr "" 207 | 208 | #: includes/wc-shortcodes-editor-i18n.php:58 209 | msgid "Attribute slug" 210 | msgstr "" 211 | 212 | #: includes/wc-shortcodes-editor-i18n.php:59 213 | msgid "Terms slug" 214 | msgstr "" 215 | 216 | #: includes/wc-shortcodes-editor-i18n.php:60 217 | msgid "Categories Per Page" 218 | msgstr "" 219 | 220 | #: includes/wc-shortcodes-editor-i18n.php:61 221 | msgid "Products Per Page" 222 | msgstr "" 223 | 224 | #: includes/wc-shortcodes-editor-i18n.php:62 225 | msgid "You need to use an ID or SKU!" 226 | msgstr "" 227 | 228 | #: includes/wc-shortcodes-editor-i18n.php:63 229 | msgid "You need to use an IDs or SKUs!" 230 | msgstr "" 231 | 232 | #: includes/wc-shortcodes-editor-i18n.php:64 233 | msgid "You need enter with a category slug!" 234 | msgstr "" 235 | 236 | #: includes/wc-shortcodes-editor-i18n.php:65 237 | msgid "You need enter with an attribute and terms slugs!" 238 | msgstr "" 239 | 240 | #: woocommerce-shortcodes.php:99 241 | msgid "WooCommerce Shortcodes depends on the last version of %s to work!" 242 | msgstr "" 243 | 244 | #. Plugin Name of the plugin/theme 245 | msgid "WooCommerce Shortcodes" 246 | msgstr "" 247 | 248 | #. Plugin URI of the plugin/theme 249 | msgid "https://www.woothemes.com/" 250 | msgstr "" 251 | 252 | #. Description of the plugin/theme 253 | msgid "WooCommerce Shortcodes." 254 | msgstr "" 255 | 256 | #. Author of the plugin/theme 257 | msgid "WooThemes, Claudio Sanches" 258 | msgstr "" 259 | 260 | #. Author URI of the plugin/theme 261 | msgid "http://woothemes.com" 262 | msgstr "" 263 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "woocommerce-shortcodes", 3 | "description": "WooCommerce Shortcodes", 4 | "version": "1.0.0", 5 | "main": "Gruntfile.js", 6 | "devDependencies": { 7 | "grunt": "^0.4.5", 8 | "grunt-contrib-watch": "^0.6.1", 9 | "grunt-contrib-jshint": "^0.10.0", 10 | "grunt-contrib-uglify": "^0.4.0", 11 | "grunt-contrib-sass": "^0.7.3" 12 | }, 13 | "engines": { 14 | "node": ">=0.8.0", 15 | "npm": ">=1.1.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === WooCommerce Shortcodes === 2 | Contributors: woothemes, claudiosanches 3 | Tags: woocommerce, shortcodes 4 | Requires at least: 3.9 5 | Tested up to: 4.0 6 | Stable tag: 1.0.0 7 | License: GPLv2 or later 8 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 | 10 | Adds a button in TinyMCE editor allowing use of WooCommerce shortcodes. Beautifully. 11 | 12 | == Description == 13 | 14 | This plugin provides a TinyMCE dropdown button for you use all [WooCommerce](http://wordpress.org/plugins/woocommerce/) shortcodes. 15 | See list of shortcodes in [Shortcodes included with WooCommerce](http://docs.woothemes.com/document/woocommerce-shortcodes/). 16 | 17 | Starting WooCommerce 2.2, this TinyMCE button will no longer be part of WooCommerce and will only be available by using this plugin. 18 | 19 | = Requeriments = 20 | 21 | * WordPress 3.9 or later. 22 | * WooCommerce 2.2 or later. 23 | 24 | = Contribute = 25 | 26 | You can contribute to the source code in our [GitHub](https://github.com/woothemes/woocommerce-shortcodes/) page. 27 | 28 | == Installation == 29 | 30 | * Upload plugin files to your plugins folder, or install using WordPress built-in Add New Plugin installer; 31 | * Activate the plugin; 32 | * This ready! You can now use the WooCommerce shortcodes in any WordPress text editor. 33 | 34 | == Frequently Asked Questions == 35 | 36 | = What is the plugin license? = 37 | 38 | * This plugin is released under a GPL license. 39 | 40 | = What is needed to use this plugin? = 41 | 42 | * WordPress 3.9 or later. 43 | * WooCommerce 2.2 or later. 44 | 45 | = How this plugin works? = 46 | 47 | * Works just adding a dropdown button on TinyMCE editor for use the WooCommerce shortcodes. 48 | * This plugin creates no shortcode, just use the [shortcodes included in WooCommerce](http://docs.woothemes.com/document/woocommerce-shortcodes/). 49 | 50 | == Screenshots == 51 | 52 | 1. WooCommerce Shortcodes dropdown button 53 | 2. Example of adding the product button shortcode 54 | 3. Example of adding the feature products shortcodes 55 | 56 | == Changelog == 57 | 58 | = 1.0.0 = 59 | 60 | * Initial version. 61 | 62 | == Upgrade Notice == 63 | 64 | = 1.0.0 = 65 | 66 | * Initial version. 67 | -------------------------------------------------------------------------------- /woocommerce-shortcodes.php: -------------------------------------------------------------------------------- 1 | admin_includes(); 51 | } 52 | 53 | } else { 54 | add_action( 'admin_notices', array( $this, 'woocommerce_missing_notice' ) ); 55 | } 56 | } 57 | 58 | /** 59 | * Return an instance of this class. 60 | * 61 | * @return object A single instance of this class. 62 | */ 63 | public static function get_instance() { 64 | // If the single instance hasn't been set, set it now. 65 | if ( null == self::$instance ) { 66 | self::$instance = new self; 67 | } 68 | 69 | return self::$instance; 70 | } 71 | 72 | /** 73 | * Load the plugin text domain for translation. 74 | * 75 | * @return void 76 | */ 77 | public function load_plugin_textdomain() { 78 | $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-shortcodes' ); 79 | 80 | load_textdomain( 'woocommerce-shortcodes', trailingslashit( WP_LANG_DIR ) . 'woocommerce-shortcodes/woocommerce-shortcodes-' . $locale . '.mo' ); 81 | load_plugin_textdomain( 'woocommerce-shortcodes', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 82 | } 83 | 84 | /** 85 | * Admin includes. 86 | * 87 | * @return void 88 | */ 89 | public function admin_includes() { 90 | require_once 'includes/class-wc-shortcodes-admin.php'; 91 | } 92 | 93 | /** 94 | * WooCommerce fallback notice. 95 | * 96 | * @return string 97 | */ 98 | public function woocommerce_missing_notice() { 99 | echo '

' . sprintf( __( 'WooCommerce Shortcodes depends on the last version of %s to work!', 'woocommerce-shortcodes' ), '' . __( 'WooCommerce', 'woocommerce-shortcodes' ) . '' ) . '

'; 100 | } 101 | 102 | } 103 | 104 | add_action( 'plugins_loaded', array( 'WooCommerce_Shortcodes', 'get_instance' ), 0 ); 105 | 106 | endif; 107 | --------------------------------------------------------------------------------