├── .gitignore ├── lib ├── displays │ ├── form-fields │ │ ├── general │ │ │ └── label.php │ │ └── multi-post-select │ │ │ └── select-list.php │ ├── editor │ │ ├── edit_button.php │ │ ├── remove_button.php │ │ ├── form-editor.php │ │ ├── add-shortcode-editor.php │ │ ├── options-editor.php │ │ ├── add-row-editor.php │ │ ├── editor.php │ │ ├── generic-editor.php │ │ ├── excerpt-editor.php │ │ ├── layout-editor.php │ │ ├── row-editor.php │ │ └── column-editor.php │ └── items │ │ ├── figure │ │ └── figure.php │ │ ├── accordion │ │ └── accordion.php │ │ └── list │ │ └── list.php ├── images │ ├── edit-icon.png │ ├── instagram.png │ ├── plus-icon.png │ ├── spacer1x1.gif │ ├── spacer3x4.gif │ ├── spacer4x3.gif │ ├── close-icon.png │ ├── spacer16x9.gif │ ├── twitter-icon.png │ ├── facebook-icon.png │ ├── next-icon-dark.png │ ├── pagebreak-icon.gif │ ├── prev-icon-dark.png │ ├── close-icon-blue.png │ ├── column-four-icon.gif │ ├── minus-icon-basic.png │ ├── plus-icon-basic.png │ ├── column-halves-icon.gif │ ├── column-single-icon.gif │ ├── column-thirds-icon.gif │ ├── column-thirds-left-icon.gif │ ├── column-thirds-right-icon.gif │ ├── column-thirds-middle-icon.gif │ ├── column-two-sidebar-left-icon.gif │ ├── column-two-sidebar-right-icon.gif │ └── column-halves-sidebar-right-icon.gif ├── shortcodes │ ├── column │ │ ├── column.min.php │ │ ├── column.php │ │ └── class-column-shortcode.php │ ├── table │ │ ├── table.php │ │ └── class-table-shortcode.php │ ├── textblock │ │ ├── textblock.php │ │ └── class-textblock-shortcode.php │ ├── faq │ │ ├── faq.php │ │ └── class-faq-shortcode.php │ ├── social │ │ ├── twitter.php │ │ ├── facebook.php │ │ └── class-social-shortcode.php │ ├── action │ │ ├── action.min.php │ │ ├── action.php │ │ └── class-action-shortcode.php │ ├── image │ │ ├── image.php │ │ └── class-image-shortcode.php │ ├── video │ │ ├── youtube-video.php │ │ ├── vimeo-video.php │ │ └── class-video-shortcode.php │ ├── subtitle │ │ ├── subtitle.php │ │ └── class-subtitle-shortcode.php │ ├── slideshow │ │ ├── slideshow.php │ │ ├── slideshow-editor.php │ │ └── class-slideshow-shortcode.php │ ├── az-index │ │ ├── az-index-nav.php │ │ ├── az-index.php │ │ └── class-az-index-shortcode.php │ ├── slide │ │ ├── slide.php │ │ └── class-slide-shortcode.php │ ├── list │ │ ├── list.php │ │ └── class-list-shortcode.php │ ├── row │ │ ├── row.min.php │ │ └── row.php │ ├── post-gallery │ │ ├── post-gallery.php │ │ └── class-post-gallery-shortcode.php │ ├── tabs │ │ ├── column-tabs.php │ │ └── class-tabs-shortcode.php │ ├── promo │ │ └── promo.php │ ├── figure │ │ └── class-figure-shortcode.php │ ├── sidebar │ │ └── class-sidebar-shortcode.php │ └── content-feed │ │ └── class-content-feed-shortcode.php ├── includes │ ├── class-legacy-support.php │ ├── class-vendor-support.php │ ├── class-scripts.php │ ├── class-cahnrswp-pagebuilder.php │ ├── class-customizer.php │ ├── class-ajax.php │ ├── class-shortcodes.php │ └── class-editor.php ├── legacy-support │ └── support-1-5-0 │ │ ├── section │ │ └── class-section-shortcode.php │ │ └── support-1-5-0.php └── classes │ ├── class-cpb-post.php │ ├── class-rest-request.php │ ├── class-shortcode-parser.php │ └── class-query.php ├── includes └── wsuwp-plugin-skeleton.php ├── tests ├── test-wsuwp-plugin-skeleton.php └── bootstrap.php ├── README.md ├── phpunit.xml ├── package.json ├── composer.json ├── .vscode └── launch.json ├── plugin.php ├── phpcs.ruleset.xml ├── Gruntfile.js ├── .travis.yml └── bin └── install-wp-tests.sh /.gitignore: -------------------------------------------------------------------------------- 1 | composer.lock 2 | node_modules 3 | vendor 4 | -------------------------------------------------------------------------------- /lib/displays/form-fields/general/label.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/images/edit-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/edit-icon.png -------------------------------------------------------------------------------- /lib/images/instagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/instagram.png -------------------------------------------------------------------------------- /lib/images/plus-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/plus-icon.png -------------------------------------------------------------------------------- /lib/images/spacer1x1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/spacer1x1.gif -------------------------------------------------------------------------------- /lib/images/spacer3x4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/spacer3x4.gif -------------------------------------------------------------------------------- /lib/images/spacer4x3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/spacer4x3.gif -------------------------------------------------------------------------------- /lib/displays/editor/edit_button.php: -------------------------------------------------------------------------------- 1 | Edit 4 | -------------------------------------------------------------------------------- /lib/images/close-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/close-icon.png -------------------------------------------------------------------------------- /lib/images/spacer16x9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/spacer16x9.gif -------------------------------------------------------------------------------- /lib/images/twitter-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/twitter-icon.png -------------------------------------------------------------------------------- /lib/displays/editor/remove_button.php: -------------------------------------------------------------------------------- 1 | Remove 4 | -------------------------------------------------------------------------------- /lib/images/facebook-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/facebook-icon.png -------------------------------------------------------------------------------- /lib/images/next-icon-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/next-icon-dark.png -------------------------------------------------------------------------------- /lib/images/pagebreak-icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/pagebreak-icon.gif -------------------------------------------------------------------------------- /lib/images/prev-icon-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/prev-icon-dark.png -------------------------------------------------------------------------------- /lib/images/close-icon-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/close-icon-blue.png -------------------------------------------------------------------------------- /lib/images/column-four-icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/column-four-icon.gif -------------------------------------------------------------------------------- /lib/images/minus-icon-basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/minus-icon-basic.png -------------------------------------------------------------------------------- /lib/images/plus-icon-basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/plus-icon-basic.png -------------------------------------------------------------------------------- /lib/images/column-halves-icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/column-halves-icon.gif -------------------------------------------------------------------------------- /lib/images/column-single-icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/column-single-icon.gif -------------------------------------------------------------------------------- /lib/images/column-thirds-icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/column-thirds-icon.gif -------------------------------------------------------------------------------- /lib/images/column-thirds-left-icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/column-thirds-left-icon.gif -------------------------------------------------------------------------------- /lib/images/column-thirds-right-icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/column-thirds-right-icon.gif -------------------------------------------------------------------------------- /lib/images/column-thirds-middle-icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/column-thirds-middle-icon.gif -------------------------------------------------------------------------------- /lib/images/column-two-sidebar-left-icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/column-two-sidebar-left-icon.gif -------------------------------------------------------------------------------- /lib/images/column-two-sidebar-right-icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/column-two-sidebar-right-icon.gif -------------------------------------------------------------------------------- /lib/images/column-halves-sidebar-right-icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/washingtonstateuniversity/CAHNRSWSUWP-Plugin-Pagebuilder/master/lib/images/column-halves-sidebar-right-icon.gif -------------------------------------------------------------------------------- /lib/shortcodes/column/column.min.php: -------------------------------------------------------------------------------- 1 |
4 | -------------------------------------------------------------------------------- /lib/shortcodes/column/column.php: -------------------------------------------------------------------------------- 1 |
4 | -------------------------------------------------------------------------------- /lib/displays/editor/form-editor.php: -------------------------------------------------------------------------------- 1 |
4 | 5 |
6 | 7 |
8 | -------------------------------------------------------------------------------- /includes/wsuwp-plugin-skeleton.php: -------------------------------------------------------------------------------- 1 |
4 | 5 |
6 |
7 | -------------------------------------------------------------------------------- /lib/shortcodes/table/table.php: -------------------------------------------------------------------------------- 1 |
4 | 5 |
6 |
7 | -------------------------------------------------------------------------------- /lib/shortcodes/textblock/textblock.php: -------------------------------------------------------------------------------- 1 |
$content

"; 6 | //@codingStandardsIgnoreEnd 7 | ?>
8 | -------------------------------------------------------------------------------- /tests/test-wsuwp-plugin-skeleton.php: -------------------------------------------------------------------------------- 1 | assertTrue( true ); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CAHNRS WSUWP Plugin Pagebuilder 2 | 3 | [![Build Status](https://travis-ci.org/washingtonstateuniversity/cahnrwsuwp-plugin-pagebuilder.svg?branch=master)](https://travis-ci.org/washingtonstateuniversity/cahnrswsuwp-plugin-pagebuilder) 4 | 5 | 6 | A framework for building a WordPress plugin at WSU. 7 | -------------------------------------------------------------------------------- /lib/displays/items/accordion/accordion.php: -------------------------------------------------------------------------------- 1 |
4 |
<>>
5 |
6 |
7 | -------------------------------------------------------------------------------- /lib/shortcodes/faq/faq.php: -------------------------------------------------------------------------------- 1 |
4 |
<>>
5 |
6 |
7 | -------------------------------------------------------------------------------- /lib/shortcodes/social/twitter.php: -------------------------------------------------------------------------------- 1 | Tweets 4 | -------------------------------------------------------------------------------- /lib/shortcodes/action/action.min.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /lib/displays/editor/add-shortcode-editor.php: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | ./tests/ 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/shortcodes/action/action.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/shortcodes/image/image.php: -------------------------------------------------------------------------------- 1 |
4 | 5 | alt="" /> 6 | 7 |
8 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cahnrswsuwp-plugin-pagebuilder", 3 | "version": "0.0.1", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/washingtonstateuniversity/cahnrswsuwp-plugin-pagebuilder" 7 | }, 8 | "author": "washingtonstateuniversity", 9 | "license": "GPL-2.0+", 10 | "devDependencies": { 11 | "grunt": "~1.0.1", 12 | "grunt-contrib-jshint": "^1.1.0", 13 | "grunt-jscs": "^3.0.1", 14 | "grunt-phpcs": "^0.4.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/shortcodes/subtitle/subtitle.php: -------------------------------------------------------------------------------- 1 | 4 | < class=""> 5 | 6 | 7 | 8 | > 9 | -------------------------------------------------------------------------------- /lib/shortcodes/video/vimeo-video.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | -------------------------------------------------------------------------------- /lib/shortcodes/slideshow/slideshow.php: -------------------------------------------------------------------------------- 1 |
4 |
5 | 6 | 7 |
8 | 9 |
10 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "washingtonstateuniversity/cahnrswsuwp-plugin-pagebuilder", 3 | "authors": [ 4 | { 5 | "name": "Washington State University" 6 | } 7 | ], 8 | "require-dev": { 9 | "squizlabs/php_codesniffer": "3.x.x", 10 | "wp-coding-standards/wpcs": "0.14.x" 11 | }, 12 | "scripts": { 13 | "post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/wp-coding-standards/wpcs", 14 | "post-update-cmd" : "\"vendor/bin/phpcs\" --config-set installed_paths vendor/wp-coding-standards/wpcs" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/displays/editor/options-editor.php: -------------------------------------------------------------------------------- 1 |
4 | $value ) : ?> 5 | 8 | /> 9 | 10 |
11 | -------------------------------------------------------------------------------- /lib/shortcodes/az-index/az-index-nav.php: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /lib/shortcodes/slide/slide.php: -------------------------------------------------------------------------------- 1 | 15 | -------------------------------------------------------------------------------- /lib/shortcodes/list/list.php: -------------------------------------------------------------------------------- 1 |
  • 4 | 5 |
    6 | 7 | 8 | 9 |
    10 | 11 | 12 |
    13 | 14 |
  • 15 | -------------------------------------------------------------------------------- /lib/displays/items/list/list.php: -------------------------------------------------------------------------------- 1 |
  • 4 | 5 |
    6 | 7 | 8 | 9 |
    10 | 11 | 12 |
    13 | 14 |
  • 15 | -------------------------------------------------------------------------------- /lib/shortcodes/az-index/az-index.php: -------------------------------------------------------------------------------- 1 |
    4 | $item ) : $class = ( ! empty( $item['link'] ) ) ? ' has-link' : ''; ?>
    5 |

    6 |
    Visit:
    8 | 9 |
    10 | 11 |
    12 | -------------------------------------------------------------------------------- /lib/shortcodes/row/row.min.php: -------------------------------------------------------------------------------- 1 |

    4 | -------------------------------------------------------------------------------- /lib/displays/editor/add-row-editor.php: -------------------------------------------------------------------------------- 1 |
    4 |
    + Add Row
    5 | 15 |
    16 | -------------------------------------------------------------------------------- /lib/displays/editor/editor.php: -------------------------------------------------------------------------------- 1 |
    7 | 8 | 9 | 10 | 11 | ID, 'cahnrs_pagebuilder_key', true, false ); ?> 12 | 13 | 14 |
    15 | -------------------------------------------------------------------------------- /lib/displays/editor/generic-editor.php: -------------------------------------------------------------------------------- 1 |
    4 |
    Item:
    5 |
    6 | 11 | 12 |
    13 | 14 |
    15 | -------------------------------------------------------------------------------- /lib/shortcodes/row/row.php: -------------------------------------------------------------------------------- 1 | 4 |
    5 |
    6 |
    7 |

    8 | 9 |
    10 |
    11 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "name": "Listen for XDebug", 10 | "type": "php", 11 | "request": "launch", 12 | "port": 9000 13 | }, 14 | { 15 | "name": "Launch currently open script", 16 | "type": "php", 17 | "request": "launch", 18 | "program": "${file}", 19 | "cwd": "${fileDirname}", 20 | "port": 9000 21 | }, 22 | 23 | ] 24 | } -------------------------------------------------------------------------------- /lib/displays/editor/excerpt-editor.php: -------------------------------------------------------------------------------- 1 |
    4 | $value ) : ?> 5 | 8 | /> 9 | 10 | 11 |
    12 | -------------------------------------------------------------------------------- /lib/displays/form-fields/multi-post-select/select-list.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | -------------------------------------------------------------------------------- /lib/displays/editor/layout-editor.php: -------------------------------------------------------------------------------- 1 |
    4 |
    5 |
    6 | 11 |
    12 | 13 |
    14 | 15 |
    16 | 21 | 26 |
    27 | -------------------------------------------------------------------------------- /lib/shortcodes/social/facebook.php: -------------------------------------------------------------------------------- 1 |
    View on Facebook
    4 | -------------------------------------------------------------------------------- /lib/includes/class-legacy-support.php: -------------------------------------------------------------------------------- 1 | cpb-layout-item" data-id=""> 2 |
    Slideshow
    3 |
    4 | 9 |
    10 |
    + Add Slide
    11 |
    12 | 13 |
    14 | 15 | -------------------------------------------------------------------------------- /lib/displays/editor/row-editor.php: -------------------------------------------------------------------------------- 1 |
    4 |
    Row |
    5 |
    6 |
    7 | 12 |
    13 |
    14 | 15 |
    16 | 17 |
    18 |
    19 | -------------------------------------------------------------------------------- /plugin.php: -------------------------------------------------------------------------------- 1 |

    " . __( 'WSUWP Plugin Skeleton requires PHP 5.3 to function properly. Please upgrade PHP or deactivate the plugin.', 'cahnrswp-pagebuilder' ) . "

    ';" ) ); 21 | return; 22 | } else { 23 | 24 | // Class to handle init of plugin 25 | include_once __DIR__ . '/lib/includes/class-cahnrswp-pagebuilder.php'; 26 | 27 | } // End if 28 | -------------------------------------------------------------------------------- /lib/shortcodes/post-gallery/post-gallery.php: -------------------------------------------------------------------------------- 1 |
    4 | 18 | 23 |
    24 | -------------------------------------------------------------------------------- /lib/displays/editor/column-editor.php: -------------------------------------------------------------------------------- 1 |
    4 |
    5 |
    Column
    6 |
    7 | 12 |
    13 | + Add Item 14 | 15 |
    16 |
    17 | 18 |
    19 |
    20 | -------------------------------------------------------------------------------- /lib/includes/class-vendor-support.php: -------------------------------------------------------------------------------- 1 | tribe_events_support(); 17 | 18 | } // End __construct 19 | 20 | 21 | /** 22 | * @desc Add support to tribe events even though it's going away 23 | * @since 3.0.5 24 | */ 25 | protected function tribe_events_support() { 26 | 27 | add_filter( 'cpb_post_item_array_local_query', array( $this, 'filter_tribe_event_post_item' ), 10, 2 ); 28 | 29 | } // End tribe_events_support 30 | 31 | 32 | /** 33 | * @desc Filter post item for Tribe Events 34 | * @since 3.0.5 35 | * 36 | * @param array $post_item CPB post item 37 | * @param WP_Post 38 | * 39 | * @return array Modified CPB post item 40 | */ 41 | public function filter_tribe_event_post_item( $post_item, $post ) { 42 | 43 | if ( 'tribe_events' === $post->post_type ) { 44 | 45 | $start_date = tribe_get_start_date( $post->ID, false, 'M j, Y' ); 46 | 47 | $post_item['event_date'] = $start_date; 48 | 49 | } // end if 50 | 51 | return $post_item; 52 | 53 | } // End filter_tribe_event_post_item 54 | 55 | } // End Vendor_Support 56 | 57 | $vendor_support = new Vendor_Support(); 58 | -------------------------------------------------------------------------------- /phpcs.ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | . 18 | 19 | Sniffs for PHP coding standards used by WSUWP Plugins 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/shortcodes/tabs/column-tabs.php: -------------------------------------------------------------------------------- 1 |
    4 | $tab ) : ?> 5 |
    6 |
    7 |
    < class="-text">>
    8 |
    9 |
    10 | post_content ); 20 | // @codingStandardsIgnoreEnd 21 | 22 | } // end foreach 23 | }; ?> 24 |
    25 | 26 |
    27 | -------------------------------------------------------------------------------- /lib/includes/class-scripts.php: -------------------------------------------------------------------------------- 1 |
    4 | 5 |
    6 | <?php echo esc_html( $img_alt ); ?> 7 |
    8 | 9 |
    10 | 11 |
    < class="cpb-title">>
    12 | 13 | 14 |
    15 | 16 | 17 |
    18 | 19 | 20 |
    21 | 22 | 23 | 24 | 25 |
    26 |
    27 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function( grunt ) { 2 | grunt.initConfig( { 3 | pkg: grunt.file.readJSON( "package.json" ), 4 | 5 | phpcs: { 6 | plugin: { 7 | src: [ "./*.php", "./includes/*.php", "./tests/*.php" ] 8 | }, 9 | options: { 10 | bin: "vendor/bin/phpcs --extensions=php --ignore=\"*/vendor/*,*/node_modules/*\"", 11 | standard: "phpcs.ruleset.xml" 12 | } 13 | }, 14 | 15 | jscs: { 16 | scripts: { 17 | src: [ "Gruntfile.js", "src/js/*.js" ], 18 | options: { 19 | preset: "jquery", 20 | requireCamelCaseOrUpperCaseIdentifiers: false, // We rely on name_name too much to change them all. 21 | maximumLineLength: 250 22 | } 23 | } 24 | }, 25 | 26 | jshint: { 27 | grunt_script: { 28 | src: [ "Gruntfile.js" ], 29 | options: { 30 | curly: true, 31 | eqeqeq: true, 32 | noarg: true, 33 | quotmark: "double", 34 | undef: true, 35 | unused: false, 36 | node: true // Define globals available when running in Node. 37 | } 38 | } 39 | } 40 | } ); 41 | 42 | grunt.loadNpmTasks( "grunt-jscs" ); 43 | grunt.loadNpmTasks( "grunt-contrib-jshint" ); 44 | grunt.loadNpmTasks( "grunt-phpcs" ); 45 | 46 | // Default task(s). 47 | grunt.registerTask( "default", [ "phpcs", "jscs", "jshint" ] ); 48 | }; 49 | -------------------------------------------------------------------------------- /lib/includes/class-cahnrswp-pagebuilder.php: -------------------------------------------------------------------------------- 1 | set_constants(); 18 | 19 | $this->init_plugin(); 20 | 21 | } // End construct 22 | 23 | 24 | /* 25 | * @desc Set constants use in plugin funcitons. These should never be used direclty 26 | * @since 3.0.0 27 | */ 28 | protected function set_constants() { 29 | 30 | // Set plugin path constant 31 | \define( 'CWPPAGEBUILDERPATH', dirname( dirname( __DIR__ ) ) ); 32 | 33 | // Set plugin url cinstant 34 | \define( 'CWPPAGEBUILDERURL', \plugin_dir_url( dirname( dirname( __FILE__ ) ) ) ); 35 | 36 | } // End set_constants 37 | 38 | 39 | /* 40 | * @desc Start plugin script and load admin classes 41 | * @since 3.0.0 42 | */ 43 | protected function init_plugin() { 44 | 45 | // Include global functions 46 | include CWPPAGEBUILDERPATH . '/lib/functions/public.php'; 47 | 48 | // Check if is WP admin 49 | if ( \is_admin() ) { 50 | 51 | // Add Pagebuilder Editor 52 | include cpb_get_plugin_path( '/lib/includes/class-editor.php' ); 53 | 54 | // Add Pagebuilder Save 55 | include cpb_get_plugin_path( '/lib/includes/class-save.php' ); 56 | 57 | } // End if 58 | 59 | // Add Pagebuilder shortcodes 60 | include cpb_get_plugin_path( '/lib/includes/class-shortcodes.php' ); 61 | 62 | // Add CSS & JS 63 | include cpb_get_plugin_path( '/lib/includes/class-scripts.php' ); 64 | 65 | // Add AJAX support 66 | include cpb_get_plugin_path( '/lib/includes/class-ajax.php' ); 67 | 68 | // Add Customizer Script 69 | include cpb_get_plugin_path( '/lib/includes/class-customizer.php' ); 70 | 71 | // Add Legacy Support 72 | include_once cpb_get_plugin_path( '/lib/includes/class-legacy-support.php' ); 73 | 74 | // Add Vendor Support 75 | include_once cpb_get_plugin_path( '/lib/includes/class-vendor-support.php' ); 76 | 77 | } // End init_plugin 78 | 79 | 80 | } // End CAHNRSWP_Pagebuilder 81 | 82 | $cahnrswp_pagebuilder = new CAHNRSWP_Pagebuilder(); 83 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: php 3 | 4 | # Cache some data across builds for performance. 5 | cache: 6 | apt: true 7 | directories: 8 | - node_modules 9 | - vendor 10 | - $HOME/.composer/cache 11 | 12 | notifications: 13 | email: 14 | on_success: never 15 | on_failure: change 16 | slack: 17 | on_pull_requests: true 18 | on_success: change 19 | on_failure: always 20 | on_start: never 21 | on_cancel: always 22 | rooms: 23 | - wsu-ucomm:n2TLZRJd84rMOMbkKthSEMgS 24 | 25 | branches: 26 | only: 27 | - master 28 | 29 | matrix: 30 | include: 31 | - php: 7.2 32 | env: WP_Version=nightly 33 | - php: 7.1 34 | env: WP_VERSION=latest WP_TRAVISCI=phpcs 35 | 36 | before_script: 37 | - export PATH="$HOME/.composer/vendor/bin:$PATH" 38 | - phpenv config-rm xdebug.ini 39 | - | 40 | if [[ ! -z "$WP_VERSION" ]] ; then 41 | bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION 42 | composer global require "phpunit/phpunit=5.7.*" 43 | fi 44 | - | 45 | if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then 46 | composer global require wp-coding-standards/wpcs 47 | phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs 48 | fi 49 | - mysql --version 50 | - phpenv versions 51 | - php --version 52 | 53 | script: 54 | - | 55 | if [[ ! -z "$WP_VERSION" ]] ; then 56 | phpunit --version 57 | phpunit 58 | WP_MULTISITE=1 phpunit 59 | fi 60 | - | 61 | if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then 62 | phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php') 63 | fi 64 | 65 | # If the plugin has any JavaScript or CSS that should be processed, 66 | # add the below to their respective sections so that Grunt is installed 67 | # and all default tasks are run. 68 | # 69 | # To the matrix: 70 | # 71 | # - php: 7.0 72 | # env: WP_TRAVISCI=grunt 73 | # 74 | # To before_script: 75 | # 76 | # - npm --version 77 | # - node --version 78 | # - nvm install stable 79 | # - npm install -g grunt-cli 80 | # - npm install 81 | # - npm prune 82 | # - npm --version 83 | # - node --version 84 | # 85 | # To script: 86 | # 87 | # - | 88 | # if [[ "$WP_TRAVISCI" == "grunt" ]] ; then 89 | # grunt --version 90 | # grunt default 91 | # fi 92 | -------------------------------------------------------------------------------- /lib/legacy-support/support-1-5-0/section/class-section-shortcode.php: -------------------------------------------------------------------------------- 1 | default_settings, array(), 'section' ); 36 | 37 | cpb_register_shortcode( 38 | 'section', 39 | $args = array( 40 | 'form_callback' => array( $this, 'get_shortcode_form' ), 41 | 'label' => 'Section', // Label of the item 42 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 43 | 'default_atts' => $default_atts, 44 | 'in_column' => false, // Allow in column 45 | ) 46 | ); 47 | 48 | } // End register_shortcode 49 | 50 | 51 | /* 52 | * @desc Render the shortcode 53 | * @since 3.0.0 54 | * 55 | * @param array $atts Shortcode attributes 56 | * @param string $content Shortcode content 57 | * 58 | * @return string HTML shortcode output 59 | */ 60 | public function get_rendered_shortcode( $atts, $content ) { 61 | 62 | $html = ''; 63 | 64 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'section' ); 65 | 66 | // Check default settings 67 | $atts = \shortcode_atts( $default_atts, $atts, 'section' ); 68 | 69 | $html = do_shortcode( $content ); 70 | 71 | return $html; 72 | 73 | } // End get_rendered_shortcode 74 | 75 | 76 | /* 77 | * @desc Get HTML for shortcode form 78 | * @since 3.0.0 79 | * 80 | * @param array $atts Shortcode attributes 81 | * @param string $content Shortcode content 82 | * 83 | * @return string HTML shortcode form output 84 | */ 85 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 86 | 87 | return array( 88 | 'Basic' => '', 89 | ); 90 | 91 | } // End get_shortcode_form 92 | 93 | } // End Section 94 | 95 | $cpb_shortcode_section = new Section_Shortcode(); 96 | -------------------------------------------------------------------------------- /lib/includes/class-customizer.php: -------------------------------------------------------------------------------- 1 | add_setting( 25 | 'cpb_pre_filter', 26 | array( 27 | 'default' => '', 28 | 'transport' => 'refresh', 29 | ) 30 | ); 31 | 32 | $post_types = $this->get_wp_post_types(); 33 | 34 | foreach ( $post_types as $type => $label ) { 35 | 36 | $default = 0; 37 | 38 | if ( 'page' === $type ) { 39 | 40 | $default = 1; 41 | 42 | } // End if 43 | 44 | $wp_customize->add_setting( 45 | 'cpb_enable_post_type_' . $type, 46 | array( 47 | 'default' => $default, 48 | 'transport' => 'refresh', 49 | ) 50 | ); 51 | 52 | } // End forach 53 | 54 | $wp_customize->add_section( 55 | 'cpb_options', 56 | array( 57 | 'title' => 'CAHNRS PageBuilder Options', 58 | 'priority' => 30, 59 | ) 60 | ); 61 | 62 | $wp_customize->add_control( 63 | 'cpb_pre_filter_control', 64 | array( 65 | 'label' => 'Pre Filter Content', 66 | 'section' => 'cpb_options', 67 | 'settings' => 'cpb_pre_filter', 68 | 'type' => 'checkbox', 69 | ) 70 | ); 71 | 72 | foreach ( $post_types as $type => $label ) { 73 | 74 | $wp_customize->add_control( 75 | 'cpb_enable_post_type_' . $type . '_control', 76 | array( 77 | 'label' => 'Add PageBuilder to ' . $label, 78 | 'section' => 'cpb_options', 79 | 'settings' => 'cpb_enable_post_type_' . $type, 80 | 'type' => 'checkbox', 81 | ) 82 | ); 83 | 84 | } // End forach 85 | 86 | } // End add_customizer_options 87 | 88 | 89 | protected function get_wp_post_types() { 90 | 91 | $post_type_array = array(); 92 | 93 | $args = array( 94 | 'public' => true, 95 | ); 96 | 97 | $post_types = \get_post_types( $args, 'objects' ); 98 | 99 | foreach ( $post_types as $post_type ) { 100 | 101 | $post_type_array[ $post_type->name ] = $post_type->label; 102 | 103 | } // End foreach 104 | 105 | return $post_type_array; 106 | 107 | } // End get_wp_post_types 108 | 109 | } // End Scripts 110 | 111 | $cpb_customizer = new Customizer(); 112 | -------------------------------------------------------------------------------- /lib/legacy-support/support-1-5-0/support-1-5-0.php: -------------------------------------------------------------------------------- 1 | add_shortcodes(); 18 | 19 | add_filter( 'cpb_shortcode_default_atts', array( $this, 'filter_default_atts' ), 10, 3 ); 20 | 21 | } // End __construct 22 | 23 | 24 | /* 25 | * @desc Add shortcodes for 1.5.0 support 26 | * @since 3.0.5 27 | */ 28 | protected function add_shortcodes() { 29 | 30 | include_once cpb_get_plugin_path( '/lib/legacy-support/support-1-5-0/section/class-section-shortcode.php' ); 31 | 32 | } // End add_shortcodes 33 | 34 | 35 | /* 36 | * @desc Filter default atts to support legacy settings 37 | * @since 3.0.5 38 | * 39 | * @param array $default_atts Default atts 40 | * @param array $atts Set shortcode atts 41 | * @param string $tag Shortcode tag 42 | * 43 | * @return array Filtered default atts 44 | */ 45 | public function filter_default_atts( $default_atts, $atts, $tag ) { 46 | 47 | switch ( $tag ) { 48 | 49 | case 'promo': 50 | $default_atts = $this->get_promo_default_atts( $default_atts, $atts ); 51 | break; 52 | case 'list': 53 | $default_atts = $this->get_list_default_atts( $default_atts, $atts ); 54 | break; 55 | } // End switch 56 | 57 | return $default_atts; 58 | 59 | } // End filter_default_atts 60 | 61 | 62 | /* 63 | * @desc Filter default atts to support legacy settings 64 | * @since 3.0.5 65 | * 66 | * @param array $default_atts Default atts 67 | * @param array $atts Set shortcode atts 68 | * 69 | * @return array Filtered default atts 70 | */ 71 | protected function get_promo_default_atts( $default_atts, $atts ) { 72 | 73 | if ( ! empty( $atts['source'] ) ) { 74 | 75 | $default_atts['promo_type'] = $atts['source']; 76 | 77 | } // End if 78 | 79 | return $default_atts; 80 | 81 | } // End get_promo_default_atts 82 | 83 | 84 | /* 85 | * @desc Filter default atts to support legacy settings 86 | * @since 3.0.5 87 | * 88 | * @param array $default_atts Default atts 89 | * @param array $atts Set shortcode atts 90 | * 91 | * @return array Filtered default atts 92 | */ 93 | protected function get_list_default_atts( $default_atts, $atts ) { 94 | 95 | if ( ! empty( $atts['source'] ) ) { 96 | 97 | $default_atts['source_type'] = $atts['source']; 98 | 99 | } // End if 100 | 101 | if ( ! empty( $atts['hide_excerpt'] ) ) { 102 | 103 | $default_atts['unset_excerpt'] = $atts['hide_excerpt']; 104 | 105 | } // End if 106 | 107 | return $default_atts; 108 | 109 | } // End get_promo_default_atts 110 | 111 | 112 | } // End Scripts 113 | 114 | $cpb_legacy_support_1_5_0 = new Support_1_5_0(); 115 | -------------------------------------------------------------------------------- /lib/classes/class-cpb-post.php: -------------------------------------------------------------------------------- 1 | '', 22 | 'img_large_src' => '', 23 | 'img_medium_src' => '', 24 | 'img_thumb_src' => '', 25 | 'img_alt' => '', 26 | 'img_id' => '', 27 | ); 28 | 29 | public $post_excerpt = ''; 30 | 31 | public $post_id = ''; 32 | 33 | public $post_type = ''; 34 | 35 | public $post_link = ''; 36 | 37 | 38 | /* 39 | * @desc Build the post from passed data 40 | * @since 3.0.4 41 | * 42 | * @param mixed $post Post data to build from. Eventually could be WP_Post, Post ID, REST Response, REST request query. 43 | * @param string $context Context to build post from 44 | * @param array $args Args to pass along to the build 45 | */ 46 | public function __construct( $post, $context = 'wp_post', $args = array() ) { 47 | 48 | switch ( $context ) { 49 | 50 | case 'rest-response': 51 | $this->set_from_rest_response( $post, $context, $args ); 52 | break; 53 | 54 | } // End switch 55 | 56 | } // End __construct 57 | 58 | 59 | /* 60 | * @desc Get REST response and set from response 61 | * 62 | * @param mixed $post Post data to build from. Eventually could be WP_Post, Post ID, REST Response, REST request query. 63 | * @param string $context Context to build post from 64 | * @param array $args Args to pass along to the build 65 | */ 66 | protected function set_from_rest_response( $post, $context, $args ) { 67 | 68 | //var_dump( $post['post_images'] ); 69 | 70 | if ( ! empty( $post['title']['rendered'] ) ) { 71 | 72 | $this->post_title = $post['title']['rendered']; 73 | 74 | $this->post_content = $post['content']['rendered']; 75 | 76 | $this->post_excerpt = $post['excerpt']['rendered']; 77 | 78 | $this->post_link = $post['link']; 79 | 80 | $this->post_id = $post['id']; 81 | 82 | // TO DO $post["_embedded"]['wp:featuredmedia'] to handle alt tags 83 | 84 | if ( ! empty( $post['post_images'] ) ) { 85 | 86 | $this->post_image_array = array( 87 | 'img_full_src' => ( ! empty( $post['post_images']['full'] ) ) ? $post['post_images']['full'] : '', 88 | 'img_large_src' => ( ! empty( $post['post_images']['large'] ) ) ? $post['post_images']['large'] : '', 89 | 'img_medium_src' => ( ! empty( $post['post_images']['medium'] ) ) ? $post['post_images']['medium'] : '', 90 | 'img_thumb_src' => ( ! empty( $post['post_images']['thumbnail'] ) ) ? $post['post_images']['thumbnail'] : '', 91 | 'img_alt' => '', 92 | 'img_id' => '', 93 | ); 94 | 95 | } // End if 96 | } // End if 97 | 98 | } // End set_from_rest_query 99 | 100 | 101 | } // End CPB_Post 102 | -------------------------------------------------------------------------------- /lib/shortcodes/table/class-table-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'img_id' => '', 20 | 'caption' => '', 21 | 'alt' => '', 22 | ); 23 | 24 | 25 | public function __construct() { 26 | 27 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 28 | 29 | } // End __construct 30 | 31 | 32 | /* 33 | * @desc Register table shortcode 34 | * @since 3.0.0 35 | */ 36 | public function register_shortcode() { 37 | 38 | \add_shortcode( 'cpbtable', array( $this, 'get_rendered_shortcode' ) ); 39 | 40 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'cpbtable' ); 41 | 42 | cpb_register_shortcode( 43 | 'cpbtable', 44 | $args = array( 45 | 'form_callback' => array( $this, 'get_shortcode_form' ), 46 | 'label' => 'Table', // Label of the item 47 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 48 | 'default_atts' => $default_atts, 49 | 'in_column' => true, // Allow in column 50 | ) 51 | ); 52 | 53 | } // End register_shortcode 54 | 55 | 56 | /* 57 | * @desc Render the shortcode 58 | * @since 3.0.0 59 | * 60 | * @param array $atts Shortcode attributes 61 | * @param string $content Shortcode content 62 | * 63 | * @return string HTML shortcode output 64 | */ 65 | public function get_rendered_shortcode( $atts, $content ) { 66 | 67 | $html = ''; 68 | 69 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'cpbtable' ); 70 | 71 | // Check default settings 72 | $atts = \shortcode_atts( $default_atts, $atts, 'cpbtable' ); 73 | 74 | $img_src = $atts['img_src']; 75 | 76 | $caption = $atts['caption']; 77 | 78 | $alt = $atts['alt']; 79 | 80 | if ( ! empty( $img_src ) ) { 81 | 82 | ob_start(); 83 | 84 | include __DIR__ . '/table.php'; 85 | 86 | $html .= ob_get_clean(); 87 | 88 | } // End if 89 | 90 | return $html; 91 | 92 | } // End get_rendered_shortcode 93 | 94 | 95 | /* 96 | * @desc Get HTML for shortcode form 97 | * @since 3.0.0 98 | * 99 | * @param array $atts Shortcode attributes 100 | * @param string $content Shortcode content 101 | * 102 | * @return string HTML shortcode form output 103 | */ 104 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 105 | 106 | $cpb_form = cpb_get_form_class(); 107 | 108 | $form = $cpb_form->insert_media( cpb_get_input_name( $id, true ), $settings ); 109 | 110 | $form .= '
    '; 111 | 112 | $form .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'caption' ), $settings['caption'], 'Caption' ); 113 | 114 | return $form; 115 | 116 | } // End get_shortcode_form 117 | 118 | } // End Table 119 | 120 | $cpb_shortcode_table = new Table_Shortcode(); 121 | -------------------------------------------------------------------------------- /lib/shortcodes/figure/class-figure-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'img_id' => '', 20 | 'caption' => '', 21 | ); 22 | 23 | 24 | public function __construct() { 25 | 26 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 27 | 28 | } // End __construct 29 | 30 | 31 | /* 32 | * @desc Register figure shortcode 33 | * @since 3.0.0 34 | */ 35 | public function register_shortcode() { 36 | 37 | \add_shortcode( 'figure', array( $this, 'get_rendered_shortcode' ) ); 38 | 39 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'figure' ); 40 | 41 | cpb_register_shortcode( 42 | 'figure', 43 | $args = array( 44 | 'label' => 'Figure/Caption', // Label of the item 45 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 46 | 'form_callback' => array( $this, 'get_shortcode_form' ), 47 | 'default_atts' => $default_atts, 48 | 'in_column' => true, // Allow in column 49 | ) 50 | ); 51 | 52 | } // End register_shortcode 53 | 54 | 55 | /* 56 | * @desc Render the shortcode 57 | * @since 3.0.0 58 | * 59 | * @param array $atts Shortcode attributes 60 | * @param string $content Shortcode content 61 | * 62 | * @return string HTML shortcode output 63 | */ 64 | public function get_rendered_shortcode( $atts, $content ) { 65 | 66 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'figure' ); 67 | 68 | // Check default settings 69 | $atts = \shortcode_atts( $default_atts, $atts, 'figure' ); 70 | 71 | $html = ''; 72 | 73 | $img_src = $atts['img_src']; 74 | 75 | $caption = $atts['caption']; 76 | 77 | if ( ! empty( $img_src ) ) { 78 | 79 | \ob_start(); 80 | 81 | include cpb_get_plugin_path( '/lib/displays/items/figure/figure.php' ); 82 | 83 | $html .= \ob_get_clean(); 84 | 85 | } // End if 86 | 87 | return $html; 88 | 89 | } // End get_rendered_shortcode 90 | 91 | 92 | /* 93 | * @desc Get HTML for shortcode form 94 | * @since 3.0.0 95 | * 96 | * @param array $atts Shortcode attributes 97 | * @param string $content Shortcode content 98 | * 99 | * @return string HTML shortcode form output 100 | */ 101 | public function get_shortcode_form( $id, $atts, $content, $cpb_form ) { 102 | 103 | $cpb_form = cpb_get_form_class(); 104 | 105 | $form = $cpb_form->insert_media( cpb_get_input_name( $id, true ), $atts ); 106 | 107 | $form .= '
    '; 108 | 109 | $form .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'caption' ), $atts['caption'], 'Caption' ); 110 | 111 | return array( 'Basic' => $form ); 112 | 113 | } // End get_shortcode_form 114 | 115 | 116 | } // End Figure 117 | 118 | $cpb_shortcode_figure = new Figure_Shortcode(); 119 | -------------------------------------------------------------------------------- /lib/shortcodes/sidebar/class-sidebar-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | ); 20 | 21 | 22 | public function __construct() { 23 | 24 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 25 | 26 | } // End __construct 27 | 28 | 29 | /* 30 | * @desc Register sidebar shortcode 31 | * @since 3.0.0 32 | */ 33 | public function register_shortcode() { 34 | 35 | \add_shortcode( 'sidebar', array( $this, 'get_rendered_shortcode' ) ); 36 | 37 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'sidebar' ); 38 | 39 | cpb_register_shortcode( 40 | 'sidebar', 41 | $args = array( 42 | 'form_callback' => array( $this, 'get_shortcode_form' ), 43 | 'label' => 'Sidebar (Widgets)', // Label of the item 44 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 45 | 'default_atts' => $default_atts, 46 | 'in_column' => true, // Allow in column 47 | ) 48 | ); 49 | 50 | } // End register_shortcode 51 | 52 | 53 | /* 54 | * @desc Render the shortcode 55 | * @since 3.0.0 56 | * 57 | * @param array $atts Shortcode attributes 58 | * @param string $content Shortcode content 59 | * 60 | * @return string HTML shortcode output 61 | */ 62 | public function get_rendered_shortcode( $atts, $content ) { 63 | 64 | $html = ''; 65 | 66 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'sidebar' ); 67 | 68 | // Check default settings 69 | $atts = \shortcode_atts( $default_atts, $atts, 'sidebar' ); 70 | 71 | if ( ! empty( $atts['sidebar_id'] ) ) { 72 | 73 | ob_start(); 74 | 75 | dynamic_sidebar( $atts['sidebar_id'] ); 76 | 77 | $sidebar = ob_get_clean(); 78 | 79 | $html = do_shortcode( $sidebar ); 80 | 81 | } // end if 82 | 83 | return $html; 84 | 85 | } // End get_rendered_shortcode 86 | 87 | 88 | /* 89 | * @desc Get HTML for shortcode form 90 | * @since 3.0.0 91 | * 92 | * @param array $atts Shortcode attributes 93 | * @param string $content Shortcode content 94 | * 95 | * @return string HTML shortcode form output 96 | */ 97 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 98 | 99 | $cpb_form = cpb_get_form_class(); 100 | 101 | global $wp_registered_sidebars; 102 | 103 | $sidebars = array( 0 => 'None' ); 104 | 105 | foreach ( $wp_registered_sidebars as $sidebar ) { 106 | 107 | $sidebars[ $sidebar['id'] ] = $sidebar['name']; 108 | 109 | } // end foreach 110 | 111 | $form = $cpb_form->select_field( cpb_get_input_name( $id, true, 'sidebar_id' ), $settings['sidebar_id'], $sidebars, 'Select Sidebar' ); 112 | 113 | return $form; 114 | 115 | } // End get_shortcode_form 116 | 117 | } // End Sidebar 118 | 119 | $cpb_shortcode_sidebar = new Sidebar_Shortcode(); 120 | -------------------------------------------------------------------------------- /lib/shortcodes/image/class-image-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'img_id' => '', 20 | 'url' => '', 21 | 'alt' => '', 22 | ); 23 | 24 | 25 | public function __construct() { 26 | 27 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 28 | 29 | } // End __construct 30 | 31 | 32 | /* 33 | * @desc Register image shortcode 34 | * @since 3.0.0 35 | */ 36 | public function register_shortcode() { 37 | 38 | \add_shortcode( 'image', array( $this, 'get_rendered_shortcode' ) ); 39 | 40 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'image' ); 41 | 42 | cpb_register_shortcode( 43 | 'image', 44 | $args = array( 45 | 'form_callback' => array( $this, 'get_shortcode_form' ), 46 | 'label' => 'Image', // Label of the item 47 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 48 | 'default_atts' => $default_atts, 49 | 'in_column' => true, // Allow in column 50 | ) 51 | ); 52 | 53 | } // End register_shortcode 54 | 55 | 56 | /* 57 | * @desc Render the shortcode 58 | * @since 3.0.0 59 | * 60 | * @param array $atts Shortcode attributes 61 | * @param string $content Shortcode content 62 | * 63 | * @return string HTML shortcode output 64 | */ 65 | public function get_rendered_shortcode( $atts, $content ) { 66 | 67 | $html = ''; 68 | 69 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'image' ); 70 | 71 | // Check default settings 72 | $atts = \shortcode_atts( $default_atts, $atts, 'image' ); 73 | 74 | if ( ! empty( $atts['img_id'] ) ) { 75 | 76 | $image_array = cpb_get_image_properties_array( $atts['img_id'] ); 77 | 78 | if ( ! empty( $atts['alt'] ) ) { 79 | 80 | $image_array['alt'] = $atts['alt']; 81 | 82 | } // End if 83 | 84 | $url = $atts['url']; 85 | 86 | $img_src = $atts['img_src']; 87 | 88 | $alt = $image_array['alt']; 89 | 90 | ob_start(); 91 | 92 | include __DIR__ . '/image.php'; 93 | 94 | $html .= ob_get_clean(); 95 | 96 | } // End if 97 | 98 | return $html; 99 | 100 | } // End get_rendered_shortcode 101 | 102 | 103 | /* 104 | * @desc Get HTML for shortcode form 105 | * @since 3.0.0 106 | * 107 | * @param array $atts Shortcode attributes 108 | * @param string $content Shortcode content 109 | * 110 | * @return string HTML shortcode form output 111 | */ 112 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 113 | 114 | $cpb_form = cpb_get_form_class(); 115 | 116 | $form = $cpb_form->insert_media( cpb_get_input_name( $id, true ), $settings ); 117 | 118 | $form .= '
    '; 119 | 120 | $form .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'alt' ), $settings['alt'], 'Image Alt Text' ); 121 | 122 | $form .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'url' ), $settings['url'], 'Link Image To:' ); 123 | 124 | return $form; 125 | 126 | } // End get_shortcode_form 127 | 128 | } // End Image 129 | 130 | $cpb_shortcode_image = new Image_Shortcode(); 131 | -------------------------------------------------------------------------------- /lib/shortcodes/faq/class-faq-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'tag' => 'span', 20 | 'textcolor' => '', 21 | 'csshook' => '', 22 | ); 23 | 24 | 25 | public function __construct() { 26 | 27 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 28 | 29 | } // End __construct 30 | 31 | 32 | /* 33 | * @desc Register faq shortcode 34 | * @since 3.0.0 35 | */ 36 | public function register_shortcode() { 37 | 38 | \add_shortcode( 'faq', array( $this, 'get_rendered_shortcode' ) ); 39 | 40 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'faq' ); 41 | 42 | cpb_register_shortcode( 43 | 'faq', 44 | $args = array( 45 | 'form_callback' => array( $this, 'get_shortcode_form' ), 46 | 'label' => 'FAQ', // Label of the item 47 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 48 | 'default_atts' => $default_atts, 49 | 'in_column' => true, // Allow in column 50 | 'uses_wp_editor' => true, // Uses WP Editor 51 | ) 52 | ); 53 | 54 | } // End register_shortcode 55 | 56 | 57 | /* 58 | * @desc Render the shortcode 59 | * @since 3.0.0 60 | * 61 | * @param array $atts Shortcode attributes 62 | * @param string $content Shortcode content 63 | * 64 | * @return string HTML shortcode output 65 | */ 66 | public function get_rendered_shortcode( $atts, $content ) { 67 | 68 | $html = ''; 69 | 70 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'faq' ); 71 | 72 | // Check default settings 73 | $atts = \shortcode_atts( $default_atts, $atts, 'faq' ); 74 | 75 | $tag = $atts['tag']; 76 | 77 | $title = $atts['title']; 78 | 79 | $classes = $atts['csshook']; 80 | 81 | $content = apply_filters( 'cpb_the_content', \do_shortcode( $content ) ); 82 | 83 | \ob_start(); 84 | 85 | include __DIR__ . '/faq.php'; 86 | 87 | $html .= \ob_get_clean(); 88 | 89 | return $html; 90 | 91 | } // End get_rendered_shortcode 92 | 93 | 94 | /* 95 | * @desc Get HTML for shortcode form 96 | * @since 3.0.0 97 | * 98 | * @param array $atts Shortcode attributes 99 | * @param string $content Shortcode content 100 | * 101 | * @return string HTML shortcode form output 102 | */ 103 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 104 | 105 | $cpb_form = cpb_get_form_class(); 106 | 107 | $html = $cpb_form->text_field( cpb_get_input_name( $id, true, 'title' ), $settings['title'], 'Title' ); 108 | 109 | $html .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'tag' ), $settings['tag'], $cpb_form->get_header_tags( true ), 'Tag Type' ); 110 | 111 | ob_start(); 112 | 113 | wp_editor( $content, '_cpb_content_' . $id ); 114 | 115 | $html .= ob_get_clean(); 116 | 117 | $adv = $cpb_form->select_field( 118 | cpb_get_input_name( $id, true, 'textcolor' ), 119 | $settings['textcolor'], 120 | $cpb_form->get_wsu_colors(), 121 | 'Text Color' 122 | ); 123 | 124 | $adv .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'csshook' ), $settings['csshook'], 'CSS Hook' ); 125 | 126 | return array( 127 | 'Basic' => $html, 128 | 'Advanced' => $adv, 129 | ); 130 | 131 | } // End get_shortcode_form 132 | 133 | } // End _Shortcode 134 | 135 | $cpb_shortcode_faq = new FAQ_Shortcode(); 136 | -------------------------------------------------------------------------------- /lib/classes/class-rest-request.php: -------------------------------------------------------------------------------- 1 | 'post', 26 | 'base_url' => '', 27 | 'request_base' => 'wp-json/wp/v2', 28 | 'post_type' => 'posts', 29 | 'post_id' => '', 30 | 'taxonomy' => '', 31 | 'term_ids' => array(), 32 | 'per_page' => 10, 33 | 'set_cbp_post' => true, 34 | 'cache_request' => true, 35 | 'add_embed' => true, 36 | ); 37 | 38 | /* 39 | * @desc Build the post from passed data 40 | * @since 3.0.4 41 | * 42 | * @param array $args Args to pass along to the build 43 | */ 44 | public function __construct( $args = array() ) { 45 | 46 | $this->request_args = array_merge( $this->request_args, $args ); 47 | 48 | switch ( $this->request_args['request_type'] ) { 49 | 50 | case 'post': 51 | $this->do_post_request(); 52 | break; 53 | 54 | } // End switch 55 | 56 | } // End __construct 57 | 58 | 59 | protected function do_post_request() { 60 | 61 | $request_query = array( 62 | 'base_url' => $this->request_args['base_url'], 63 | 'request_base' => $this->request_args['request_base'], 64 | 'post_type' => $this->request_args['post_type'], 65 | 'post_id' => $this->request_args['post_id'], 66 | 'add_embed' => $this->request_args['add_embed'], 67 | 'params' => array( 68 | 'taxonomy' => $this->request_args['taxonomy'], 69 | 'term_ids' => $this->request_args['term_ids'], 70 | 'per_page' => $this->request_args['per_page'], 71 | ), 72 | ); 73 | 74 | $this->request_query = $request_query; 75 | 76 | $request_url = $this->get_request_url(); 77 | 78 | $response = wp_remote_get( $request_url ); 79 | 80 | if ( is_array( $response ) ) { 81 | 82 | $this->response_raw = $response; 83 | 84 | $this->response_body = wp_remote_retrieve_body( $response ); 85 | 86 | $this->response_array = json_decode( $this->response_body, true ); 87 | 88 | if ( is_array( $this->response_array ) && $this->request_args['set_cbp_post'] ) { 89 | 90 | include_once cpb_get_plugin_path( '/lib/classes/class-cpb-post.php' ); 91 | 92 | foreach ( $this->response_array as $index => $rest_response ) { 93 | 94 | $this->request_posts[] = new CPB_Post( $rest_response, 'rest-response' ); 95 | 96 | } // End foreach 97 | } // End if 98 | } // End if 99 | 100 | } // End do_post_request 101 | 102 | 103 | protected function get_request_url() { 104 | 105 | $url = $this->request_query['base_url'] . '/' . $this->request_query['request_base'] . '/' . $this->request_query['post_type']; 106 | 107 | $query_params = array( 108 | 'per_page' => $this->request_query['params']['per_page'], 109 | ); 110 | 111 | if ( ! empty( $this->request_query['post_id'] ) ) { 112 | 113 | $url .= '/' . $this->request_query['post_id']; 114 | 115 | } elseif ( ! empty( $this->request_query['params']['taxonomy'] ) ) { 116 | 117 | $taxonomy = $this->request_query['params']['taxonomy']; 118 | 119 | $terms = ( is_array( $this->request_query['params']['term_ids'] ) ) ? implode( ',', $this->request_query['params']['term_ids'] ) : $this->request_query['params']['term_ids']; 120 | 121 | $query_params[ $taxonomy ] = $terms; 122 | 123 | } 124 | 125 | $url .= '?' . http_build_query( $query_params ); 126 | 127 | if ( ! empty( $this->request_query['add_embed'] ) ) { 128 | 129 | $url .= '&_embed'; 130 | 131 | } // End if 132 | 133 | return $url; 134 | 135 | } // End get_request_url 136 | 137 | 138 | } // End REST_Request 139 | -------------------------------------------------------------------------------- /lib/shortcodes/action/class-action-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'link' => '#', 20 | 'textcolor' => '', 21 | 'csshook' => '', 22 | 'style' => '', 23 | 'caption' => '', 24 | ); 25 | 26 | 27 | public function __construct() { 28 | 29 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 30 | 31 | } // End __construct 32 | 33 | 34 | /* 35 | * @desc Register action shortcode 36 | * @since 3.0.0 37 | */ 38 | public function register_shortcode() { 39 | 40 | \add_shortcode( 'action', array( $this, 'get_rendered_shortcode' ) ); 41 | 42 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'action' ); 43 | 44 | cpb_register_shortcode( 45 | 'action', 46 | $args = array( 47 | 'form_callback' => array( $this, 'get_shortcode_form' ), 48 | 'label' => 'Action Button', // Label of the item 49 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 50 | 'default_atts' => $default_atts, 51 | 'in_column' => true, // Allow in column 52 | ) 53 | ); 54 | 55 | } // End register_shortcode 56 | 57 | 58 | /* 59 | * @desc Render the shortcode 60 | * @since 3.0.0 61 | * 62 | * @param array $atts Shortcode attributes 63 | * @param string $content Shortcode content 64 | * 65 | * @return string HTML shortcode output 66 | */ 67 | public function get_rendered_shortcode( $atts, $content ) { 68 | 69 | $html = ''; 70 | 71 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'action' ); 72 | 73 | // Check default settings 74 | $atts = \shortcode_atts( $default_atts, $atts, 'action' ); 75 | 76 | $class_array = array( 'cpb-action-button', 'cpb-action-button-item' ); 77 | 78 | if ( ! empty( $atts['style'] ) ) { 79 | 80 | $class_array[] = $atts['style']; 81 | 82 | } // End if 83 | 84 | if ( ! empty( $atts['caption'] ) ) { 85 | 86 | $class_array[] = 'has-caption'; 87 | 88 | } // End if 89 | 90 | if ( ! empty( $atts['csshook'] ) ) { 91 | 92 | $class_array[] = $atts['csshook']; 93 | 94 | } // End if 95 | 96 | $classes = implode( ' ', $class_array ); 97 | 98 | $link = $atts['link']; 99 | 100 | $label = $atts['label']; 101 | 102 | $caption = $atts['caption']; 103 | 104 | if ( ! empty( $label ) ) { 105 | 106 | \ob_start(); 107 | 108 | include __DIR__ . '/action.min.php'; 109 | 110 | $html .= \ob_get_clean(); 111 | 112 | } // End if 113 | 114 | return $html; 115 | 116 | } // End get_rendered_shortcode 117 | 118 | 119 | /* 120 | * @desc Get HTML for shortcode form 121 | * @since 3.0.0 122 | * 123 | * @param array $atts Shortcode attributes 124 | * @param string $content Shortcode content 125 | * 126 | * @return string HTML shortcode form output 127 | */ 128 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 129 | 130 | $cpb_form = cpb_get_form_class(); 131 | 132 | $styles = array( 133 | '' => 'None', 134 | 'in-page-action' => 'In Page Button', 135 | ); 136 | 137 | $html = ''; 138 | 139 | $adv = ''; 140 | 141 | $html .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'label' ), $settings['label'], 'Label' ); 142 | 143 | $html .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'link' ), $settings['link'], 'Link' ); 144 | 145 | $html .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'csshook' ), $settings['csshook'], 'CSS Hook' ); 146 | 147 | $html .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'style' ), $settings['style'], $styles, 'Style' ); 148 | 149 | $adv .= $cpb_form->textarea_field( cpb_get_input_name( $id, true, 'caption' ), $settings['caption'], 'Link Description' ); 150 | 151 | return array( 152 | 'Basic' => $html, 153 | 'Advanced' => $adv, 154 | ); 155 | 156 | } // End get_shortcode_form 157 | 158 | } // End Action 159 | 160 | $cpb_shortcode_action = new Action(); 161 | -------------------------------------------------------------------------------- /bin/install-wp-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ $# -lt 3 ]; then 4 | echo "usage: $0 [db-host] [wp-version] [skip-database-creation]" 5 | exit 1 6 | fi 7 | 8 | DB_NAME=$1 9 | DB_USER=$2 10 | DB_PASS=$3 11 | DB_HOST=${4-localhost} 12 | WP_VERSION=${5-latest} 13 | SKIP_DB_CREATE=${6-false} 14 | 15 | WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} 16 | WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/} 17 | 18 | download() { 19 | if [ `which curl` ]; then 20 | curl -s "$1" > "$2"; 21 | elif [ `which wget` ]; then 22 | wget -nv -O "$2" "$1" 23 | fi 24 | } 25 | 26 | if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then 27 | WP_TESTS_TAG="tags/$WP_VERSION" 28 | elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then 29 | WP_TESTS_TAG="trunk" 30 | else 31 | # http serves a single offer, whereas https serves multiple. we only want one 32 | download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json 33 | grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json 34 | LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') 35 | if [[ -z "$LATEST_VERSION" ]]; then 36 | echo "Latest WordPress version could not be found" 37 | exit 1 38 | fi 39 | WP_TESTS_TAG="tags/$LATEST_VERSION" 40 | fi 41 | 42 | set -ex 43 | 44 | install_wp() { 45 | 46 | if [ -d $WP_CORE_DIR ]; then 47 | return; 48 | fi 49 | 50 | mkdir -p $WP_CORE_DIR 51 | 52 | if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then 53 | mkdir -p /tmp/wordpress-nightly 54 | download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip 55 | unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/ 56 | mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR 57 | else 58 | if [ $WP_VERSION == 'latest' ]; then 59 | local ARCHIVE_NAME='latest' 60 | else 61 | local ARCHIVE_NAME="wordpress-$WP_VERSION" 62 | fi 63 | download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz 64 | tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR 65 | fi 66 | 67 | download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php 68 | } 69 | 70 | install_test_suite() { 71 | # portable in-place argument for both GNU sed and Mac OSX sed 72 | if [[ $(uname -s) == 'Darwin' ]]; then 73 | local ioption='-i .bak' 74 | else 75 | local ioption='-i' 76 | fi 77 | 78 | # set up testing suite if it doesn't yet exist 79 | if [ ! -d $WP_TESTS_DIR ]; then 80 | # set up testing suite 81 | mkdir -p $WP_TESTS_DIR 82 | svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes 83 | svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data 84 | fi 85 | 86 | if [ ! -f wp-tests-config.php ]; then 87 | download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php 88 | # remove all forward slashes in the end 89 | WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") 90 | sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php 91 | sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php 92 | sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php 93 | sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php 94 | sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php 95 | fi 96 | 97 | } 98 | 99 | install_db() { 100 | 101 | if [ ${SKIP_DB_CREATE} = "true" ]; then 102 | return 0 103 | fi 104 | 105 | # parse DB_HOST for port or socket references 106 | local PARTS=(${DB_HOST//\:/ }) 107 | local DB_HOSTNAME=${PARTS[0]}; 108 | local DB_SOCK_OR_PORT=${PARTS[1]}; 109 | local EXTRA="" 110 | 111 | if ! [ -z $DB_HOSTNAME ] ; then 112 | if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then 113 | EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" 114 | elif ! [ -z $DB_SOCK_OR_PORT ] ; then 115 | EXTRA=" --socket=$DB_SOCK_OR_PORT" 116 | elif ! [ -z $DB_HOSTNAME ] ; then 117 | EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" 118 | fi 119 | fi 120 | 121 | # create database 122 | mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA 123 | } 124 | 125 | install_wp 126 | install_test_suite 127 | install_db 128 | -------------------------------------------------------------------------------- /lib/includes/class-ajax.php: -------------------------------------------------------------------------------- 1 | check_nounce(); 32 | 33 | //@codingStandardsIgnoreStart Already checked nonce 34 | if ( ! empty( $_POST['service'] ) ) { 35 | 36 | switch ( $_POST['service'] ) { 37 | // @codingStandardsIgnoreEnd 38 | case 'get_part': 39 | $this->get_part(); 40 | break; 41 | 42 | case 'get_content': 43 | $this->request_content(); 44 | break; 45 | 46 | case 'get_style': 47 | $this->get_style(); 48 | break; 49 | 50 | case 'search_posts': 51 | break; 52 | 53 | case 'remote_request': 54 | break; 55 | 56 | } // end switch 57 | } // end service 58 | 59 | die(); 60 | 61 | } // End admin_ajax 62 | 63 | 64 | /* 65 | * @desc Get part from ajax request 66 | * @since 3.0.0 67 | * 68 | * @return json Part 69 | */ 70 | protected function get_part() { 71 | 72 | $json = array(); 73 | 74 | //@codingStandardsIgnoreStart Already checked nonce 75 | if ( ! empty( $_POST['slug'] ) ) { 76 | 77 | $slug = sanitize_text_field( $_POST['slug'] ); 78 | 79 | // TO DO: Need to sanitize this - use shortcode sanitize_callback 80 | $settings = ( ! empty( $_POST['settings'] ) ) ? $_POST['settings'] : array(); 81 | 82 | $content = ( ! empty( $_POST['content'] ) ) ? wp_kses_post( $_POST['content'] ) : ''; 83 | 84 | $get_children = ( isset( $_POST['get_children'] ) ) ? $_POST['get_children'] : true; 85 | // @codingStandardsIgnoreEnd 86 | 87 | $shortcode = cpb_get_shortcode( $slug, $settings, $content, $get_children ); 88 | 89 | if ( ! empty( $shortcode ) ) { 90 | 91 | $json['id'] = $shortcode['id']; 92 | 93 | $json['is_content'] = $shortcode['in_column']; 94 | 95 | $json['editor'] = cpb_get_editor_html( $shortcode ); 96 | 97 | $json['forms'] = cpb_get_shortcodes_editor_form_html( $shortcode ); 98 | 99 | } // End if 100 | } // End if 101 | 102 | header( 'Content-Type: application/json; charset=utf-8', true ); 103 | 104 | echo \wp_json_encode( $json ); 105 | 106 | } // End get_part 107 | 108 | 109 | protected function check_nounce() { 110 | 111 | //@codingStandardsIgnoreStart 112 | if ( empty( $_POST['ajax-post-id'] ) ) { 113 | 114 | die(); 115 | 116 | } 117 | 118 | $post_id = $_POST['ajax-post-id']; 119 | // @codingStandardsIgnoreEnd 120 | 121 | \check_ajax_referer( 'cahnrs_pb_ajax_' . $post_id, 'ajax-nonce' ); 122 | 123 | } 124 | 125 | 126 | protected function request_content() { 127 | 128 | \define( 'CWPPAGEBUILDER_IS_EDITOR', true ); 129 | 130 | $shortcodes = array(); 131 | 132 | //@codingStandardsIgnoreStart Already checked nonce 133 | if ( ! empty( $_POST['_cpb']['items'] ) ) { 134 | 135 | foreach ( $_POST['_cpb']['items'] as $id => $slug ) { 136 | 137 | if ( ! empty( $_POST['_cpb'][ $id ]['settings'] ) ) { 138 | 139 | $settings = $_POST['_cpb'][ $id ]['settings']; 140 | 141 | } else { 142 | 143 | $settings = array(); 144 | 145 | } // End if 146 | 147 | if ( ! empty( $_POST[ '_cpb_content_' . $id ] ) ) { 148 | 149 | $content = wp_kses_post( $_POST[ '_cpb_content_' . $id ] ); 150 | 151 | } else { 152 | 153 | $content = ''; 154 | 155 | }// End if 156 | // @codingStandardsIgnoreEnd 157 | 158 | $rendered_shortcode = cpb_get_rendered_shortcode( $slug, $settings, $content, true, true ); 159 | 160 | if ( $rendered_shortcode ) { 161 | 162 | $shortcodes[ $id ] = $rendered_shortcode; 163 | 164 | } // end if 165 | } // end foreach 166 | } // End if 167 | 168 | echo wp_json_encode( $shortcodes ); 169 | 170 | } // End request_content 171 | 172 | 173 | /* 174 | * @desc Get CSS to use in editor 175 | * @since 3.0.0 176 | * 177 | * @return string CSS to use in editor 178 | */ 179 | protected function get_style() { 180 | 181 | include cpb_get_plugin_path( '/lib/css/public.css' ); 182 | 183 | } // End get_style 184 | 185 | } // End AJAX 186 | 187 | $cpb_ajax = new AJAX(); 188 | -------------------------------------------------------------------------------- /lib/shortcodes/subtitle/class-subtitle-shortcode.php: -------------------------------------------------------------------------------- 1 | 'h2', 19 | 'title' => '', 20 | 'textcolor' => '', 21 | 'csshook' => '', 22 | 'anchor' => '', 23 | 'link' => '', 24 | 'style' => '', 25 | ); 26 | 27 | 28 | public function __construct() { 29 | 30 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 31 | 32 | } // End __construct 33 | 34 | 35 | /* 36 | * @desc Register subtitle shortcode 37 | * @since 3.0.0 38 | */ 39 | public function register_shortcode() { 40 | 41 | \add_shortcode( 'subtitle', array( $this, 'get_rendered_shortcode' ) ); 42 | 43 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'subtitle' ); 44 | 45 | cpb_register_shortcode( 46 | 'subtitle', 47 | $args = array( 48 | 'form_callback' => array( $this, 'get_shortcode_form' ), 49 | 'label' => 'Subtitle', // Label of the item 50 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 51 | 'default_atts' => $default_atts, 52 | 'in_column' => true, // Allow in column 53 | ) 54 | ); 55 | 56 | } // End register_shortcode 57 | 58 | 59 | /* 60 | * @desc Render the shortcode 61 | * @since 3.0.0 62 | * 63 | * @param array $atts Shortcode attributes 64 | * @param string $content Shortcode content 65 | * 66 | * @return string HTML shortcode output 67 | */ 68 | public function get_rendered_shortcode( $atts, $content ) { 69 | 70 | $html = ''; 71 | 72 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'subtitle' ); 73 | 74 | // Check default settings 75 | $atts = \shortcode_atts( $default_atts, $atts, 'subtitle' ); 76 | 77 | $classes_array = array( 'cpb-subtitle' ); 78 | 79 | if ( ! empty( $atts['style'] ) ) { 80 | 81 | $classes_array[] = $atts['style']; 82 | 83 | } // End if 84 | 85 | if ( ! empty( $atts['csshook'] ) ) { 86 | 87 | $classes_array[] = $atts['csshook']; 88 | 89 | } // End if 90 | 91 | if ( ! empty( $atts['textcolor'] ) ) { 92 | 93 | $classes_array[] = $atts['textcolor'] . '-text'; 94 | 95 | } // End if 96 | 97 | $classes = implode( ' ', $classes_array ); 98 | 99 | $tag = $atts['tag']; 100 | 101 | $title = $atts['title']; 102 | 103 | $anchor = $atts['anchor']; 104 | 105 | $link = $atts['link']; 106 | 107 | \ob_start(); 108 | 109 | include __DIR__ . '/subtitle.php'; 110 | 111 | $html .= \ob_get_clean(); 112 | 113 | return $html; 114 | 115 | } // End get_rendered_shortcode 116 | 117 | 118 | /* 119 | * @desc Get HTML for shortcode form 120 | * @since 3.0.0 121 | * 122 | * @param array $atts Shortcode attributes 123 | * @param string $content Shortcode content 124 | * 125 | * @return string HTML shortcode form output 126 | */ 127 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 128 | 129 | $cpb_form = cpb_get_form_class(); 130 | 131 | $styles = array( 132 | '' => 'None', 133 | 'underline-heading' => 'Underlined Heading', 134 | 'underline-heading small-heading' => 'Underlined Heading (small font)', 135 | ); 136 | 137 | $html = $cpb_form->text_field( cpb_get_input_name( $id, true, 'title' ), $settings['title'], 'Title' ); 138 | 139 | $html .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'tag' ), $settings['tag'], $cpb_form->get_header_tags(), 'Tag Type' ); 140 | 141 | $adv = $cpb_form->select_field( cpb_get_input_name( $id, true, 'textcolor' ), $settings['textcolor'], $cpb_form->get_wsu_colors(), 'Text Color' ); 142 | 143 | $adv .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'link' ), $settings['link'], 'Link' ); 144 | 145 | $adv .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'anchor' ), $settings['anchor'], 'Anchor Name' ); 146 | 147 | $adv .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'csshook' ), $settings['csshook'], 'CSS Hook' ); 148 | 149 | $adv .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'style' ), $settings['style'], $styles, 'Style' ); 150 | 151 | return array( 152 | 'Basic' => $html, 153 | 'Advanced' => $adv, 154 | ); 155 | 156 | } // End get_shortcode_form 157 | 158 | } // End Subtitle 159 | 160 | $cpb_shortcode_subtitle = new Subtitle_Shortcode(); 161 | -------------------------------------------------------------------------------- /lib/classes/class-shortcode-parser.php: -------------------------------------------------------------------------------- 1 | get_shortcode_regex( $allowed_shortcodes ); 42 | 43 | // Split content to account for malformed shortcodes 44 | $split_content = $this->split_content( $content, $regex ); 45 | 46 | // Loop through and add items 47 | foreach ( $split_content as $index => $shortcode_content ) { 48 | 49 | $trimmed_content = trim( $shortcode_content ); 50 | 51 | // Ignore empty if more than one set 52 | if ( empty( $trimmed_content ) && 1 < count( $split_content ) ) { 53 | 54 | continue; 55 | 56 | } // End if 57 | 58 | // Look for items 59 | \preg_match_all( $regex, $shortcode_content, $shortcode_data ); 60 | 61 | if ( ! empty( $shortcode_data[2] ) ) { // item found 62 | 63 | // Get the item 64 | $shortcode = cpb_get_shortcode( 65 | $shortcode_data[2][0], 66 | \shortcode_parse_atts( $shortcode_data[3][0] ), 67 | $shortcode_data[5][0] 68 | ); 69 | 70 | } elseif ( $default_shortcode ) { // no items found and default exists set default 71 | 72 | $shortcode = cpb_get_shortcode( $default_shortcode, array(), $shortcode_content ); 73 | 74 | } else { 75 | 76 | $shortcode = false; 77 | 78 | }// end if 79 | 80 | if ( $shortcode ) { 81 | 82 | $shortcodes[] = $shortcode; 83 | 84 | } // End if 85 | } // end foreach 86 | 87 | return $shortcodes; 88 | 89 | } // End get_shortcodes_from_content 90 | 91 | 92 | /* 93 | * @desc Get search regex for shortcode using built WP functions 94 | * @since 3.0.0 95 | * 96 | * @param array $allowed_shortcodes Shortcodes to look for 97 | * 98 | * @return string Search regex 99 | */ 100 | protected function get_shortcode_regex( $allowed_shortcodes ) { 101 | 102 | // Create empty array to populate later 103 | $slugs = array(); 104 | 105 | // Populate $slugs array with shortcode slugs as keys (needed for WP) 106 | foreach ( $allowed_shortcodes as $shortcode ) { 107 | 108 | $slugs[ $shortcode ] = true; 109 | 110 | } // end foreach 111 | 112 | // The keys from $shortcode_tags are used to populate the regex in parsing code 113 | global $shortcode_tags; 114 | 115 | // Temporarily write tags to temp 116 | $temp = $shortcode_tags; 117 | 118 | // @codingStandardsIgnoreStart Override with custom set 119 | $shortcode_tags = $slugs; 120 | 121 | // Get regex code using WP function 122 | $regex = \get_shortcode_regex(); 123 | 124 | $shortcode_tags = $temp; 125 | // @codingStandardsIgnoreEnd Set back to original 126 | 127 | $regex = '/' . $regex . '/'; 128 | 129 | return $regex; 130 | 131 | } // End get_shortcode_regex 132 | 133 | 134 | /* 135 | * @desc Split content by shortcode to account for malformed shortcodes 136 | * @since 3.0.0 137 | * 138 | * @param string $content Content to split 139 | * @param string $regex Regex to use in search 140 | * 141 | * @return array Content split by shortcode instance 142 | */ 143 | protected function split_content( $content, $regex ) { 144 | 145 | if ( '' === $content ) { 146 | 147 | $content = ' '; 148 | 149 | } // End if 150 | 151 | // Add Delimiter to content. This is required to account for content outside of shortcodes 152 | $content_set = \preg_replace_callback( 153 | 154 | $regex, function( $matches ) { 155 | 156 | return '|$|' . $matches[0] . '|$|'; 157 | 158 | }, 159 | $content 160 | ); 161 | 162 | // Split into an array of content and shortcodes 163 | $content_set = \explode( '|$|', $content_set ); 164 | 165 | return $content_set; 166 | 167 | } // End split_content 168 | 169 | 170 | } // End Shortcode_Parser 171 | -------------------------------------------------------------------------------- /lib/shortcodes/slideshow/class-slideshow-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'display_type' => 'gallery-slideshow', 20 | ); 21 | 22 | 23 | public function __construct() { 24 | 25 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 26 | 27 | } // End __construct 28 | 29 | 30 | /* 31 | * @desc Register slideshow shortcode 32 | * @since 3.0.0 33 | */ 34 | public function register_shortcode() { 35 | 36 | \add_shortcode( 'slideshow', array( $this, 'get_rendered_shortcode' ) ); 37 | 38 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'slideshow' ); 39 | 40 | cpb_register_shortcode( 41 | 'slideshow', 42 | $args = array( 43 | 'form_callback' => array( $this, 'get_shortcode_form' ), 44 | 'editor_callback' => array( $this, 'get_shortcode_editor' ), // Callback to render form 45 | 'allowed_children' => array( 'slide' ), // Allowed child shortcodes 46 | 'default_shortcode' => 'slide', // Default to this if no children 47 | 'label' => 'Slideshow', // Label of the item 48 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 49 | 'default_atts' => $default_atts, 50 | 'in_column' => true, // Allow in column 51 | ) 52 | ); 53 | 54 | } // End register_shortcode 55 | 56 | 57 | /* 58 | * @desc Render the shortcode 59 | * @since 3.0.0 60 | * 61 | * @param array $atts Shortcode attributes 62 | * @param string $content Shortcode content 63 | * 64 | * @return string HTML shortcode output 65 | */ 66 | public function get_rendered_shortcode( $atts, $content ) { 67 | 68 | $html = ''; 69 | 70 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'slideshow' ); 71 | 72 | // Check default settings 73 | $atts = \shortcode_atts( $default_atts, $atts, 'slideshow' ); 74 | 75 | global $cpb_slideshow; 76 | 77 | $cpb_slideshow = array( 78 | 'type' => $atts['display_type'], 79 | 'i' => 1, 80 | ); 81 | 82 | $slides = do_shortcode( $content ); 83 | 84 | \ob_start(); 85 | 86 | include __DIR__ . '/slideshow.php'; 87 | 88 | $html = \ob_get_clean(); 89 | 90 | return $html; 91 | 92 | } // End get_rendered_shortcode 93 | 94 | 95 | /* 96 | * @desc Get HTML for shortcode form 97 | * @since 3.0.0 98 | * 99 | * @param array $atts Shortcode attributes 100 | * @param string $content Shortcode content 101 | * 102 | * @return string HTML shortcode form output 103 | */ 104 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 105 | 106 | $cpb_form = cpb_get_form_class(); 107 | 108 | $displays = array( 109 | 'default' => 'Default', 110 | 'college' => 'College', 111 | ); 112 | 113 | $html = $cpb_form->text_field( cpb_get_input_name( $id, true, 'title' ), $settings['title'], 'Title' ); 114 | 115 | $html .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'display_type' ), $settings['display_type'], $displays, 'Display Type' ); 116 | 117 | return array( 'Basic' => $html ); 118 | 119 | } // End get_shortcode_form 120 | 121 | 122 | /* 123 | * @desc Get HTML for shortcode editor 124 | * @since 3.0.0 125 | * 126 | * @param string $id Shortcode id 127 | * @param array $atts Shortcode attributes 128 | * @param string $content Shortcode content 129 | * @param string $children Shortcode children 130 | * 131 | * @return string HTML shortcode form output 132 | */ 133 | public function get_shortcode_editor( $id, $atts, $content, $children ) { 134 | 135 | $slug = 'slideshow'; 136 | 137 | // Get the editor content 138 | $editor_content = cpb_get_editor_html( $children ); 139 | 140 | // Get the input name 141 | $input_name = cpb_get_input_name( $id ); 142 | 143 | // Get the child keys 144 | $child_keys = cpb_get_child_shortcode_ids( $children ); 145 | 146 | // implode the child keys 147 | $child_keys = \implode( ',', $child_keys ); 148 | 149 | // Get the edit button 150 | $edit_button = cpb_get_editor_edit_button(); 151 | 152 | // Get the remove button 153 | $remove_button = cpb_get_editor_remove_button(); 154 | 155 | // Start output buffer 156 | \ob_start(); 157 | 158 | // Include the html 159 | include __DIR__ . '/slideshow-editor.php'; 160 | 161 | // Get the html 162 | $html = \ob_get_clean(); 163 | 164 | return $html; 165 | 166 | } // End get_shortcode_form 167 | 168 | } // End Slideshow 169 | 170 | $cpb_shortcode_slideshow = new Slideshow_Shortcode(); 171 | -------------------------------------------------------------------------------- /lib/includes/class-shortcodes.php: -------------------------------------------------------------------------------- 1 | add_content_filter(); 19 | 20 | // Add shrotcodes 21 | $this->add_shortcodes(); 22 | 23 | // Add Registered shortcodes via filter 24 | \add_action( 'init', array( $this, 'register_shortcodes' ), 99 ); 25 | 26 | \add_action( 'init', array( $this, 'check_pre_filter' ), 99 ); 27 | 28 | } // End __construct 29 | 30 | 31 | /** 32 | * @desc Check if set to use pre-filter 33 | * @since 3.0.5 34 | */ 35 | public function check_pre_filter() { 36 | 37 | if ( get_theme_mod( 'cpb_pre_filter', '' ) ) { 38 | 39 | add_filter( 'the_content', array( $this, 'do_remove_p' ), 1 ); 40 | 41 | } // End if 42 | 43 | } // End check_pre_filter 44 | 45 | 46 | /* 47 | * @desc Removes extra p that WordPress likes to add 48 | * @since 3.0.0 49 | * 50 | * @param string $content Post content 51 | * 52 | * @return string Post content with shortcodes built out 53 | */ 54 | public function do_remove_p( $content ) { 55 | 56 | remove_filter( 'the_content', array( $this, 'do_remove_p' ), 1 ); 57 | 58 | $content = do_shortcode( $content ); 59 | 60 | return $content; 61 | 62 | } // End do_remove_p 63 | 64 | 65 | /* 66 | * @desc Add custom the_content filters to avoid abuse 67 | * @since 3.0.0 68 | */ 69 | protected function add_content_filter() { 70 | 71 | add_filter( 'cpb_the_content', 'wptexturize' ); 72 | add_filter( 'cpb_the_content', 'convert_smilies' ); 73 | add_filter( 'cpb_the_content', 'convert_chars' ); 74 | add_filter( 'cpb_the_content', 'wpautop' ); 75 | add_filter( 'cpb_the_content', 'shortcode_unautop' ); 76 | add_filter( 'cpb_the_content', 'prepend_attachment' ); 77 | 78 | } // End add_content_filter 79 | 80 | 81 | /* 82 | * @desc Register shortcodes use in cpb 83 | * @since 3.0.0 84 | */ 85 | public function register_shortcodes() { 86 | 87 | /* 88 | * Shortcodes can be added via cpb_shortcode filter or 89 | * the cpb_register_shortcode() (lib/functions/public.php) function 90 | */ 91 | $register_shortcodes = \apply_filters( 'cpb_shortcodes', array() ); 92 | 93 | if ( ! empty( $register_shortcodes ) ) { 94 | 95 | foreach ( $register_shortcodes as $slug => $args ) { 96 | 97 | cpb_register_shortcode( $slug, $args ); 98 | 99 | } // End foreach 100 | } // End if 101 | 102 | } // End add_shortcodes 103 | 104 | /* 105 | * @desc Add built in Shortcodes 106 | * @since 3.0.0 107 | */ 108 | protected function add_shortcodes() { 109 | 110 | // Add row Shortcode 111 | include_once cpb_get_plugin_path( '/lib/shortcodes/row/class-row-shortcode.php' ); 112 | 113 | // Add column Shortcode 114 | include_once cpb_get_plugin_path( '/lib/shortcodes/column/class-column-shortcode.php' ); 115 | 116 | // Add textblock Shortcode 117 | include_once cpb_get_plugin_path( '/lib/shortcodes/textblock/class-textblock-shortcode.php' ); 118 | 119 | // Add Image shortcode 120 | include_once cpb_get_plugin_path( '/lib/shortcodes/subtitle/class-subtitle-shortcode.php' ); 121 | 122 | // Add action Shortcode 123 | include_once cpb_get_plugin_path( '/lib/shortcodes/action/class-action-shortcode.php' ); 124 | 125 | // Add Image shortcode 126 | include_once cpb_get_plugin_path( '/lib/shortcodes/promo/class-promo-shortcode.php' ); 127 | 128 | // Add Image shortcode 129 | include_once cpb_get_plugin_path( '/lib/shortcodes/social/class-social-shortcode.php' ); 130 | 131 | // Add Content Feed Shortcode 132 | include_once cpb_get_plugin_path( '/lib/shortcodes/content-feed/class-content-feed-shortcode.php' ); 133 | 134 | // Add FAQ shortcode 135 | include_once cpb_get_plugin_path( '/lib/shortcodes/faq/class-faq-shortcode.php' ); 136 | 137 | // Add Figure Caption shortcode 138 | include_once cpb_get_plugin_path( '/lib/shortcodes/figure/class-figure-shortcode.php' ); 139 | 140 | // Add Image shortcode 141 | include_once cpb_get_plugin_path( '/lib/shortcodes/image/class-image-shortcode.php' ); 142 | 143 | // Add Image shortcode 144 | include_once cpb_get_plugin_path( '/lib/shortcodes/list/class-list-shortcode.php' ); 145 | 146 | // Add Image shortcode 147 | include_once cpb_get_plugin_path( '/lib/shortcodes/post-gallery/class-post-gallery-shortcode.php' ); 148 | 149 | // Add Image shortcode 150 | include_once cpb_get_plugin_path( '/lib/shortcodes/sidebar/class-sidebar-shortcode.php' ); 151 | 152 | // Add Image shortcode 153 | include_once cpb_get_plugin_path( '/lib/shortcodes/slide/class-slide-shortcode.php' ); 154 | 155 | // Add Image shortcode 156 | include_once cpb_get_plugin_path( '/lib/shortcodes/slideshow/class-slideshow-shortcode.php' ); 157 | 158 | // Add Image shortcode 159 | include_once cpb_get_plugin_path( '/lib/shortcodes/table/class-table-shortcode.php' ); 160 | 161 | // Add Image shortcode 162 | include_once cpb_get_plugin_path( '/lib/shortcodes/video/class-video-shortcode.php' ); 163 | 164 | // Add Image shortcode 165 | include_once cpb_get_plugin_path( '/lib/shortcodes/tabs/class-tabs-shortcode.php' ); 166 | 167 | // Add Image shortcode 168 | include_once cpb_get_plugin_path( '/lib/shortcodes/az-index/class-az-index-shortcode.php' ); 169 | 170 | } // End add_shortcodes 171 | 172 | 173 | } // End Editor 174 | 175 | $cpb_shortcodes = new Shortcodes(); 176 | -------------------------------------------------------------------------------- /lib/shortcodes/textblock/class-textblock-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'bgcolor' => '', 20 | 'textcolor' => '', 21 | 'csshook' => '', 22 | 'list_style' => '', 23 | 'title' => '', 24 | ); 25 | 26 | 27 | public function __construct() { 28 | 29 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 30 | 31 | } // End __construct 32 | 33 | 34 | /* 35 | * @desc Register textblock shortcode 36 | * @since 3.0.0 37 | */ 38 | public function register_shortcode() { 39 | 40 | \add_shortcode( 'textblock', array( $this, 'get_rendered_shortcode' ) ); 41 | 42 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'textblock' ); 43 | 44 | cpb_register_shortcode( 45 | 'textblock', 46 | $args = array( 47 | 'form_callback' => array( $this, 'get_shortcode_form' ), 48 | 'label' => 'Textblock', // Label of the item 49 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 50 | 'default_atts' => $default_atts, 51 | 'in_column' => true, // Allow in column 52 | 'uses_wp_editor' => true, // Uses WP Editor 53 | ) 54 | ); 55 | 56 | } // End register_shortcode 57 | 58 | 59 | /* 60 | * @desc Render the shortcode 61 | * @since 3.0.0 62 | * 63 | * @param array $atts Shortcode attributes 64 | * @param string $content Shortcode content 65 | * 66 | * @return string HTML shortcode output 67 | */ 68 | public function get_rendered_shortcode( $atts, $content ) { 69 | 70 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'textblock' ); 71 | 72 | // Check default settings 73 | $settings = \shortcode_atts( $default_atts, $atts, 'textblock' ); 74 | 75 | $content = do_shortcode( $this->get_more_content( $content, $settings ) ); 76 | 77 | //$content = apply_filters( 'cpb_the_content', $content ); 78 | 79 | //TO DO: Need to work out applying the content filter here 80 | 81 | // Set textblock classes 82 | $classes = $this->get_textblock_classes( $settings ); 83 | 84 | $prefix = $this->prefix; 85 | 86 | \ob_start(); 87 | 88 | include __DIR__ . '/textblock.php'; 89 | 90 | $html = \ob_get_clean(); 91 | 92 | return $html; 93 | 94 | } // End get_rendered_shortcode 95 | 96 | 97 | /* 98 | * @desc Get HTML for shortcode form 99 | * @since 3.0.0 100 | * 101 | * @param array $atts Shortcode attributes 102 | * @param string $content Shortcode content 103 | * 104 | * @return string HTML shortcode form output 105 | */ 106 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 107 | 108 | $cpb_form = cpb_get_form_class(); 109 | 110 | $style_array = array( 111 | '' => 'Default', 112 | 'list-style-arrows' => 'Arrows', 113 | 'list-style-drop-down' => 'Accordion', 114 | ); 115 | 116 | $html = $cpb_form->text_field( cpb_get_input_name( $id, true, 'title' ), $settings['title'], 'Title' ); 117 | 118 | ob_start(); 119 | 120 | wp_editor( $content, '_cpb_content_' . $id ); 121 | 122 | $html .= ob_get_clean(); 123 | 124 | $adv = $cpb_form->select_field( cpb_get_input_name( $id, true, 'textcolor' ), $settings['textcolor'], $cpb_form->get_wsu_colors(), 'Text Color' ); 125 | 126 | $adv .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'bgcolor' ), $settings['bgcolor'], $cpb_form->get_wsu_colors(), 'Background Color' ); 127 | 128 | $adv .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'list_style' ), $settings['list_style'], $style_array, 'List Style' ); 129 | 130 | $adv .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'is_callout' ), 1, $settings['is_callout'], 'Is Callout' ); 131 | 132 | $adv .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'csshook' ), $settings['csshook'], 'CSS Hook' ); 133 | 134 | return array( 135 | 'Basic' => $html, 136 | 'Advanced' => $adv, 137 | ); 138 | 139 | } // End get_shortcode_form 140 | 141 | 142 | /* 143 | * @desc Get textblock classes 144 | * @since 3.0.0 145 | * 146 | * @param array $settings Textblock attributes 147 | * 148 | * @return string Textblock classes 149 | */ 150 | private function get_textblock_classes( $settings ) { 151 | 152 | $class = array(); 153 | 154 | if ( ! empty( $settings['textcolor'] ) ) { 155 | 156 | $class[] = $settings['textcolor'] . '-text'; 157 | 158 | } // End if 159 | 160 | if ( ! empty( $settings['is_callout'] ) ) { 161 | 162 | $class[] = 'is-callout'; 163 | 164 | } // End if 165 | 166 | if ( ! empty( $settings['csshook'] ) ) { 167 | 168 | $class[] = $settings['csshook']; 169 | 170 | } // End if 171 | 172 | if ( ! empty( $settings['bgcolor'] ) ) { 173 | 174 | $class[] = $settings['bgcolor'] . '-back'; 175 | 176 | } // End if 177 | 178 | if ( ! empty( $settings['list_style'] ) ) { 179 | 180 | $class[] = $settings['list_style']; 181 | 182 | } // End if 183 | 184 | return implode( ' ', $class ); 185 | 186 | } // End get_item_class 187 | 188 | 189 | /* 190 | * @desc Split content by more span 191 | * @since 3.0.0 192 | * 193 | * @param array $settings Textblock attributes 194 | * 195 | * @return array Textblock css 196 | */ 197 | private function get_more_content( $content, $settings ) { 198 | 199 | $temp_id = 'textblock-' . uniqid(); 200 | 201 | if ( strpos( $content, '<\/span>/', $content ); 204 | 205 | $link = ''; 206 | 207 | $new_content = '
    '; 208 | 209 | $new_content .= '
    ' . $content_parts[0] . '
    '; 210 | 211 | $new_content .= '
    ' . $content_parts[1] . '
    '; 212 | 213 | $new_content .= $link . '
    '; 214 | 215 | $content = $new_content; 216 | 217 | } // end if 218 | 219 | return $content; 220 | 221 | } // end get_more_content 222 | 223 | } // End Textblock 224 | 225 | $cpb_shortcode_textblock = new Textblock(); 226 | -------------------------------------------------------------------------------- /lib/shortcodes/tabs/class-tabs-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'csshook' => '', 20 | 'textcolor' => '', 21 | 'min_height' => '', 22 | 'tag' => '', 23 | 'anchor' => '', 24 | ); 25 | 26 | 27 | public function __construct() { 28 | 29 | $fields = array(); 30 | 31 | for ( $i = 1; $i < 6; $i++ ) { 32 | 33 | $fields[ 'tab' . $i . '_title' ] = ''; 34 | $fields[ 'tab' . $i . '_url' ] = ''; 35 | $fields[ 'tab' . $i . '_posts' ] = ''; 36 | $fields[ 'tab' . $i . '_bgcolor' ] = ''; 37 | $fields[ 'tab' . $i . '_img_src' ] = ''; 38 | $fields[ 'tab' . $i . '_img_id' ] = ''; 39 | 40 | } // End for 41 | 42 | $this->default_settings = array_merge( $this->default_settings, $fields ); 43 | 44 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 45 | 46 | } // End __construct 47 | 48 | 49 | /* 50 | * @desc Register cpbtabs shortcode 51 | * @since 3.0.0 52 | */ 53 | public function register_shortcode() { 54 | 55 | \add_shortcode( 'cpbtabs', array( $this, 'get_rendered_shortcode' ) ); 56 | 57 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'cpbtabs' ); 58 | 59 | cpb_register_shortcode( 60 | 'cpbtabs', 61 | $args = array( 62 | 'form_callback' => array( $this, 'get_shortcode_form' ), 63 | 'label' => 'Tabs', // Label of the item 64 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 65 | 'default_atts' => $default_atts, 66 | 'in_column' => true, // Allow in column 67 | ) 68 | ); 69 | 70 | } // End register_shortcode 71 | 72 | 73 | /* 74 | * @desc Render the shortcode 75 | * @since 3.0.0 76 | * 77 | * @param array $atts Shortcode attributes 78 | * @param string $content Shortcode content 79 | * 80 | * @return string HTML shortcode output 81 | */ 82 | public function get_rendered_shortcode( $atts, $content ) { 83 | 84 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'cpbtabs' ); 85 | 86 | // Check default settings 87 | $atts = \shortcode_atts( $default_atts, $atts, 'cpbtabs' ); 88 | 89 | $html = '
    '; 90 | 91 | $tabs = array(); 92 | 93 | for ( $i = 1; $i < 6; $i++ ) { 94 | 95 | $prefix = 'tab' . $i; 96 | 97 | if ( ! empty( $atts[ $prefix . '_title' ] ) ) { 98 | 99 | $tab = array( 100 | 'tag' => ( ! empty( $atts['tag'] ) ) ? $atts['tag'] : 'h2', 101 | 'title' => $atts[ $prefix . '_title' ], 102 | 'url' => ( ! empty( $atts[ $prefix . '_url' ] ) ) ? $atts[ $prefix . '_url' ] : '', 103 | 'posts' => ( ! empty( $atts[ $prefix . '_posts' ] ) ) ? $atts[ $prefix . '_posts' ] : '', 104 | 'bgcolor' => ( ! empty( $atts[ $prefix . '_bgcolor' ] ) ) ? $atts[ $prefix . '_bgcolor' ] : '', 105 | 'bgimage' => ( ! empty( $atts[ $prefix . '_img_src' ] ) ) ? $atts[ $prefix . '_img_src' ] : '', 106 | ); 107 | 108 | $tabs[ $prefix ] = $tab; 109 | 110 | } // End if 111 | } // End for 112 | 113 | $display = ( ! empty( $atts['display'] ) ) ? $atts['display'] : 'basic'; 114 | 115 | switch ( $display ) { 116 | 117 | case 'columns': 118 | $html .= $this->get_display_columns( $tabs, $atts, $content ); 119 | break; 120 | 121 | default: 122 | break; 123 | 124 | } // End switch 125 | 126 | return $html . '
    '; 127 | 128 | } // End get_rendered_shortcode 129 | 130 | 131 | protected function get_display_columns( $tabs, $settings, $content ) { 132 | 133 | \ob_start(); 134 | 135 | include __DIR__ . '/column-tabs.php'; 136 | 137 | $html = \ob_get_clean(); 138 | 139 | return $html; 140 | 141 | } // End get_display_columns 142 | 143 | 144 | /* 145 | * @desc Get HTML for shortcode form 146 | * @since 3.0.0 147 | * 148 | * @param array $atts Shortcode attributes 149 | * @param string $content Shortcode content 150 | * 151 | * @return string HTML shortcode form output 152 | */ 153 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 154 | 155 | $cpb_form = cpb_get_form_class(); 156 | 157 | $posts = cpb_get_public_posts( array(), true, true ); 158 | 159 | $html = ''; 160 | 161 | $tags = $cpb_form->get_header_tags(); 162 | 163 | unset( $tags['strong'] ); 164 | 165 | $html .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'tag' ), $settings['tag'], $tags, 'Tag Type' ); 166 | 167 | for ( $i = 1; $i < 6; $i++ ) { 168 | 169 | $html .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'tab' . $i . '_title' ), $settings[ 'tab' . $i . '_title' ], 'Tab ' . $i . ' Title' ); 170 | 171 | $html .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'tab' . $i . '_url' ), $settings[ 'tab' . $i . '_url' ], 'Tab ' . $i . ' Link' ); 172 | 173 | $html .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'tab' . $i . '_posts' ), $settings[ 'tab' . $i . '_posts' ], $posts, 'Tab ' . $i . ' Content' ); 174 | 175 | $html .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'tab' . $i . '_bgcolor' ), $settings[ 'tab' . $i . '_bgcolor' ], $cpb_form->get_wsu_colors(), 'Tab ' . $i . ' Background Color' ); 176 | 177 | $html .= $cpb_form->insert_media( cpb_get_input_name( $id, true ), $settings, '', 'tab' . $i . '_' ); 178 | 179 | } // End for 180 | 181 | $displays = array( 182 | 'basic' => 'Basic', 183 | 'columns' => 'Columns', 184 | ); 185 | 186 | $adv = ''; 187 | 188 | $adv .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'display' ), $settings['display'], $displays, 'Display' ); 189 | 190 | $adv .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'min_height' ), $settings['min_height'], 'Minimum Height' ); 191 | 192 | $adv .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'textcolor' ), $settings['textcolor'], $cpb_form->get_wsu_colors(), 'Text Color' ); 193 | 194 | $adv .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'anchor' ), $settings['anchor'], 'Anchor Name' ); 195 | 196 | $adv .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'csshook' ), $settings['csshook'], 'CSS Hook' ); 197 | 198 | return array( 199 | 'Basic' => $html, 200 | 'Advanced' => $adv, 201 | ); 202 | 203 | } // End get_shortcode_form 204 | 205 | } // End Tabs 206 | 207 | $cpb_shortcode_cpbtabs = new Tabs_Shortcode(); 208 | -------------------------------------------------------------------------------- /lib/shortcodes/video/class-video-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'vid_type' => '', 20 | 'vid_summary' => '' 21 | ); 22 | 23 | 24 | public function __construct() { 25 | 26 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 27 | 28 | } // End __construct 29 | 30 | 31 | /* 32 | * @desc Register video shortcode 33 | * @since 3.0.0 34 | */ 35 | public function register_shortcode() { 36 | 37 | \add_shortcode( 'video', array( $this, 'get_rendered_shortcode' ) ); 38 | 39 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'video' ); 40 | 41 | cpb_register_shortcode( 42 | 'video', 43 | $args = array( 44 | 'form_callback' => array( $this, 'get_shortcode_form' ), 45 | 'label' => 'Video', // Label of the item 46 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 47 | 'editor_render_callback' => array( $this, 'get_editor_content' ), // Callback to render shortcode 48 | 'default_atts' => $default_atts, 49 | 'in_column' => true, // Allow in column 50 | ) 51 | ); 52 | 53 | } // End register_shortcode 54 | 55 | 56 | /* 57 | * @desc Render the shortcode 58 | * @since 3.0.0 59 | * 60 | * @param array $atts Shortcode attributes 61 | * @param string $content Shortcode content 62 | * 63 | * @return string HTML shortcode output 64 | */ 65 | public function get_rendered_shortcode( $atts, $content ) { 66 | 67 | $html = ''; 68 | 69 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'video' ); 70 | 71 | // Check default settings 72 | $atts = \shortcode_atts( $default_atts, $atts, 'video' ); 73 | 74 | if ( ! empty( $atts['vid_id'] ) ) { 75 | 76 | $html .= '
    '; 77 | 78 | switch ( $atts['vid_type'] ) { 79 | 80 | case 'vimeo': 81 | $video_id = $atts['vid_id']; 82 | $video_summary = $this->get_video_id_from_url( $atts['vid_summary'] ); 83 | ob_start(); 84 | include __DIR__ . '/vimeo-video.php'; 85 | $html .= ob_get_clean(); 86 | break; 87 | default: 88 | $video_id = $this->get_video_id_from_url( $atts['vid_id'] ); 89 | $video_summary = $this->get_video_id_from_url( $atts['vid_summary'] ); 90 | ob_start(); 91 | include __DIR__ . '/youtube-video.php'; 92 | $html .= ob_get_clean(); 93 | break; 94 | } // end switch 95 | 96 | $html .= '
    '; 97 | 98 | } // End if 99 | 100 | return $html; 101 | 102 | } // End get_rendered_shortcode 103 | 104 | 105 | /* 106 | * @desc Override dhe editor content view 107 | * @since 3.0.0 108 | * 109 | * @param array $settings Shortode atts 110 | * @param string $content Shortcode content 111 | * 112 | * @return string HTML for use in Editor 113 | */ 114 | public function get_editor_content( $settings, $content ) { 115 | 116 | $html = ''; 117 | 118 | if ( ! empty( $settings['vid_id'] ) ) { 119 | 120 | if ( 'youtube' === $settings['vid_type'] ) { 121 | 122 | $video_id = $this->get_video_id_from_url( $settings['vid_id'] ); 123 | 124 | $src = 'http://img.youtube.com/vi/' . $video_id . '/default.jpg'; 125 | 126 | } else { 127 | 128 | $src = ''; 129 | 130 | } // end if 131 | 132 | $vid_style = 'background-image:url( ' . $src . ' );background-position: center center;background-size:cover;'; 133 | 134 | } else { 135 | 136 | $vid_style = ''; 137 | 138 | } // end if 139 | 140 | $html .= ''; 141 | 142 | //$html .= '
    '; 143 | 144 | return $html; 145 | 146 | } // end admin_item 147 | 148 | 149 | /* 150 | * @desc - Extracts video id from url 151 | * @since 3.0.0 152 | * 153 | * @return string - The video id. 154 | */ 155 | protected function get_video_id_from_url( $url ) { 156 | 157 | $video_id = $url; 158 | 159 | if ( strpos( $url, 'watch?v=' ) ) { 160 | 161 | $url = explode( 'watch?v=', $url ); 162 | 163 | $video_id = $url[1]; 164 | 165 | } elseif ( strpos( $url, '.be/' ) ) { //https://youtu.be/nkXGohB02V0 166 | 167 | $url = explode( '.be/', $url ); 168 | 169 | $video_id = $url[1]; 170 | 171 | } // End if 172 | 173 | return $video_id; 174 | 175 | } // end cwp_get_video_id_from_url 176 | 177 | 178 | /* 179 | * @desc Get HTML for shortcode form 180 | * @since 3.0.0 181 | * 182 | * @param array $atts Shortcode attributes 183 | * @param string $content Shortcode content 184 | * 185 | * @return string HTML shortcode form output 186 | */ 187 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 188 | 189 | $cpb_form = cpb_get_form_class(); 190 | 191 | $form_custom = '
    '; 192 | 193 | if($settings['vid_type'] == 'youtube'){ 194 | $form_custom .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'vid_id' ), $settings['vid_id'], 'YouTube Video ID' ); 195 | }else{ 196 | $form_custom .= $cpb_form->text_field( cpb_get_input_name( $id, true, 'vid_id' ), $settings['vid_id'], 'Vimeo Video ID' ); 197 | } 198 | 199 | $form_custom .= $cpb_form->textarea_field( cpb_get_input_name( $id, true, 'vid_summary' ), $settings['vid_summary'], 'Video Description', 'cpb-full-width' ); 200 | 201 | 202 | $form_custom .= '
    '; 203 | 204 | $youtube_form = array( 205 | 'name' => cpb_get_input_name( $id, true, 'vid_type' ), 206 | 'value' => 'youtube', 207 | 'selected' => $settings['vid_type'], 208 | 'title' => 'YouTube Video', 209 | 'desc' => 'Display YouTube video by ID', 210 | 'form' => $form_custom, 211 | ); 212 | 213 | $vimeo_form = array( 214 | 'name' => cpb_get_input_name( $id, true, 'vid_type' ), 215 | 'value' => 'vimeo', 216 | 'selected' => $settings['vid_type'], 217 | 'title' => 'Vimeo Video', 218 | 'desc' => 'Display Vimeo video by ID', 219 | 'form' => $form_custom, 220 | ); 221 | 222 | $html = $cpb_form->multi_form( array( $youtube_form, $vimeo_form ) ); 223 | 224 | return $html; 225 | 226 | } // End get_shortcode_form 227 | 228 | } // End Video 229 | 230 | $cpb_shortcode_video = new Video_Shortcode(); 231 | -------------------------------------------------------------------------------- /lib/shortcodes/az-index/class-az-index-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | ); 20 | 21 | 22 | public function __construct() { 23 | 24 | $local_query_defaults = cpb_get_local_query_defaults(); 25 | 26 | $remote_query_defaults = cpb_get_remote_query_defaults(); 27 | 28 | $this->default_settings = array_merge( 29 | $this->default_settings, 30 | $local_query_defaults, 31 | $remote_query_defaults 32 | ); 33 | 34 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 35 | 36 | } // End __construct 37 | 38 | 39 | /* 40 | * @desc Register az_index shortcode 41 | * @since 3.0.1 42 | */ 43 | public function register_shortcode() { 44 | 45 | \add_shortcode( 'az_index', array( $this, 'get_rendered_shortcode' ) ); 46 | 47 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'az_index' ); 48 | 49 | cpb_register_shortcode( 50 | 'az_index', 51 | $args = array( 52 | 'form_callback' => array( $this, 'get_shortcode_form' ), 53 | 'label' => 'AZ Index', // Label of the item 54 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 55 | 'default_atts' => $default_atts, 56 | 'in_column' => true, // Allow in column 57 | ) 58 | ); 59 | 60 | } // End register_shortcode 61 | 62 | 63 | /* 64 | * @desc Render the shortcode 65 | * @since 3.0.1 66 | * 67 | * @param array $atts Shortcode attributes 68 | * @param string $content Shortcode content 69 | * 70 | * @return string HTML shortcode output 71 | */ 72 | public function get_rendered_shortcode( $atts, $content ) { 73 | 74 | $html = ''; 75 | 76 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'az_index' ); 77 | 78 | // Check default settings 79 | $atts = \shortcode_atts( $default_atts, $atts, 'az_index' ); 80 | 81 | $atts['count'] = '-1'; 82 | 83 | $atts['order_by'] = 'title'; 84 | 85 | $atts['order'] = 'ASC'; 86 | 87 | $class = ( ! empty( $atts['csshook'] ) ) ? $atts['csshook'] : ''; 88 | 89 | $html .= '
    '; 90 | 91 | $items = $this->get_items( $atts ); 92 | 93 | $alpha_items = $this->get_alpha_items( $items, $atts ); 94 | 95 | ob_start(); 96 | 97 | include __DIR__ . '/az-index-nav.php'; 98 | 99 | $html .= ob_get_clean(); 100 | 101 | $html .= $this->get_az_index_content( $alpha_items, $atts ); 102 | 103 | return $html; 104 | 105 | } // End get_rendered_shortcode 106 | 107 | 108 | /* 109 | * @desc Get HTML for shortcode form 110 | * @since 3.0.1 111 | * 112 | * @param array $atts Shortcode attributes 113 | * @param string $content Shortcode content 114 | * 115 | * @return string HTML shortcode form output 116 | */ 117 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 118 | 119 | $cpb_form = cpb_get_form_class(); 120 | 121 | $feed_form = array( 122 | 'name' => cpb_get_input_name( $id, true, 'source_type' ), 123 | 'value' => 'feed', 124 | 'selected' => $settings['source_type'], 125 | 'title' => 'Feed (This Site)', 126 | 'desc' => 'Load content by category or tag', 127 | 'form' => $cpb_form->get_form_local_query( cpb_get_input_name( $id, true ), $settings ), 128 | ); 129 | 130 | $remote_feed_form = array( 131 | 'name' => cpb_get_input_name( $id, true, 'source_type' ), 132 | 'value' => 'remote_feed', 133 | 'selected' => $settings['source_type'], 134 | 'title' => 'Feed (Another Site)', 135 | 'desc' => 'Load external content by category or tag', 136 | 'form' => $cpb_form->get_form_remote_feed( cpb_get_input_name( $id, true ), $settings ), 137 | ); 138 | 139 | $html = $cpb_form->multi_form( array( $feed_form, $remote_feed_form ) ); 140 | 141 | return array( 'Source' => $html ); 142 | 143 | } // End get_shortcode_form 144 | 145 | 146 | protected function get_items( $settings ) { 147 | 148 | $query = cpb_get_query_class(); 149 | 150 | switch ( $settings['source_type'] ) { 151 | 152 | case 'feed': 153 | $items = $query->get_local_items( $settings, '' ); 154 | break; 155 | case 'remote_feed': 156 | $items = $query->get_remote_items_feed( $settings, '' ); 157 | break; 158 | 159 | default: 160 | $items = array(); 161 | break; 162 | 163 | } // end switch 164 | 165 | return $items; 166 | 167 | } // End get_items 168 | 169 | 170 | protected function get_alpha_items( $items, $settings ) { 171 | 172 | $alpha = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ); 173 | 174 | $alpha_array = array(); 175 | 176 | foreach ( $alpha as $index => $al ) { 177 | 178 | $alpha_array[ $al ] = array(); 179 | 180 | } // End foreach 181 | 182 | $alpha_num = array( 183 | 1 => 'o', 184 | 2 => 't', 185 | 3 => 't', 186 | 4 => 'f', 187 | 5 => 'f', 188 | 6 => 's', 189 | 7 => 's', 190 | 8 => 'e', 191 | 9 => 'n', 192 | ); 193 | 194 | foreach ( $items as $index => $item ) { 195 | 196 | $let = strtolower( $item['title'][0] ); 197 | 198 | if ( array_key_exists( $let, $alpha_num ) ) { 199 | 200 | $let = $alpha_num[ $let ]; 201 | 202 | } // End if 203 | 204 | $alpha_array[ $let ][] = $item; 205 | 206 | } // End foreach 207 | 208 | return $alpha_array; 209 | 210 | } // End get_alpha_items 211 | 212 | 213 | protected function get_az_index_content( $alpha_items, $settings ) { 214 | 215 | $html = '
    '; 216 | 217 | $has_active = true; 218 | 219 | foreach ( $alpha_items as $key => $alpha_set ) { 220 | 221 | $active = ''; 222 | 223 | if ( ! empty( $alpha_set ) && $has_active ) { 224 | 225 | $active = ' active'; 226 | 227 | $has_active = false; 228 | 229 | } // End if 230 | 231 | $html .= '
    '; 232 | 233 | if ( ! empty( $alpha_set ) ) { 234 | 235 | $cols = array_chunk( $alpha_set, ceil( count( $alpha_set ) / 3 ) ); 236 | 237 | foreach ( $cols as $column => $col_items ) { 238 | 239 | ob_start(); 240 | 241 | include __DIR__ . '/az-index.php'; 242 | 243 | $html .= ob_get_clean(); 244 | 245 | } // End foreach 246 | } // End if 247 | 248 | $html .= '
    '; 249 | 250 | } // End foreach 251 | 252 | $html .= '
    '; 253 | 254 | return $html; 255 | 256 | } // End get_az_index_content 257 | 258 | } // End AZ Index 259 | 260 | $cpb_shortcode_az_index = new AZ_Index_Shortcode(); 261 | -------------------------------------------------------------------------------- /lib/shortcodes/content-feed/class-content-feed-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'tag' => '', 20 | 'display' => '', 21 | 'unset_excerpt' => '0', 22 | 'unset_title' => '0', 23 | 'unset_link' => '0', 24 | 'as_lightbox' => '0', 25 | 'csshook' => '', 26 | ); 27 | 28 | 29 | public function __construct() { 30 | 31 | $local_query_defaults = cpb_get_local_query_defaults(); 32 | 33 | $this->default_settings = array_merge( $this->default_settings, $local_query_defaults ); 34 | 35 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 36 | 37 | } // End __construct 38 | 39 | 40 | /* 41 | * @desc Register action shortcode 42 | * @since 3.0.0 43 | */ 44 | public function register_shortcode() { 45 | 46 | \add_shortcode( 'content_feed', array( $this, 'get_rendered_shortcode' ) ); 47 | 48 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'content_feed' ); 49 | 50 | cpb_register_shortcode( 51 | 'content_feed', 52 | $args = array( 53 | 'form_callback' => array( $this, 'get_shortcode_form' ), 54 | 'label' => 'Content Feed', // Label of the item 55 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 56 | 'default_atts' => $default_atts, 57 | 'in_column' => true, // Allow in column 58 | ) 59 | ); 60 | 61 | } // End register_shortcode 62 | 63 | 64 | /* 65 | * @desc Render the shortcode 66 | * @since 3.0.0 67 | * 68 | * @param array $atts Shortcode attributes 69 | * @param string $content Shortcode content 70 | * 71 | * @return string HTML shortcode output 72 | */ 73 | public function get_rendered_shortcode( $atts, $content ) { 74 | 75 | $html = ''; 76 | 77 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'content_feed' ); 78 | 79 | // Check default settings 80 | $atts = \shortcode_atts( $default_atts, $atts, 'content_feed' ); 81 | 82 | $post_items = array(); 83 | 84 | if ( ! empty( $atts['feed_type'] ) ) { 85 | 86 | switch ( $atts['feed_type'] ) { 87 | 88 | case 'feed': 89 | $post_items = $this->get_post_items_feed( $atts ); 90 | break; 91 | 92 | } // end switch 93 | } // end if 94 | 95 | switch ( $atts['display'] ) { 96 | 97 | case 'accordion': 98 | $html .= $this->get_accordion_display( $post_items, $atts ); 99 | break; 100 | case 'list': 101 | $html .= $this->get_list_display( $post_items, $atts ); 102 | 103 | } // End switch 104 | 105 | if ( $html ) { 106 | 107 | $html = '
    ' . wp_kses_post( $html ) . '
    '; 108 | 109 | } // end if 110 | 111 | return $html; 112 | 113 | } // End get_rendered_shortcode 114 | 115 | 116 | protected function get_accordion_display( $post_items, $settings ) { 117 | 118 | $html = ''; 119 | 120 | $tag = $settings['tag']; 121 | 122 | foreach ( $post_items as $index => $post_item ) { 123 | 124 | $title = $post_item['title']; 125 | 126 | $content = apply_filters( 'cpb_the_content', \do_shortcode( $post_item['content'] ) ); 127 | 128 | \ob_start(); 129 | 130 | include cpb_get_plugin_path( '/lib/displays/items/accordion/accordion.php' ); 131 | 132 | $html .= \ob_get_clean(); 133 | 134 | } // End foreach 135 | 136 | return $html; 137 | 138 | } // End get_accordion_display 139 | 140 | 141 | protected function get_list_display( $post_items, $settings ) { 142 | 143 | $html = '
      '; 144 | 145 | $tag = $settings['tag']; 146 | 147 | foreach ( $post_items as $index => $post_item ) { 148 | 149 | $link_class = ( ! empty( $post_item['link'] ) ) ? 'has-link' : ''; 150 | 151 | $title = $post_item['title']; 152 | 153 | $excerpt = $post_item['excerpt']; 154 | 155 | $link = ( ! empty( $post_item['link'] ) ) ? $post_item['link'] : ''; 156 | 157 | \ob_start(); 158 | 159 | include cpb_get_plugin_path( '/lib/displays/items/list/list.php' ); 160 | 161 | $html .= \ob_get_clean(); 162 | 163 | } // End foreach 164 | 165 | $html = '
    '; 166 | 167 | return $html; 168 | 169 | } // End get_list_display 170 | 171 | 172 | protected function get_post_items_feed( $atts ) { 173 | 174 | $query = cpb_get_query_class(); 175 | 176 | $post_items = $query->get_local_items( $atts ); 177 | 178 | return $post_items; 179 | 180 | } // End get_items_feed 181 | 182 | 183 | /* 184 | * @desc Get HTML for shortcode form 185 | * @since 3.0.0 186 | * 187 | * @param array $atts Shortcode attributes 188 | * @param string $content Shortcode content 189 | * 190 | * @return string HTML shortcode form output 191 | */ 192 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 193 | 194 | $cpb_form = cpb_get_form_class(); 195 | 196 | $displays = array( 197 | 'list' => 'List', 198 | 'accordion' => 'Accordion', 199 | ); 200 | 201 | $feed_form = array( 202 | 'name' => cpb_get_input_name( $id, true, 'feed_type' ), 203 | 'value' => 'feed', 204 | 'selected' => $settings['feed_type'], 205 | 'title' => 'Feed (This Site)', 206 | 'desc' => 'Load content by category or tag', 207 | 'form' => $cpb_form->get_form_local_query( cpb_get_input_name( $id, true ), $settings ), 208 | ); 209 | 210 | $html = $cpb_form->multi_form( array( $feed_form ) ); 211 | 212 | $tags = $cpb_form->get_header_tags(); 213 | 214 | $display = $cpb_form->select_field( cpb_get_input_name( $id, true, 'display' ), $settings['display'], $displays, 'Display As' ); 215 | 216 | $display .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'tag' ), $settings['tag'], $tags, 'Tag Type' ); 217 | 218 | $display .= '
    '; 219 | 220 | $display .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'unset_title' ), 1, $settings['unset_title'], 'Hide Title' ); 221 | 222 | $display .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'unset_excerpt' ), 1, $settings['unset_excerpt'], 'Hide Summary' ); 223 | 224 | $display .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'unset_link' ), 1, $settings['unset_link'], 'Remove Link' ); 225 | 226 | $display .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'as_lightbox' ), 1, $settings['as_lightbox'], 'Display Lightbox' ); 227 | 228 | $adv = $cpb_form->text_field( cpb_get_input_name( $id, true, 'csshook' ), $settings['csshook'], 'CSS Hook' ); 229 | 230 | return array( 231 | 'Source' => $html, 232 | 'Display' => $display, 233 | 'Advanced' => $adv, 234 | ); 235 | 236 | } // End get_shortcode_form 237 | 238 | } // End Content Feed 239 | 240 | $cpb_shortcode_action = new Content_Feed_Shortcode(); 241 | -------------------------------------------------------------------------------- /lib/shortcodes/list/class-list-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'title_tag' => 'h2', 20 | 'source_type' => '', 21 | 'columns' => '4', 22 | 'unset_excerpt' => '0', 23 | 'unset_title' => '0', 24 | 'unset_img' => '0', 25 | 'unset_link' => '0', 26 | 'excerpt_length' => 'medium', 27 | ); 28 | 29 | 30 | public function __construct() { 31 | 32 | $local_query_defaults = cpb_get_local_query_defaults(); 33 | 34 | $remote_query_defaults = cpb_get_remote_query_defaults(); 35 | 36 | $select_query_defaults = cpb_get_select_query_defaults(); 37 | 38 | $this->default_settings = array_merge( 39 | $this->default_settings, 40 | $local_query_defaults, 41 | $remote_query_defaults, 42 | $select_query_defaults 43 | ); 44 | 45 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 46 | 47 | } // End __construct 48 | 49 | 50 | /* 51 | * @desc Register list shortcode 52 | * @since 3.0.0 53 | */ 54 | public function register_shortcode() { 55 | 56 | \add_shortcode( 'list', array( $this, 'get_rendered_shortcode' ) ); 57 | 58 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'list' ); 59 | 60 | cpb_register_shortcode( 61 | 'list', 62 | $args = array( 63 | 'form_callback' => array( $this, 'get_shortcode_form' ), 64 | 'label' => 'Post/Page List', // Label of the item 65 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 66 | 'default_atts' => $default_atts, 67 | 'in_column' => true, // Allow in column 68 | ) 69 | ); 70 | 71 | } // End register_shortcode 72 | 73 | 74 | /* 75 | * @desc Render the shortcode 76 | * @since 3.0.0 77 | * 78 | * @param array $atts Shortcode attributes 79 | * @param string $content Shortcode content 80 | * 81 | * @return string HTML shortcode output 82 | */ 83 | public function get_rendered_shortcode( $atts, $content ) { 84 | 85 | $html = ''; 86 | 87 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'list' ); 88 | 89 | // Check default settings 90 | $atts = \shortcode_atts( $default_atts, $atts, 'list' ); 91 | 92 | $post_items = array(); 93 | 94 | if ( ! empty( $atts['source_type'] ) ) { 95 | 96 | $query = cpb_get_query_class(); 97 | 98 | switch ( $atts['source_type'] ) { 99 | 100 | case 'feed': 101 | $post_items = $query->get_local_items( $atts, '' ); 102 | break; 103 | case 'remote_feed': 104 | $post_items = $query->get_remote_items_feed( $atts, '' ); 105 | break; 106 | default: 107 | $post_items = array(); 108 | break; 109 | 110 | } // end switch 111 | 112 | if ( ! empty( $post_items ) ) { 113 | 114 | if ( ! empty( $atts['title'] ) ) { 115 | 116 | $html .= '<' . esc_attr( $atts['title_tag'] ) . '>' . esc_html( $atts['title'] ) . ''; 117 | 118 | } // End if 119 | 120 | $html .= '
      '; 121 | 122 | foreach ( $post_items as $index => $post_item ) { 123 | 124 | $post_item = cpb_check_advanced_display( $post_item, $atts ); 125 | 126 | $link = ( ! empty( $post_item['link'] ) ) ? $post_item['link'] : ''; 127 | 128 | $title = ( ! empty( $post_item['title'] ) ) ? $post_item['title'] : ''; 129 | 130 | $excerpt = ( ! empty( $post_item['excerpt'] ) ) ? $post_item['excerpt'] : ''; 131 | 132 | \ob_start(); 133 | 134 | include __DIR__ . '/list.php'; 135 | 136 | $html .= \ob_get_clean(); 137 | 138 | } // end foreach 139 | 140 | $html .= '
    '; 141 | 142 | } // End if 143 | } // End if 144 | 145 | return $html; 146 | 147 | } // End get_rendered_shortcode 148 | 149 | 150 | /* 151 | * @desc Get HTML for shortcode form 152 | * @since 3.0.0 153 | * 154 | * @param array $atts Shortcode attributes 155 | * @param string $content Shortcode content 156 | * 157 | * @return string HTML shortcode form output 158 | */ 159 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 160 | 161 | $cpb_form = cpb_get_form_class(); 162 | 163 | $select_form = array( 164 | 'name' => cpb_get_input_name( $id, true, 'source_type' ), 165 | 'value' => 'select', 166 | 'selected' => $settings['source_type'], 167 | 'title' => 'Insert', 168 | 'desc' => 'Insert a specific post/page', 169 | 'form' => $cpb_form->get_form_select_post( cpb_get_input_name( $id, true ), $settings ), 170 | ); 171 | 172 | $feed_form = array( 173 | 'name' => cpb_get_input_name( $id, true, 'source_type' ), 174 | 'value' => 'feed', 175 | 'selected' => $settings['source_type'], 176 | 'title' => 'Feed (This Site)', 177 | 'desc' => 'Load content by category or tag', 178 | 'form' => $cpb_form->get_form_local_query( cpb_get_input_name( $id, true ), $settings ), 179 | ); 180 | 181 | $remote_feed_form = array( 182 | 'name' => cpb_get_input_name( $id, true, 'source_type' ), 183 | 'value' => 'remote_feed', 184 | 'selected' => $settings['source_type'], 185 | 'title' => 'Feed (Another Site)', 186 | 'desc' => 'Load external content by category or tag', 187 | 'form' => $cpb_form->get_form_remote_feed( cpb_get_input_name( $id, true ), $settings ), 188 | ); 189 | 190 | $display = $cpb_form->select_field( 191 | cpb_get_input_name( $id, true, 'columns' ), 192 | $settings['columns'], 193 | array( 194 | 1 => 1, 195 | 2 => 2, 196 | 3 => 3, 197 | 4 => 4, 198 | 5 => 5, 199 | ), 200 | 'Columns' 201 | ); 202 | 203 | $excerpt_length = array( 204 | 'short' => 'Short', 205 | 'medium' => 'Medium', 206 | 'long' => 'Long', 207 | 'full' => 'Full', 208 | ); 209 | 210 | $display = $cpb_form->text_field( cpb_get_input_name( $id, true, 'title' ), $settings['title'], 'Title' ); 211 | 212 | $display .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'excerpt_length' ), $settings['excerpt_length'], $excerpt_length, 'Summary Length' ); 213 | 214 | $display .= '
    '; 215 | 216 | $display .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'unset_img' ), 1, $settings['unset_img'], 'Hide Image' ); 217 | 218 | $display .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'unset_title' ), 1, $settings['unset_title'], 'Hide Title' ); 219 | 220 | $display .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'unset_excerpt' ), 1, $settings['unset_excerpt'], 'Hide Summary' ); 221 | 222 | $display .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'unset_link' ), 1, $settings['unset_link'], 'Remove Link' ); 223 | 224 | $html = $cpb_form->multi_form( array( $select_form, $feed_form, $remote_feed_form ) ); 225 | 226 | return array( 227 | 'Source' => $html, 228 | 'Display' => $display, 229 | ); 230 | 231 | } // End get_shortcode_form 232 | 233 | } // End List 234 | 235 | $cpb_shortcode_list = new List_Shortcode(); 236 | -------------------------------------------------------------------------------- /lib/shortcodes/post-gallery/class-post-gallery-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'columns' => '4', 20 | 'unset_excerpt' => '0', 21 | 'unset_title' => '0', 22 | 'unset_img' => '0', 23 | 'unset_link' => '0', 24 | 'excerpt_length' => 'medium', 25 | 'tag' => 'h3', 26 | 'promo_type' => 'basic', 27 | ); 28 | 29 | 30 | public function __construct() { 31 | 32 | $local_query_defaults = cpb_get_local_query_defaults(); 33 | 34 | $remote_query_defaults = cpb_get_rest_query_defaults(); 35 | 36 | $select_query_defautls = cpb_get_select_query_defaults(); 37 | 38 | $this->default_settings = array_merge( 39 | $this->default_settings, 40 | $local_query_defaults, 41 | $remote_query_defaults, 42 | $select_query_defautls 43 | ); 44 | 45 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 46 | 47 | } // End __construct 48 | 49 | 50 | /* 51 | * @desc Register postgallery shortcode 52 | * @since 3.0.0 53 | */ 54 | public function register_shortcode() { 55 | 56 | \add_shortcode( 'postgallery', array( $this, 'get_rendered_shortcode' ) ); 57 | 58 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'postgallery' ); 59 | 60 | cpb_register_shortcode( 61 | 'postgallery', 62 | $args = array( 63 | 'form_callback' => array( $this, 'get_shortcode_form' ), 64 | 'label' => 'Post Gallery', // Label of the item 65 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 66 | 'default_atts' => $default_atts, 67 | 'in_column' => true, // Allow in column 68 | ) 69 | ); 70 | 71 | } // End register_shortcode 72 | 73 | 74 | /* 75 | * @desc Render the shortcode 76 | * @since 3.0.0 77 | * 78 | * @param array $atts Shortcode attributes 79 | * @param string $content Shortcode content 80 | * 81 | * @return string HTML shortcode output 82 | */ 83 | public function get_rendered_shortcode( $atts, $content ) { 84 | 85 | $html = ''; 86 | 87 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'postgallery' ); 88 | 89 | // Check default settings 90 | $atts = \shortcode_atts( $default_atts, $atts, 'postgallery' ); 91 | 92 | $post_items = array(); 93 | 94 | if ( ! empty( $atts['source_type'] ) ) { 95 | 96 | $query = cpb_get_query_class(); 97 | 98 | switch ( $atts['source_type'] ) { 99 | 100 | case 'feed': 101 | $post_items = $query->get_local_items( $atts, '' ); 102 | break; 103 | case 'remote_feed': 104 | $cpb_posts = cpb_get_rest_items( $atts ); 105 | $post_items = cpb_convert_legacy_post_items( $cpb_posts ); 106 | break; 107 | default: 108 | $post_items = array(); 109 | break; 110 | 111 | } // end switch 112 | 113 | if ( ! empty( $post_items ) ) { 114 | 115 | $columns = $atts['columns']; 116 | 117 | $type = $atts['promo_type']; 118 | 119 | $tag = $atts['tag']; 120 | 121 | $html .= ''; 158 | 159 | } // End if 160 | } // End if 161 | 162 | return $html; 163 | 164 | } // End get_rendered_shortcode 165 | 166 | 167 | /* 168 | * @desc Get HTML for shortcode form 169 | * @since 3.0.0 170 | * 171 | * @param array $atts Shortcode attributes 172 | * @param string $content Shortcode content 173 | * 174 | * @return string HTML shortcode form output 175 | */ 176 | public function get_shortcode_form( $id, $settings, $content, $cpb_form ) { 177 | 178 | $cpb_form = cpb_get_form_class(); 179 | 180 | $select_form = array( 181 | 'name' => cpb_get_input_name( $id, true, 'source_type' ), 182 | 'value' => 'select', 183 | 'selected' => $settings['source_type'], 184 | 'title' => 'Insert', 185 | 'desc' => 'Insert a specific post/page', 186 | 'form' => $cpb_form->get_form_select_post( cpb_get_input_name( $id, true ), $settings ), 187 | ); 188 | 189 | $feed_form = array( 190 | 'name' => cpb_get_input_name( $id, true, 'source_type' ), 191 | 'value' => 'feed', 192 | 'selected' => $settings['source_type'], 193 | 'title' => 'Feed (This Site)', 194 | 'desc' => 'Load content by category or tag', 195 | 'form' => $cpb_form->get_form_local_query( cpb_get_input_name( $id, true ), $settings ), 196 | ); 197 | 198 | $remote_feed_form = array( 199 | 'name' => cpb_get_input_name( $id, true, 'source_type' ), 200 | 'value' => 'remote_feed', 201 | 'selected' => $settings['source_type'], 202 | 'title' => 'Feed (Another Site)', 203 | 'desc' => 'Load external content by category or tag', 204 | 'form' => $cpb_form->get_form_external_feed( cpb_get_input_name( $id, true ), $settings ), 205 | ); 206 | 207 | $display = $cpb_form->select_field( 208 | cpb_get_input_name( 209 | $id, 210 | true, 211 | 'columns' 212 | ), 213 | $settings['columns'], 214 | array( 215 | 1 => 1, 216 | 2 => 2, 217 | 3 => 3, 218 | 4 => 4, 219 | 5 => 5, 220 | ), 221 | 'Columns' 222 | ); 223 | 224 | $excerpt_length = array( 225 | 'short' => 'Short', 226 | 'medium' => 'Medium', 227 | 'long' => 'Long', 228 | 'full' => 'Full', 229 | ); 230 | 231 | $display .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'excerpt_length' ), $settings['excerpt_length'], $excerpt_length, 'Summary Length' ); 232 | 233 | $tags = $cpb_form->get_header_tags(); 234 | unset( $tags['strong'] ); 235 | $display .= $cpb_form->select_field( cpb_get_input_name( $id, true, 'tag' ), $settings['tag'], $tags, 'Tag Type' ); 236 | 237 | $display .= '
    '; 238 | 239 | $display .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'unset_img' ), 1, $settings['unset_img'], 'Hide Image' ); 240 | 241 | $display .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'unset_title' ), 1, $settings['unset_title'], 'Hide Title' ); 242 | 243 | $display .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'unset_excerpt' ), 1, $settings['unset_excerpt'], 'Hide Summary' ); 244 | 245 | $display .= $cpb_form->checkbox_field( cpb_get_input_name( $id, true, 'unset_link' ), 1, $settings['unset_link'], 'Remove Link' ); 246 | 247 | $html = $cpb_form->multi_form( array( $select_form, $feed_form, $remote_feed_form ) ); 248 | 249 | return array( 250 | 'Source' => $html, 251 | 'Display' => $display, 252 | ); 253 | 254 | } // End get_shortcode_form 255 | 256 | 257 | } // End Post Gallery 258 | 259 | $cpb_shortcode_postgallery = new Post_Gallery_Shortcode(); 260 | -------------------------------------------------------------------------------- /lib/shortcodes/social/class-social-shortcode.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'twitter_order' => '', 20 | 'facebook' => '', 21 | 'facebook_order' => '', 22 | 'instagram' => '', 23 | 'instagram_order' => '', 24 | 'instagram_target' => '', 25 | 'height' => '', 26 | 'csshook' => '', 27 | ); 28 | 29 | 30 | public function __construct() { 31 | 32 | \add_action( 'init', array( $this, 'register_shortcode' ) ); 33 | 34 | } // End __construct 35 | 36 | 37 | /* 38 | * @desc Register social shortcode 39 | * @since 3.0.0 40 | */ 41 | public function register_shortcode() { 42 | 43 | \add_shortcode( 'social', array( $this, 'get_rendered_shortcode' ) ); 44 | 45 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, array(), 'social' ); 46 | 47 | cpb_register_shortcode( 48 | 'social', 49 | $args = array( 50 | 'form_callback' => array( $this, 'get_shortcode_form' ), 51 | 'label' => 'Social', // Label of the item 52 | 'render_callback' => array( $this, 'get_rendered_shortcode' ), // Callback to render shortcode 53 | 'default_atts' => $default_atts, 54 | 'in_column' => true, // Allow in column 55 | ) 56 | ); 57 | 58 | } // End register_shortcode 59 | 60 | 61 | /* 62 | * @desc Render the shortcode 63 | * @since 3.0.0 64 | * 65 | * @param array $atts Shortcode attributes 66 | * @param string $content Shortcode content 67 | * 68 | * @return string HTML shortcode output 69 | */ 70 | public function get_rendered_shortcode( $atts, $content ) { 71 | 72 | $html = ''; 73 | 74 | $default_atts = apply_filters( 'cpb_shortcode_default_atts', $this->default_settings, $atts, 'social' ); 75 | 76 | // Check default settings 77 | $atts = \shortcode_atts( $default_atts, $atts, 'social' ); 78 | 79 | if ( empty( $atts['height'] ) ) { 80 | 81 | $atts['height'] = 800; 82 | 83 | } // end if 84 | 85 | $feeds = array(); 86 | 87 | if ( ! empty( $atts['twitter'] ) ) { 88 | 89 | $order = ( ! empty( $atts['twitter_order'] ) ) ? $atts['twitter_order'] : 2; 90 | 91 | $feeds[ $order ] = array( 92 | 'type' => 'twitter', 93 | 'src' => $atts['twitter'], 94 | 'height' => $atts['height'], 95 | ); 96 | 97 | } // End if 98 | 99 | if ( ! empty( $atts['facebook'] ) ) { 100 | 101 | $order = ( ! empty( $atts['facebook_order'] ) ) ? $atts['facebook_order'] : 3; 102 | 103 | $feeds[ $order ] = array( 104 | 'type' => 'facebook', 105 | 'src' => $atts['facebook'], 106 | 'height' => $atts['height'], 107 | ); 108 | 109 | } // End if 110 | 111 | if ( ! empty( $atts['instagram'] ) ) { 112 | 113 | $order = ( ! empty( $atts['instagram_order'] ) ) ? $atts['instagram_order'] : 4; 114 | 115 | $feeds[ $order ] = array( 116 | 'type' => 'instagram', 117 | 'src' => $atts['instagram'], 118 | 'height' => $atts['height'], 119 | 'target' => $atts['instagram_target'], 120 | 'is_link' => true, 121 | ); 122 | 123 | } // End if 124 | 125 | $html = '
    '; 126 | 127 | ksort( $feeds ); 128 | 129 | $icon_html = '
    '; 130 | 131 | $content_html = '
    '; 132 | 133 | $i = 0; 134 | 135 | foreach ( $feeds as $index => $feed ) { 136 | 137 | $active = ( 0 === $i ) ? ' active' : ''; 138 | 139 | $content_html .= '
    '; 140 | 141 | switch ( $feed['type'] ) { 142 | 143 | case 'facebook': 144 | $icon_html .= $this->get_facebook_html( $feed, $i, true ); 145 | $content_html .= $this->get_facebook_html( $feed, $i ); 146 | break; 147 | case 'twitter': 148 | $icon_html .= $this->get_twitter_html( $feed, $i, true ); 149 | $content_html .= $this->get_twitter_html( $feed, $i ); 150 | break; 151 | case 'instagram': 152 | $icon_html .= $this->get_instagram_html( $feed, $i, true ); 153 | $content_html .= $this->get_instagram_html( $feed, $i ); 154 | break; 155 | } // End 156 | 157 | $content_html .= '
    '; 158 | 159 | $i++; 160 | 161 | } // end foreach 162 | 163 | $icon_html .= '
    '; 164 | 165 | $content_html .= '
    '; 166 | 167 | $html .= $icon_html . $content_html . '
    '; 168 | 169 | return $html; 170 | 171 | } // End get_rendered_shortcode 172 | 173 | 174 | protected function get_facebook_html( $feed, $i, $is_icon = false ) { 175 | 176 | $html = ''; 177 | 178 | $height = $feed['height']; 179 | 180 | if ( $is_icon ) { 181 | 182 | $html .= '
    '; 183 | 184 | } else { 185 | 186 | $facebook_src = $feed['src']; 187 | 188 | \ob_start(); 189 | 190 | include __DIR__ . '/facebook.php'; 191 | 192 | $html .= \ob_get_clean(); 193 | 194 | } // End if 195 | 196 | return $html; 197 | 198 | } // End get_facebook_html 199 | 200 | 201 | protected function get_twitter_html( $feed, $i, $is_icon = false ) { 202 | 203 | $html = ''; 204 | 205 | $height = $feed['height']; 206 | 207 | if ( $is_icon ) { 208 | 209 | $html .= '
    '; 210 | 211 | } else { 212 | 213 | $twitter_src = $feed['src']; 214 | 215 | \ob_start(); 216 | 217 | include __DIR__ . '/twitter.php'; 218 | 219 | $html .= \ob_get_clean(); 220 | 221 | } // End if 222 | 223 | return $html; 224 | 225 | } // End get_facebook_html 226 | 227 | protected function get_instagram_html( $feed, $i, $is_icon = false ) { 228 | 229 | $html = ''; 230 | 231 | $height = $feed['height']; 232 | 233 | if ( $is_icon ) { 234 | 235 | $html .= '