20 |
--------------------------------------------------------------------------------
/assets/js/screen/id/media_page_boldgrid-connect-search.js:
--------------------------------------------------------------------------------
1 | var IMHWPB = IMHWPB || {};
2 |
3 | IMHWPB.ScreenIdMediaPageBoldGridConnectSearch = function() {
4 | var self = this;
5 |
6 | jQuery(function() {
7 | // When the page loads, resize the iframe.
8 | self.resize_boldgrid_connect_search();
9 |
10 | // When the window size is changed, resize iframe.
11 | jQuery(window).resize(function() {
12 | self.resize_boldgrid_connect_search();
13 | });
14 | });
15 |
16 | /**
17 | *
18 | */
19 | this.resize_boldgrid_connect_search = function() {
20 | var body_height = jQuery("body").height();
21 | jQuery(".wrap-boldgrid-connect-search").css("height",
22 | (body_height - 165) + "px");
23 | }
24 | };
25 |
26 | new IMHWPB.ScreenIdMediaPageBoldGridConnectSearch();
--------------------------------------------------------------------------------
/assets/js/inline/checking_out_complete.js:
--------------------------------------------------------------------------------
1 | $stop_and_explain = jQuery(".stop-and-explain");
2 | $title_purchase = jQuery("h1.purchasing");
3 | var ruler = "";
4 |
5 | // Hide the spinner.
6 | $spinner.remove();
7 |
8 | // Hide the loading graphic.
9 | jQuery('.boldgrid-loading').remove();
10 |
11 | // Move "stop and explain" to the top of the page.
12 | $stop_and_explain.insertBefore($title_purchase).slideToggle(1000);
13 |
14 | // Move the separator into place.
15 | jQuery(ruler).insertBefore($title_purchase);
16 |
17 | // Update the title of the page.
18 | $title_purchase
19 | .html( BoldGridInspirationsPurchase.purchaseComplete )
20 | .prepend( "" );
21 |
22 | // Scroll the user to the top of the page.
23 | jQuery("html").animate({
24 | scrollTop : 0
25 | }, "slow");
--------------------------------------------------------------------------------
/assets/js/inline/checking_out_complete_with_errors.js:
--------------------------------------------------------------------------------
1 | $stop_and_explain = jQuery(".stop-and-explain");
2 | $title_purchase = jQuery("h1.purchasing");
3 | var ruler = "";
4 |
5 | // Hide the spinner.
6 | $spinner.remove();
7 |
8 | // Hide the loading graphic.
9 | jQuery('.boldgrid-loading').remove();
10 |
11 | // Move "stop and explain" to the top of the page.
12 | $stop_and_explain.insertBefore($title_purchase).slideToggle(1000);
13 |
14 | // Move the separator into place.
15 | jQuery(ruler).insertBefore($title_purchase);
16 |
17 | // Update the title of the page.
18 | $title_purchase
19 | .html( BoldGridInspirationsPurchase.withErrors )
20 | .prepend( "" );
21 |
22 | // Scroll the user to the top of the page.
23 | jQuery("html").animate({
24 | scrollTop : 0
25 | }, "slow");
--------------------------------------------------------------------------------
/includes/deploy/invoice/posts/get-a-quote.php:
--------------------------------------------------------------------------------
1 | 'get-a-quote',
7 | 'post_title' => 'Get a Quote',
8 | 'post_status' => 'publish',
9 | 'post_type' => 'page',
10 | 'comment_status' => 'closed',
11 | 'post_content' => '
12 |
13 |
14 |
15 |
16 |
17 |
Are you looking to get a quote for our services? Please fill out the form below and provide us with all necessary information for us to generate a quote. We will get back with you within 1 to 2 business days.
18 |
[weforms id="' . $form->id . '"]
19 |
20 |
21 |
22 |
23 | ',
24 | );
25 |
26 | return $post;
27 |
--------------------------------------------------------------------------------
/pages/templates/widget_customization.php:
--------------------------------------------------------------------------------
1 |
9 |
10 |
23 |
--------------------------------------------------------------------------------
/assets/css/boldgrid-in-menu.css:
--------------------------------------------------------------------------------
1 | /**
2 | * This file should not be auto formatted.
3 | */
4 |
5 |
6 | .boldgrid-auto-add-to-menu:before {
7 | content: "\f203";
8 | font: 400 20px/1 dashicons;
9 | speak: none;
10 | display: inline-block;
11 | padding: 0 2px 0 0;
12 | top: 0;
13 | left: -1px;
14 | position: relative;
15 | vertical-align: top;
16 | -webkit-font-smoothing: antialiased;
17 | -moz-osx-font-smoothing: grayscale;
18 | text-decoration: none !important;
19 | color: #82878c;
20 | }
21 |
22 | #boldgrid-auto-add-to-menu-menu-listing {
23 | margin-top: 3px;
24 | }
25 |
26 | #boldgrid-auto-add-to-menu-menu-listing ul{
27 | font-size: 12px;
28 | list-style: disc outside none !important;
29 | margin: 0px;
30 | padding-left: 30px;
31 | }
32 |
33 | .hide-boldgrid-auto-add-to-menu.button {
34 | margin-top: 8px;
35 | }
36 |
37 | #selected-menu-names {
38 | font-weight: bold;
39 | }
40 |
--------------------------------------------------------------------------------
/assets/js/boldgrid-admin-notices.js:
--------------------------------------------------------------------------------
1 | var IMHWPB = IMHWPB || {};
2 |
3 | IMHWPB.BoldGridAdminNotices = function( configs ) {
4 | var self = this;
5 |
6 | jQuery( function() {
7 |
8 | // Allow users to dismiss a notice.
9 | jQuery( '.boldgrid-admin-notice .notice-dismiss' ).on( 'click', function() {
10 | self.dismiss_boldgrid_admin_notice( this );
11 | } );
12 | } );
13 |
14 | /**
15 | * Allow users to dismiss a notice.
16 | */
17 | self.dismiss_boldgrid_admin_notice = function( dismiss_button ) {
18 |
19 | // Get the id of the notice.
20 | var admin_notice_id = jQuery( dismiss_button )
21 | .parents( '.boldgrid-admin-notice' )
22 | .attr( 'data-admin-notice-id' );
23 | var data = {
24 | action: 'dismiss_boldgrid_admin_notice',
25 | id: admin_notice_id
26 | };
27 |
28 | jQuery.post( ajaxurl, data, function( response ) {} );
29 | };
30 | };
31 |
32 | new IMHWPB.BoldGridAdminNotices();
33 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "require": {
3 | "boldgrid/library": "^2.13.11",
4 | "boldgrid/boldgrid-inspirations-premium": "^1.1.3",
5 | "boldgrid/plugin-installer": "^1.0.9",
6 | "boldgrid/bgforms": "^1.2.3"
7 | },
8 | "scripts": {
9 | "post-autoload-dump": [
10 | "yarn run cpx -v 'node_modules/font-awesome/css/*' 'assets/css/font-awesome/css/'",
11 | "yarn run cpx -v 'node_modules/font-awesome/fonts/*' 'assets/css/font-awesome/fonts/'",
12 | "yarn run cpx -v 'node_modules/jquery-toggles/toggles*.js' 'assets/js/jquery-toggles/'",
13 | "yarn run cpx -v 'node_modules/jquery-toggles/css/toggles-full.css' 'assets/css/jquery-toggles/'",
14 | "composer run-script post-autoload-dump -d ./vendor/boldgrid/library"
15 | ]
16 | },
17 | "require-dev": {
18 | "phpunit/phpunit": "^7",
19 | "yoast/phpunit-polyfills": "^1.0"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/includes/class-boldgrid-inspirations-customizer.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 |
11 | /**
12 | * The BoldGrid Inspirations Customizer class.
13 | */
14 | class Boldgrid_Inspirations_Customizer {
15 | /**
16 | * Add hooks.
17 | */
18 | public function add_hooks() {
19 | if ( is_customize_preview() ) {
20 | // If in admin add CSS and JS to dashboard for widget and styling.
21 | add_action(
22 | 'customize_controls_print_styles',
23 | array(
24 | $this, 'remove_change_themes'
25 | ), 999
26 | );
27 | }
28 | }
29 |
30 | /**
31 | * This function adds some styles to the WordPress Customizer.
32 | */
33 | public function remove_change_themes() {
34 | ?>
35 |
40 | img {
44 | max-height: 60px;
45 | }
46 |
--------------------------------------------------------------------------------
/assets/css/easy-attachment-preview-size.css:
--------------------------------------------------------------------------------
1 | select.easy-attachment-preview-size option {
2 | background: #fff;
3 | color: #000;
4 | }
5 |
6 | select.easy-attachment-preview-size option:hover {
7 | background: #1e90ff;
8 | color: #fff;
9 | }
10 |
11 | select#image_size option.recommended_image_size:hover {
12 | background: #009E00;
13 | }
14 |
15 | div#easy_attachment_preview_size {
16 | position: fixed;
17 | top: 30px;
18 | left: 30px;
19 | background-color: rgba(51, 204, 255, 0.75);
20 | font-size: 20px;
21 | padding: 0px;
22 | border: 3px solid #33CCFF;
23 | z-index: 200000;
24 | font-weight: bold;
25 | text-shadow: rgb(221, 221, 221) 1px 1px;
26 | }
27 |
28 | div#easy_attachment_preview_size.easy_attachment_preview_size_iframed {
29 | top: 0px;
30 | left: 0px;
31 | }
32 |
33 | div#easy_attachment_preview_size.easy_attachment_preview_size_100 {
34 | font-size: 12px;
35 | line-height: 14px;
36 | }
37 |
38 | select#image_size, select.easy-attachment-preview-size {
39 | position: absolute;
40 | z-index: 300001;
41 | width: 90%;
42 | max-width: 100%;
43 | }
44 |
45 | .easy-attachment-preview-size-hidden {
46 | visibility: hidden;
47 | }
48 |
49 | label.setting {
50 | min-height: 45px;
51 | }
--------------------------------------------------------------------------------
/assets/js/all-pages-mine-count.js:
--------------------------------------------------------------------------------
1 | /* global boldgridAttributionCount */
2 |
3 | jQuery( function() {
4 |
5 | // Abort if we don't have a count to remove.
6 | if ( 'undefined' === typeof boldgridAttributionCount ) {
7 | return;
8 | }
9 |
10 | /**
11 | * On "All Pages", we remove the ninja forms preview page both from the list
12 | * of pages and the page count next to "All".
13 | *
14 | * There may be a "Mine(5)" page count at the top of the page as well.
15 | * However, there does not appear to be a filter to manage that count. So,
16 | * we will use JS to remove 1 from the count.
17 | */
18 | var $mine_span = jQuery( 'li.mine a span' ),
19 | mineCount,
20 | newMineCount;
21 |
22 | // If we don't have a "Mine" element, abort.
23 | if ( 0 === $mine_span.length ) {
24 | return;
25 | }
26 |
27 | mineCount = parseInt(
28 | $mine_span
29 | .html()
30 | .replace( '(', '' )
31 | .replace( ')', '' )
32 | );
33 |
34 | newMineCount = mineCount - parseInt( boldgridAttributionCount.removeFromMine );
35 |
36 | // If the new_mine_count is not a number, abort.
37 | if ( isNaN( newMineCount ) ) {
38 | return;
39 | }
40 |
41 | $mine_span.html( '(' + newMineCount + ')' );
42 | } );
43 |
--------------------------------------------------------------------------------
/includes/configure_plugin/contact-form-7.php:
--------------------------------------------------------------------------------
1 | ID . '" title="Contact form 1"]';
13 |
14 | // update the post and replace [imhwpb-form] with the shortcode used by cf7
15 | // $post_id is coming from the file in which this was included
16 | $page_needing_form = get_post( $post_id );
17 | $page_needing_form->post_content = str_replace( '[imhwpb-form]', $short_code,
18 | $page_needing_form->post_content );
19 | wp_update_post( $page_needing_form );
20 |
21 | // update the email address of the recipient
22 | global $current_user;
23 | get_currentuserinfo();
24 | $postmeta = get_post_meta( $auto_created_form->ID, '_mail', true );
25 | $postmeta['recipient'] = "wpb@boldgrid.com";
26 | if ( $current_user->user_email != "" ) {
27 | $postmeta['recipient'] = $current_user->user_email;
28 | }
29 | update_post_meta( $auto_created_form->ID, '_mail', $postmeta );
30 |
31 |
--------------------------------------------------------------------------------
/includes/deploy/class-logo.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 |
11 | namespace Boldgrid\Inspirations\Deploy;
12 |
13 | /**
14 | * Deploy Logo class.
15 | *
16 | * @since SINCEVERSION
17 | */
18 | class Logo {
19 | /**
20 | * Download and setup a logo.
21 | *
22 | * @since SINCEVERSION
23 | *
24 | * @param int $asset_id The asset_id of our logo.
25 | * @param Boldgrid_Inspirations_Deploy $deploy Our deployment class.
26 | */
27 | public static function deploy( $asset_id, $deploy ) {
28 | if ( ! is_numeric( $asset_id ) ) {
29 | return false;
30 | }
31 |
32 | $attachment_data = $deploy->asset_manager->download_and_attach_asset( false, $asset_id, null, 'all' );
33 |
34 | if ( empty( $attachment_data['attachment_id'] ) || ! is_numeric( $attachment_data['attachment_id'] ) ) {
35 | return false;
36 | } else {
37 | $attachment_id = $attachment_data['attachment_id'];
38 | }
39 |
40 | set_theme_mod( 'custom_logo', $attachment_id );
41 | update_option( 'site_logo', $attachment_id );
42 |
43 | return true;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/tests/bootstrap.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 |
11 | /**
12 | * BoldGrid Inspirations Deploy Metadata class.
13 | *
14 | * This class is designated for working with metadata surrounding a new site deployment.
15 | *
16 | * @since 1.3.9
17 | */
18 | class Boldgrid_Inspirations_Deploy_Metadata{
19 |
20 | /**
21 | * Get private posts.
22 | *
23 | * If you installed a Staging site via Inspirations, and that site included posts, those posts
24 | * were set to private. This method will return an array of those private post ids.
25 | *
26 | * @since 1.3.9
27 | *
28 | * @return array
29 | */
30 | public static function get_private_posts() {
31 | $posts = array();
32 |
33 | $metadata = get_option( 'boldgrid_staging_boldgrid_installed_pages_metadata', array() );
34 |
35 | foreach( $metadata as $post_id => $post_data ) {
36 | if( 'private' === $post_data['post_status'] && 'post' === $post_data['post_type'] ) {
37 | $posts[] = $post_id;
38 | }
39 | }
40 |
41 | return $posts;
42 | }
43 | }
44 |
45 | ?>
--------------------------------------------------------------------------------
/pages/includes/post_submitbox_misc_actions_auto_add_to_menu.php:
--------------------------------------------------------------------------------
1 |
11 |
' . wp_kses(
50 | sprintf(
51 | // translators: 1 The opening anchor tag to the Inspirations page, 2 its closing tag.
52 | __( 'It looks like there is still more you can do with BoldGrid. %1$sClick here to continue%2$s.', 'boldgrid-inspirations' ),
53 | '',
54 | ''
55 | ),
56 | array( 'a' => array( 'href' => array() ) )
57 | ) . '
This is a paragraph with an image aligned to the left. Replace this text with your own text. It\'s easy! This is a paragraph with an image aligned to the left. Replace this text with your own text. It\'s easy! This is a paragraph with an image aligned to the left. Replace this text with your own text. It\'s easy! This is a paragraph with an image aligned to the left. Replace this text with your own text. It\'s easy!
This is a paragraph with an image aligned to the left. Replace this text with your own text. It\'s easy!
';
5 | return left_image;
6 | }
7 |
8 | tinymce.create( 'tinymce.plugins.imhwpb', {
9 |
10 | /**
11 | * Initializes the plugin, this will be executed after the plugin has been
12 | * created. This call is done before the editor instance has finished it's
13 | * initialization so use the onInit event of the editor instance to
14 | * intercept that event.
15 | *
16 | * @param {tinymce.Editor}
17 | * ed Editor instance that the plugin is initialized in.
18 | * @param {string}
19 | * url Absolute URL to where the plugin is located.
20 | */
21 | init: function( ed, url ) {
22 | ed.addButton( 'example', {
23 | text: 'Z',
24 | icon: false,
25 | title: 'TITLE GOES HERE',
26 |
27 | // image : url + '/../images/icon-toggle.gif',
28 | onclick: function() {
29 |
30 | // CustomButtonClick('learn_more');
31 | myText = boldgrid_mce_image_left();
32 | ed.execCommand( 'mceInsertContent', false, myText );
33 | }
34 | } );
35 | },
36 |
37 | /**
38 | * Creates control instances based in the incomming name. This method is
39 | * normally not needed since the addButton method of the tinymce.Editor
40 | * class is a more easy way of adding buttons but you sometimes need to
41 | * create more complex controls like listboxes, split buttons etc then this
42 | * method can be used to create those.
43 | *
44 | * @param {String}
45 | * n Name of the control to create.
46 | * @param {tinymce.ControlManager}
47 | * cm Control manager to use inorder to create new control.
48 | * @return {tinymce.ui.Control} New control instance or null if no control
49 | * was created.
50 | */
51 | createControl: function( n, cm ) {
52 | return null;
53 | }
54 | } );
55 |
56 | tinymce.PluginManager.add( 'boldgrid_example', tinymce.plugins.imhwpb );
57 |
--------------------------------------------------------------------------------
/includes/class-boldgrid-inspirations-widget.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 |
11 | /**
12 | * BoldGrid Widget class.
13 | *
14 | * @since 1.4
15 | */
16 | class Boldgrid_Inspirations_Widget {
17 |
18 | /**
19 | * Create a widget.
20 | *
21 | * Create a widget based upon the standard WordPress widgets. The option name is widget_$type,
22 | * it's an array, and each instance of that widget has a numeric key.
23 | *
24 | * @since 1.4
25 | *
26 | * @param string $type Such as "search" or "recent-posts".
27 | * @param mixed $value The value of your new widget, such as array().
28 | * @return int The key of the new widget.
29 | */
30 | public static function create_widget( $type, $value ) {
31 | $widget_name = 'widget_' . $type;
32 |
33 | $widgets = get_option( $widget_name );
34 |
35 | $widgets[] = $value;
36 |
37 | update_option( $widget_name, $widgets );
38 |
39 | return max( array_keys( $widgets ) );
40 | }
41 |
42 | /**
43 | * Return the sidebars_widgets option.
44 | *
45 | * @since 1.4
46 | *
47 | * @return array
48 | */
49 | public static function get_sidebars_widgets() {
50 | return get_option( 'sidebars_widgets', array() );
51 | }
52 |
53 | /**
54 | * Update sidebars_widgets.
55 | *
56 | * @since 1.4
57 | *
58 | * @param string $sidebar The sidebar to update, such as 'sidebar-1'.
59 | * @param string $id The new widget to add, such as 'search-4'.
60 | * @return bool True if update was successful.
61 | */
62 | public static function add_to_sidebars( $sidebar, $id ) {
63 | $widgets = self::get_sidebars_widgets();
64 |
65 | $widgets[ $sidebar ][] = $id;
66 |
67 | return self::update_sidebars_widgets( $widgets );
68 | }
69 |
70 | /**
71 | * Empty a sidebar within the sidebars_widgets option.
72 | *
73 | * @since 1.4
74 | *
75 | * @param string $sidebar The sidebar to empty, such as 'sidebar-1'.
76 | */
77 | public static function empty_sidebar( $sidebar ) {
78 | $sidebars_widgets = self::get_sidebars_widgets();
79 |
80 | $sidebars_widgets[ $sidebar ] = array();
81 |
82 | self::update_sidebars_widgets( $sidebars_widgets );
83 | }
84 |
85 | /**
86 | * Update the sidebars_widgets option.
87 | *
88 | * @since 1.4
89 | *
90 | * @param array $value The new value.
91 | */
92 | public static function update_sidebars_widgets( $value ) {
93 | return update_option( 'sidebars_widgets', $value );
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/pages/cart/checking-out.php:
--------------------------------------------------------------------------------
1 |
6 |
7 |
26 |
27 |
--------------------------------------------------------------------------------
/bin/install-wp-tests.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | if [ $# -lt 3 ]; then
4 | echo "usage: $0 [db-host] [wp-version]"
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 |
14 | WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
15 | WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
16 |
17 | set -ex
18 |
19 | install_wp() {
20 | mkdir -p $WP_CORE_DIR
21 |
22 | if [ $WP_VERSION == 'latest' ]; then
23 | local ARCHIVE_NAME='latest'
24 | else
25 | local ARCHIVE_NAME="wordpress-$WP_VERSION"
26 | fi
27 |
28 | # Install the WordPress files.
29 | # Unzip quietly (-qq) so the automated tests are not flooded with the unzip output.
30 | wget -nv -O /tmp/wordpress-latest.zip https://wordpress.org/nightly-builds/wordpress-latest.zip
31 | unzip -qq /tmp/wordpress-latest.zip -d /tmp
32 |
33 | wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
34 | }
35 |
36 | install_test_suite() {
37 | # portable in-place argument for both GNU sed and Mac OSX sed
38 | if [[ $(uname -s) == 'Darwin' ]]; then
39 | local ioption='-i .bak'
40 | else
41 | local ioption='-i'
42 | fi
43 |
44 | # set up testing suite
45 | mkdir -p $WP_TESTS_DIR
46 | cd $WP_TESTS_DIR
47 | # As each new version of WP is released, the branch should be updated in the 2 lines below.
48 | svn co --quiet https://develop.svn.wordpress.org/branches/5.9/tests/phpunit/includes/
49 | wget -nv -O wp-tests-config.php https://develop.svn.wordpress.org/branches/5.9/wp-tests-config-sample.php
50 | sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php
51 | sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php
52 | sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php
53 | sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php
54 | sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php
55 | }
56 |
57 | install_db() {
58 | # parse DB_HOST for port or socket references
59 | local PARTS=(${DB_HOST//\:/ })
60 | local DB_HOSTNAME=${PARTS[0]};
61 | local DB_SOCK_OR_PORT=${PARTS[1]};
62 | local EXTRA=""
63 |
64 | if ! [ -z $DB_HOSTNAME ] ; then
65 | if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
66 | EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
67 | elif ! [ -z $DB_SOCK_OR_PORT ] ; then
68 | EXTRA=" --socket=$DB_SOCK_OR_PORT"
69 | elif ! [ -z $DB_HOSTNAME ] ; then
70 | EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
71 | fi
72 | fi
73 |
74 | # create database
75 | mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
76 | }
77 |
78 | install_wp
79 | install_test_suite
80 | install_db
81 |
--------------------------------------------------------------------------------
/assets/css/adminiconstyle.css:
--------------------------------------------------------------------------------
1 | /**
2 | * #.# Error alerts.
3 | *
4 | * These styles appear to be used by the BoldGrid library. @todo, confirm and move them to the library.
5 | */
6 |
7 | .error-alerts {
8 | color: red;
9 | }
10 |
11 | .error-color::before {
12 | content: '*';
13 | padding-right: 5px;
14 | }
15 |
16 | .error-color {
17 | color: red;
18 | }
19 |
20 | /**
21 | * #.# Theme install.
22 | *
23 | * These styles are for theme-install.php
24 | */
25 |
26 | .theme-install-php #recommend-boldgrid p {
27 | margin: 0;
28 | position: relative;
29 | }
30 |
31 | .theme-install-php #recommend-boldgrid .recommend-boldgrid-text {
32 | padding-left: 41px;
33 | display: inline-block;
34 | left: 18px;
35 | padding-top: 10px;
36 | padding-bottom: 10px;
37 | }
38 |
39 | .theme-install-php .boldgrid-cert,
40 | .theme-install-php .theme[aria-describedby*="boldgrid-"] .theme-name:after {
41 | background: url(../images/bg-seal.png) no-repeat;
42 | }
43 |
44 | .theme-install-php .theme[aria-describedby*="boldgrid-"] .theme-name:after {
45 | content: ' ';
46 | width: 40px;
47 | height: 40px;
48 | display: block;
49 | position: absolute;
50 | left: -6px;
51 | bottom: 36px;
52 | background-size: 37px auto;
53 | }
54 |
55 | .theme-install-php .theme[aria-describedby*="boldgrid-"] .theme-name:before {
56 | content: 'Certified';
57 | display: block;
58 | width: 100%;
59 | height: 18px;
60 | background: #262626; /* Old browsers */
61 | background: -moz-linear-gradient(left, #262626 0%, #ffffff 100%); /* FF3.6-15 */
62 | background: -webkit-linear-gradient(left, #262626 0%,#ffffff 100%); /* Chrome10-25,Safari5.1-6 */
63 | background: linear-gradient(to right, #262626 0%,#ffffff 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
64 | background-size: 100% 100%;
65 | padding: 2px 0px;
66 | position: absolute;
67 | bottom: 48px;
68 | left: 0px;
69 | color: white;
70 | text-transform: uppercase;
71 | text-indent: 38px;
72 | font-size: 10px;
73 | font-family: Josefin Sans;
74 | letter-spacing: .1em;
75 | font-weight: 500;
76 | }
77 |
78 | .theme-install-php .boldgrid-cert {
79 | width: 39px;
80 | height: 44px;
81 | display: inline-block;
82 | position: absolute;
83 | top: 50%;
84 | transform: translateY(-50%);
85 | }
86 |
87 | .theme-install-php .boldgrid-cert {
88 | background-position: -1px 5px;
89 | }
90 |
91 | #toplevel_page_boldgrid-inspirations span.bginsp-progress.complete {
92 | display: none;
93 | }
94 |
95 | #toplevel_page_boldgrid-inspirations span.bginsp-progress {
96 | background: green;
97 | padding: 2px 4px;
98 | border-radius: 35%;
99 | color: white;
100 | font-weight: 600;
101 | }
102 |
--------------------------------------------------------------------------------
/includes/class-boldgrid-inspirations-external-plugin.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 |
11 | /**
12 | * The BoldGrid External Plugin class.
13 | */
14 | class Boldgrid_Inspirations_External_Plugin {
15 |
16 | /**
17 | * An instance of WPB_Plugin.
18 | *
19 | * @var WPB_Plugin
20 | */
21 | protected $configs;
22 |
23 | /**
24 | * Array of plugin statuses.
25 | *
26 | * @var array
27 | */
28 | protected $boldgrid_plugins_status;
29 |
30 | /**
31 | * Accessor for active plugins.
32 | *
33 | * @return array
34 | */
35 | public function get_active_boldgrid_plugins() {
36 | return $this->boldgrid_plugins_status;
37 | }
38 |
39 | /**
40 | * Accessor for configs.
41 | *
42 | * @return array
43 | */
44 | public function get_configs() {
45 | return $this->configs;
46 | }
47 |
48 | /**
49 | * Checks if a paticular boldgrid plugin is active by name.
50 | *
51 | * @param string $name
52 | * @return boolean
53 | */
54 | public function plugin_is_active( $name ) {
55 | return isset( $this->boldgrid_plugins_status[$name] ) ? $this->boldgrid_plugins_status[$name] : null;
56 | }
57 |
58 | /**
59 | * Accepts configs.
60 | *
61 | * @param array $configs
62 | */
63 | public function __construct( $boldgrid_configs = null ) {
64 | $this->configs = $boldgrid_configs;
65 |
66 | add_action( 'wp_loaded', array (
67 | $this,
68 | 'find_plugins'
69 | ) );
70 | }
71 |
72 | /**
73 | * Check if plugin is active, before admin_init.
74 | *
75 | * @param string $plugin_name Sub-directory/file.
76 | */
77 | public function is_active( $plugin_name ) {
78 | $all_active_plugins = $this->get_all_active_plugins();
79 | return ( false !== array_search( $plugin_name, $all_active_plugins, true ) );
80 | }
81 |
82 | /**
83 | * Get all active plugins.
84 | */
85 | public function get_all_active_plugins() {
86 | $site_plugins = get_option( 'active_plugins', array () );
87 | $sitewide_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
88 | return array_unique( array_merge( $site_plugins, $sitewide_plugins ) );
89 | }
90 |
91 | /**
92 | * Find all plugins that are active.
93 | */
94 | public function find_plugins() {
95 | $configs = $this->get_configs();
96 |
97 | $active_plugins = $this->get_all_active_plugins();
98 |
99 | if ( ! empty( $configs ) ) {
100 | foreach ( $configs['plugins'] as $name => $plugin ) {
101 | $this->boldgrid_plugins_status[$name] = false !== array_search( $plugin['path'],
102 | $active_plugins );
103 | }
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/includes/deploy/class-crio-utility.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 |
11 | namespace Boldgrid\Inspirations\Deploy;
12 |
13 | /**
14 | * Crio Utility class.
15 | *
16 | * @since sinceversion
17 | */
18 | class Crio_Utility {
19 | /**
20 | * Setup our template locations taxonomy.
21 | *
22 | * This code is copied directly from Crio. In the future, it would help if these were static methods
23 | * within Crio that we could call directly.
24 | * @see /src/includes/page-headers/templates/class-crio-premium-page-headers-templates.php
25 | *
26 | * @since SINCEVERSION
27 | */
28 | public static function register_template_locations() {
29 | $taxonomy = 'template_locations';
30 |
31 | // Labels part for the GUI
32 | $labels = array(
33 | 'name' => __( 'Template Location', 'bgtfw' ),
34 | 'singular_name' => _x( 'Template Location', 'taxonomy singular name' ),
35 | 'search_items' => __( 'Search Template Locations', 'bgtfw' ),
36 | 'all_items' => null,
37 | 'parent_item' => null,
38 | 'parent_item_colon' => null,
39 | 'edit_item' => __( 'Edit Template Location', 'bgtfw' ),
40 | 'update_item' => __( 'Update Template Location', 'bgtfw' ),
41 | 'add_new_item' => null,
42 | 'new_item_name' => null,
43 | 'menu_name' => __( 'Template Locations', 'bgtfw' ),
44 | 'most_used' => null,
45 | );
46 |
47 | $locations = array(
48 | 'header',
49 | 'sticky-header',
50 | 'footer',
51 | );
52 |
53 | // Register our taxonomy. It may already exist if Crio is already installed.
54 | if ( ! taxonomy_exists( $taxonomy ) ) {
55 | register_taxonomy(
56 | $taxonomy,
57 | 'crio_page_header',
58 | array(
59 | 'hierarchical' => true,
60 | 'labels' => $labels,
61 | 'public' => true,
62 | 'show_ui' => true,
63 | 'show_in_menu' => false,
64 | 'show_in_rest' => true,
65 | 'update_count_callback' => '_update_post_term_count',
66 | 'query_var' => true,
67 | 'rewrite' => array( 'slug' => 'template_location' ),
68 | 'meta_box_cb' => false,
69 | 'capabilities' => array(
70 | 'manage_terms' => '',
71 | 'edit_terms' => '',
72 | 'delete_terms' => '',
73 | 'assign_terms' => 'edit_posts',
74 | ),
75 | )
76 | );
77 | }
78 |
79 | // Add our terms.
80 | foreach ( $locations as $slug ) {
81 | $name = ucwords( str_replace( '-', ' ', $slug ) );
82 | // Crio may already be installed, so check for existing terms.
83 | if ( ! term_exists( $slug, $taxonomy ) ) {
84 | wp_insert_term( $name, $taxonomy, array( 'slug' => $slug ) );
85 | }
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/includes/class-boldgrid-inspirations-attribution-update.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 |
11 | /**
12 | * The BoldGrid Attribution Update class.
13 | *
14 | * This file includes all functionality necessary to ensure our "Custom Post Type" attribution pages
15 | * are backwards compatible.
16 | *
17 | * @since 1.3.1
18 | */
19 | class Boldgrid_Inspirations_Attribution_Update {
20 |
21 | /**
22 | * Add hooks.
23 | *
24 | * @since 1.3.1
25 | */
26 | public function add_hooks() {
27 | $this->upgrade_to_cpt();
28 |
29 | add_filter( 'pre_option_boldgrid_staging_boldgrid_attribution', array( $this, 'pre_option_boldgrid_attribution' ), 20 );
30 | add_filter( 'pre_option_boldgrid_attribution', array( $this, 'pre_option_boldgrid_attribution' ), 20 );
31 | }
32 |
33 | /**
34 | * Return older format of boldgrid_attribution option.
35 | *
36 | * @since 1.3.1
37 | */
38 | public function pre_option_boldgrid_attribution() {
39 | $return = array();
40 |
41 | $attribution_page = Boldgrid_Inspirations_Attribution_Page::get();
42 |
43 | $return['page']['id'] = $attribution_page->ID;
44 |
45 | return $return;
46 | }
47 |
48 |
49 | /**
50 | * Upgrade the Attribution system to use custom post types.
51 | *
52 | * @since 1.3.1
53 | */
54 | public function upgrade_to_cpt() {
55 | /*
56 | * Do we need to perform this upgrade?
57 | *
58 | * This upgrade only needs to be ran once. If the option
59 | * boldgrid_attribution_upgraded_to_cpt has a value, it means that we've already ran this
60 | * method.
61 | *
62 | * Part of the upgrade process involves flush_rewrite_rules. It is when we run that, that we
63 | * set boldgrid_attribution_upgraded_to_cpt to true. Please see:
64 | * BoldGrid_Inspirations_Attribution_Page::register_post_type();
65 | */
66 | if( false !== get_option( 'boldgrid_attribution_upgraded_to_cpt' ) ) {
67 | return;
68 | }
69 |
70 | $lang = Boldgrid_Inspirations_Attribution::get_lang();
71 |
72 | // These are the pages that we will find and delete.
73 | $slugs = array( $lang['attribution'], $lang['attribution'] . '-staging' );
74 |
75 | foreach( $slugs as $slug ) {
76 | $attribution_page = get_page_by_path( $slug );
77 |
78 | if( is_object( $attribution_page ) && isset( $attribution_page->ID ) ) {
79 | $attribution_page->post_type = $lang['post_type'];
80 | wp_delete_post( $attribution_page->ID, true );
81 | }
82 | }
83 |
84 | // Flag this option as true so that the next visit to Attribution triggers a rebuild.
85 | update_option( 'boldgrid_attribution_rebuild', true );
86 | update_option( 'boldgrid_staging_boldgrid_attribution_rebuild', true );
87 |
88 | // These options are no longer needed, delete them.
89 | delete_option( 'boldgrid_attribution' );
90 | delete_option( 'boldgrid_staging_boldgrid_attribution' );
91 | }
92 | }
--------------------------------------------------------------------------------
/pages/attribution.php:
--------------------------------------------------------------------------------
1 | ' . esc_html__( 'This site has been created with the help of many different people and companies.', 'boldgrid-inspirations' ) . '';
6 | $attribution_image_heading = '
' . esc_html__( 'In particular, a special thanks goes to the following for content running on this site:', 'boldgrid-inspirations' ) . '
';
7 |
8 | // Create attribution for the web host reseller.
9 | $reseller = get_option( 'boldgrid_reseller' );
10 |
11 | if ( false !== $reseller && ! empty( $reseller['reseller_title'] ) ) {
12 | if ( ! empty( $reseller['reseller_website_url'] ) ) {
13 | $reseller_link = '' . esc_html( $reseller['reseller_title'] ) . '.';
14 | } else {
15 | $reseller_link = $reseller['reseller_title'] . '.';
16 | }
17 | // translators: 1 a link to the resller.
18 | $reseller_attribution = ' ' . sprintf( __( 'Web hosting support is provided by %1$s', 'boldgrid-inspirations' ), $reseller_link );
19 | } else {
20 | $reseller_attribution = '';
21 | }
22 |
23 | // This var used by includes/class-boldgrid-inspirations-attribution.php.
24 | $attribution_wordpress_and_inspirations =
25 | '
%s ' .
26 | sprintf(
27 | wp_kses(
28 | // translators: 1 a link to boldgrid.com, 2 a link to wordpress.org.
29 | __( 'site was built on a powerful, Inspirations based web builder called %1$s. It is running on %2$s, the most popular content management software online today.', 'boldgrid-inspirations' ),
30 | array( 'a' => array( 'href' => array() ), 'target' => array(), )
31 | ),
32 | 'BoldGrid',
33 | 'WordPress'
34 | ) .
35 | $reseller_attribution .
36 | '
';
37 |
38 | /*
39 | * Create attribution for plugins we install from 3rd Party sources.
40 | *
41 | * This var used by includes/class-boldgrid-inspirations-attribution.php
42 | */
43 | $attribution_additional_plugins = '';
44 | if ( function_exists( 'is_plugin_active' ) ) {
45 | // Check if some plugins are active.
46 | $is_boldgrid_ninja_forms_active = ( bool ) is_plugin_active( 'boldgrid-ninja-forms/ninja-forms.php' );
47 | $is_boldgrid_gallery_active = ( bool ) is_plugin_active( 'boldgrid-gallery/wc-gallery.php' );
48 |
49 | if ( $is_boldgrid_ninja_forms_active || $is_boldgrid_gallery_active ) {
50 | $attribution_additional_plugins .= '
51 |
50 |
51 | Creative Commons, but it is not a guarantee it is legally Creative Commons. Those images may be subject to other copyrights. You, as the website owner, are responsible for content on your site.', 'boldgrid-inspirations' ),
56 | array( 'a' => array( 'href' => array(), 'target' => array() ) )
57 | ),
58 | 'https://creativecommons.org/about/'
59 | );
60 | ?>
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/includes/deploy/class-social-menu.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 |
11 | namespace Boldgrid\Inspirations\Deploy;
12 |
13 | /**
14 | * Social Menu class.
15 | *
16 | * @since 2.5.0
17 | */
18 | class Social_Menu {
19 | /**
20 | * Our deploy class.
21 | *
22 | * @since 2.5.0
23 | * @access private
24 | * @var Boldgrid_Inspirations_Deploy
25 | */
26 | private $deploy;
27 |
28 | /**
29 | * Constructor.
30 | *
31 | * @since 2.5.0
32 | *
33 | * @param Boldgrid_Inspirations_Deploy $deploy
34 | */
35 | public function __construct( \Boldgrid_Inspirations_Deploy $deploy ) {
36 | $this->deploy = $deploy;
37 | }
38 |
39 | /**
40 | * Create a unique menu for our social links.
41 | *
42 | * @since 2.5.0
43 | *
44 | * @param string $name Menu name.
45 | * @return int Id of menu created.
46 | */
47 | public function create_menu( $name ) {
48 | $original_name = $name;
49 | $count = 2;
50 |
51 | /*
52 | * Get a unique name for our menu.
53 | *
54 | * Start off by trying to create $name. If it doesn't exist, try $name-1, $name-2, etc.
55 | */
56 | $menu_object = wp_get_nav_menu_object( $name );
57 | while( ! empty( $menu_object ) ) {
58 | $name = $original_name . '-' . $count;
59 | $menu_object = wp_get_nav_menu_object( $name );
60 | $count++;
61 | }
62 |
63 | return wp_create_nav_menu( $name );
64 | }
65 |
66 | /**
67 | * Create a social media menu based off of survey data and assign to social nav menu location.
68 | *
69 | * This method should only be ran for Crio themes.
70 | *
71 | * This method has been introduced for Crio. Prior, the social media menu was created by filtering
72 | * the bgtfw configs. As of Crio, that code no longer exists, and so we must actually create a menu.
73 | *
74 | * @since 2.5.0
75 | */
76 | public function deploy() {
77 | // Make sure we have social media data.
78 | $socials = $this->get_social();
79 | if ( empty( $socials ) ) {
80 | return;
81 | }
82 |
83 | // Create a menu.
84 | $menu_id = $this->create_menu( 'social' );
85 | if ( is_wp_error( $menu_id ) ) {
86 | return;
87 | }
88 |
89 | // Add all of our menu items.
90 | foreach ( $socials as $network => $url ) {
91 | wp_update_nav_menu_item(
92 | $menu_id,
93 | 0,
94 | [
95 | 'menu-item-title' => $network,
96 | 'menu-item-url' => $url,
97 | 'menu-item-status' => 'publish',
98 | ]
99 | );
100 | }
101 |
102 | // Save our new menu to the theme's nav_menu_locations.
103 | $locations = get_theme_mod( 'nav_menu_locations', array() );
104 | $locations['footer-social'] = $menu_id;
105 | $locations['social'] = $menu_id;
106 | set_theme_mod( 'nav_menu_locations', $locations );
107 | }
108 |
109 | /**
110 | * Get our social media data.
111 | *
112 | * Data is gathered from the user via the Inspirations process.
113 | *
114 | * @since 2.5.0
115 | *
116 | * @return array Example: https://pastebin.com/ANt5G8uq
117 | */
118 | public function get_social() {
119 | $social = $this->deploy->survey->get_social();
120 |
121 | // Preview sites should show a social media menu. If preview server, set dummy data.
122 | if ( empty( $social ) && $this->deploy->is_preview_server ) {
123 | $social = [
124 | 'facebook' => 'https://facebook.com',
125 | 'twitter' => 'https://twitter.com',
126 | ];
127 | }
128 |
129 | return $social;
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/assets/js/handlebars/templates/preview.php:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
26 |
27 |
37 |
38 |
47 |
48 |
54 |
55 |
56 |
57 |
62 |
63 |
71 |
72 |
81 |
82 |
83 |
84 |
105 |
106 |
113 |
--------------------------------------------------------------------------------
/includes/class-boldgrid-inspirations-file.php:
--------------------------------------------------------------------------------
1 |
9 | *
10 | */
11 |
12 | /**
13 | * The BoldGrid File class.
14 | */
15 | class Boldgrid_Inspiration_File {
16 | /**
17 | * Zip.
18 | *
19 | * @link http://stackoverflow.com/questions/1334613/how-to-recursively-zip-a-directory-in-php
20 | *
21 | * @param unknown $source
22 | * @param unknown $destination
23 | * @return boolean
24 | */
25 | public function zip( $source, $destination, $include_dir = true ) {
26 | if ( ! extension_loaded( 'zip' ) || ! file_exists( $source ) ) {
27 | wp_die(
28 | esc_html__( 'You do not have the zip extension loaded', 'boldgrid-inspirations' )
29 | );
30 |
31 | return false;
32 | }
33 |
34 | if ( file_exists( $destination ) ) {
35 | unlink( $destination );
36 | }
37 |
38 | $zip = new ZipArchive();
39 |
40 | if ( ! $zip->open( $destination, ZIPARCHIVE::CREATE ) ) {
41 | return false;
42 | }
43 | $source = str_replace( '\\', '/', realpath( $source ) );
44 |
45 | if ( is_dir( $source ) ) {
46 |
47 | $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $source ),
48 | RecursiveIteratorIterator::SELF_FIRST );
49 |
50 | if ( $include_dir ) {
51 |
52 | $arr = explode( '/', $source );
53 | $maindir = $arr[count( $arr ) - 1];
54 |
55 | $source = '';
56 | for ( $i = 0; $i < count( $arr ) - 1; $i ++ ) {
57 | $source .= '/' . $arr[$i];
58 | }
59 |
60 | $source = substr( $source, 1 );
61 |
62 | $zip->addEmptyDir( $maindir );
63 | }
64 |
65 | foreach ( $files as $file ) {
66 | $file = str_replace( '\\', '/', $file );
67 |
68 | // Ignore "." and ".." folders
69 | if ( in_array( substr( $file, strrpos( $file, '/' ) + 1 ),
70 | array(
71 | '.',
72 | '..',
73 | ), true ) ) {
74 | continue;
75 | }
76 |
77 | $file = realpath( $file );
78 |
79 | if ( is_dir( $file ) ) {
80 | $zip->addEmptyDir( str_replace( $source . '/', '', $file . '/' ) );
81 | } else if ( is_file( $file ) ) {
82 | $zip->addFromString( str_replace( $source . '/', '', $file ),
83 | file_get_contents( $file ) );
84 | }
85 | }
86 | } else if ( is_file( $source ) ) {
87 | $zip->addFromString( basename( $source ), file_get_contents( $source ) );
88 | }
89 |
90 | return $zip->close();
91 | }
92 |
93 | /**
94 | * Pass this function an absolute path to a directory.
95 | * It will scan the directory and return info about the file last updated.
96 | *
97 | * @param unknown $dir
98 | * @return Ambigous
99 | */
100 | public function oldest_file_timestamp_in_directory( $dir ) {
101 | $greatest['time'] = 0;
102 | $greatest['file'] = '';
103 | $result = scandir( $dir );
104 |
105 | foreach ( $result as $k => $v ) {
106 | // if we're dealing with . or .., continue
107 | if ( in_array( $v, array(
108 | '.',
109 | '..'
110 | ), true ) ) {
111 | continue;
112 | }
113 |
114 | // If this is a file.
115 | $full_path = $dir . '/' . $v;
116 |
117 | if ( is_file( $full_path ) ) {
118 | // Get the timestamp of this file.
119 | $files_unix_time = filemtime( $dir . '/' . $v );
120 |
121 | // If it's the oldest file, keep track of it.
122 | if ( $files_unix_time > $greatest['time'] ) {
123 | $greatest['time'] = $files_unix_time;
124 | $greatest['file'] = $full_path;
125 | }
126 | } elseif ( is_dir( $full_path ) ) {
127 | $directorys_greatest = $this->oldest_file_timestamp_in_directory( $full_path );
128 | if ( $directorys_greatest['time'] > $greatest['time'] ) {
129 | $greatest['time'] = $directorys_greatest['time'];
130 | $greatest['file'] = $directorys_greatest['file'];
131 | }
132 | }
133 | }
134 |
135 | return $greatest;
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/includes/class-boldgrid-inspirations-installed.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 |
11 | /**
12 | * The BoldGrid Inspiration Installed class.
13 | *
14 | * This class is responsible for checking on the content that Inspirations has installed.
15 | *
16 | * @since 1.7.0
17 | */
18 | class Boldgrid_Inspirations_Installed {
19 | /**
20 | * Get all pages installed by Inspirations.
21 | *
22 | * @since 1.7.0
23 | *
24 | * @link https://developer.wordpress.org/reference/functions/get_posts/
25 | *
26 | * @return array An array of post objects or post IDs.
27 | */
28 | public function get_all_pages( $args = array() ) {
29 | $page_ids = $this->get_page_ids( false );
30 |
31 | $defaults = array(
32 | 'include' => $page_ids,
33 | 'post_type' => 'any',
34 | );
35 |
36 | $args = wp_parse_args( $args, $defaults );
37 |
38 | $pages = get_posts( $args );
39 |
40 | return $pages;
41 | }
42 |
43 | /**
44 | * Get the page id's installed via Inspirations.
45 | *
46 | * They are stored as an array in the following format:
47 | * # KEY - The page id on the API server.
48 | * # VALUE - The local WordPress page id.
49 | *
50 | * Example: https://pastebin.com/drmnU0VC
51 | *
52 | * @since 1.7.0
53 | *
54 | * @param bool $as_is True to return the raw option value, false to return only the local page ids.
55 | */
56 | public function get_page_ids( $as_is = true ) {
57 | $page_ids = get_option( 'boldgrid_installed_page_ids', array() );
58 |
59 | return $as_is ? $page_ids : array_values( $page_ids );
60 | }
61 |
62 | /**
63 | * Get all posts that Inspirations installed.
64 | *
65 | * This can be used to check whether or not the Inspirations process installed a blog or any
66 | * other posts.
67 | *
68 | * @return array An array of post objects or post IDs.
69 | */
70 | public function get_all_posts() {
71 | $args = array(
72 | 'post_type' => 'post',
73 | );
74 |
75 | return $this->get_all_pages( $args );
76 | }
77 |
78 | /**
79 | * Get a single install option.
80 | *
81 | * @since 1.7.0
82 | *
83 | * @param string $key The specific install option.
84 | * @param mixed $default The default value returned if install option does not exist.
85 | * @return mixed
86 | */
87 | public function get_install_option( $key, $default = false ) {
88 | $options = $this->get_install_options();
89 |
90 | return isset( $options[$key] ) ? $options[$key] : $default;
91 | }
92 |
93 | /**
94 | * Get the install options.
95 | *
96 | * Management of the 'boldgrid_install_options' option was originally within the deploy class,
97 | * and has been moved here as of 1.7.0.
98 | *
99 | * @since 1.7.0
100 | *
101 | * @return array
102 | */
103 | public function get_install_options() {
104 | return get_option( 'boldgrid_install_options', array() );
105 | }
106 |
107 | /**
108 | * Determine whether or not we have deployed a site with Inspirations.
109 | *
110 | * @since 1.7.0
111 | *
112 | * @return bool
113 | */
114 | public static function has_built_site() {
115 | return 'yes' === get_option( 'boldgrid_has_built_site' );
116 | }
117 |
118 | /**
119 | * Check whether or not Inspirations has installed any posts.
120 | *
121 | * @since 1.7.0
122 | *
123 | * @return bool
124 | */
125 | public function has_installed_posts() {
126 | $posts = $this->get_all_posts();
127 |
128 | return ! empty( $posts );
129 | }
130 |
131 | /**
132 | * Update the install options.
133 | *
134 | * Management of the 'boldgrid_install_options' option was originally within the deploy class,
135 | * and has been moved here as of 1.7.0.
136 | *
137 | * @since 1.7.0
138 | *
139 | * @param array $args
140 | */
141 | public function update_install_options( $args = array() ) {
142 | update_option( 'boldgrid_install_options', $args );
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/includes/class-boldgrid-inspirations-deploy-pages.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 |
11 | /**
12 | * Class: Boldgrid_Inspirations_Deploy_Pages.
13 | *
14 | * Responsible for installing pages during deployment.
15 | *
16 | * @since 1.0.7
17 | * @package Boldgrid_Inspirations_Deploy_Pages.
18 | * @subpackage Boldgrid_Inspirations_Deploy_Pages.
19 | * @author BoldGrid .
20 | *
21 | * @link https://boldgrid.com.
22 | */
23 | class Boldgrid_Inspirations_Deploy_Pages {
24 |
25 | /**
26 | * Variables relevant to page deploment.
27 | *
28 | * @since 1.0.7
29 | * @access protected
30 | * @var array $deployment_variables
31 | */
32 | protected $deployment_variables = array ();
33 |
34 | /**
35 | * Temporary pages created for the purpose of forcing image replacement.
36 | *
37 | * @since 1.0.7
38 | * @access protected
39 | * @var array $temp_pages
40 | */
41 | protected $temp_pages;
42 |
43 | /**
44 | * Pass deployment variables that are relevant to page installation
45 | *
46 | * @param array $deployment_variables
47 | * Variables relevant to page installation
48 | */
49 | public function __construct( $deployment_variables ) {
50 | $this->deployment_variables = $deployment_variables;
51 | }
52 |
53 | /**
54 | * Create pages so that when the images are dynamically inserted,
55 | * the content markup us updated with the image urls.
56 | *
57 | * @since 1.0.7
58 | *
59 | * @param array $full_page_list
60 | * List of all pages returned from asset sever.
61 | * @return array $installed_page_ids List of installed pages.
62 | */
63 | public function deploy_temp_pages( $full_page_list, $installed_page_ids ) {
64 | $this->temp_pages = array ();
65 | $requested_ids = array_keys( $installed_page_ids );
66 | if ( ! empty( $full_page_list['pages']['additional'] ) ) {
67 | foreach ( $full_page_list['pages']['additional'] as $page ) {
68 |
69 | // Set Page variables
70 | $post['post_content'] = $page->code;
71 | $post['post_name'] = $page->page_slug;
72 | $post['post_title'] = $page->page_title;
73 | $post['post_status'] = $this->deployment_variables['post_status'];
74 | $post['post_type'] = $page->post_type;
75 | $post['comment_status'] = 'closed';
76 |
77 | // Insert Post
78 | $post_id = wp_insert_post( $post );
79 |
80 | $this->temp_pages[$page->id] = $post_id;
81 |
82 | /**
83 | * Create an entry into installed page_ids
84 | * This occurs AFTER this option is stored into the the DB,
85 | * but before this class property is used to replace media images
86 | */
87 | $installed_page_ids[$page->id] = $post_id;
88 | }
89 | }
90 |
91 | return $installed_page_ids;
92 | }
93 |
94 | /**
95 | * Create pages so that when the images are dynamically inserted,
96 | * the content markup us updated with the image urls.
97 | *
98 | * @since 1.0.7
99 | *
100 | * @param array $full_page_list
101 | * List of all pages returned from asset sever.
102 | * @param array $installed_page_ids
103 | * List of installed pages.
104 | */
105 | public function cleanup_temp_pages( $full_page_list, $installed_page_ids ) {
106 | $posts = array ();
107 |
108 | foreach ( $installed_page_ids as $page_id => $post_id ) {
109 | $post = get_post( $post_id );
110 |
111 | // Store updated Content
112 | $posts[$page_id] = $post->post_content;
113 |
114 | // Delete the temp post
115 | if ( ! empty( $this->temp_pages[$page_id] ) ) {
116 | wp_delete_post( $this->temp_pages[$page_id], true );
117 | }
118 | }
119 |
120 | foreach ( $full_page_list['pages']['pages_in_pageset'] as &$page ) {
121 | $page->code = ! empty( $posts[$page->id] ) ? $posts[$page->id] : '';
122 | }
123 | foreach ( $full_page_list['pages']['additional'] as &$page ) {
124 | $page->code = ! empty( $posts[$page->id] ) ? $posts[$page->id] : '';
125 | }
126 |
127 | update_option( 'boldgrid_static_pages', $full_page_list );
128 | }
129 | }
--------------------------------------------------------------------------------
/includes/class-boldgrid-inspirations-deploy-post.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 |
11 | /**
12 | * The BoldGrid Inspiration Deploy Post class.
13 | *
14 | * This class handles tasks to take after a deployment has finished.
15 | *
16 | * @since 1.7.0
17 | */
18 | class Boldgrid_Inspirations_Deploy_Post {
19 | /**
20 | * An instance of Boldgrid_Inspirations_Deploy_Status.
21 | *
22 | * @since 1.7.0
23 | * @access private
24 | * @var Boldgrid_Inspirations_Deploy_Status
25 | */
26 | private $deploy_status;
27 |
28 | /**
29 | * An instance of Boldgrid_Inspirations_Installed.
30 | *
31 | * @since 1.7.0
32 | * @access private
33 | * @var Boldgrid_Inspirations_Installed
34 | */
35 | private $installed;
36 |
37 | /**
38 | * Whether or not we are in the call immediately after a deployment.
39 | *
40 | * This is the call that triggers the after_switch_theme action.
41 | *
42 | * @since 1.7.0
43 | * @access private
44 | * @var bool
45 | */
46 | private $is_post_deploy = false;
47 |
48 | /**
49 | * Constructor.
50 | *
51 | * @since 1.7.0
52 | */
53 | public function __construct() {
54 | $this->is_post_deploy = ! empty( $_GET['doing_wp_cron'] ) && 'fire-after-theme-switch-hooks' === $_GET['doing_wp_cron'];
55 |
56 | $this->installed = new Boldgrid_Inspirations_Installed();
57 |
58 | $this->deploy_status = new Boldgrid_Inspirations_Deploy_Status();
59 | }
60 |
61 | /**
62 | * Add hooks.
63 | *
64 | * These hooks are added via the Boldgrid_Inspirations_Inspiration class, within its
65 | * add_hooks_always method. These hooks are added regardless of is_admin().
66 | *
67 | * This method is ran within the "init" filter. Keep this in mind when adding filters below.
68 | *
69 | * @since 1.7.0
70 | */
71 | public function add_hooks() {
72 | add_filter( 'option_theme_switched', array( $this, 'stop_switch_theme' ), 10, 2 );
73 |
74 | if ( $this->is_post_deploy ) {
75 | add_filter( 'after_switch_theme', array( $this, 'install_widgets' ), 15 );
76 |
77 | if ( ! empty( $_POST['install_cache'] ) ) {
78 | add_filter( 'wp_loaded', '\Boldgrid\Inspirations\W3TC\Utility::deploy_post_setup' );
79 | }
80 | }
81 | }
82 |
83 | /**
84 | * Install widgets after a deployment.
85 | *
86 | * @since 1.7.0
87 | */
88 | public function install_widgets() {
89 | // If we installed a blog, setup the blog widgets.
90 | if ( $this->installed->get_install_option( 'install_blog' ) ) {
91 | $configs = Boldgrid_Inspirations_Config::get_format_configs();
92 |
93 | $blog = new Boldgrid_Inspirations_Blog( $configs );
94 | $blog->create_sidebar_widgets();
95 | }
96 | }
97 |
98 | /**
99 | * Prevent "after_switch_theme" action from running too soon.
100 | *
101 | * Within WordPress' switch_theme() function, the "theme_switched" option is set to the old
102 | * theme's stylesheet at the end of the method:
103 | * @link https://github.com/WordPress/WordPress/blob/03240dd3f4442546562824bc6a10ed7c197bd6b2/wp-includes/theme.php#L780
104 | *
105 | * If the "theme_switched" option is found, then ultimately the "after_switch_theme" action will
106 | * be ran.
107 | * @link https://github.com/WordPress/WordPress/blob/03240dd3f4442546562824bc6a10ed7c197bd6b2/wp-includes/theme.php#L2875
108 | *
109 | * If we are in the middle of deploying a site with Inspirations, then we don't want the
110 | * "after_switch_theme" action to run, as we're still in the middle of setting up the new site.
111 | *
112 | * To prevent this from happening, we will hook into the call to get the "theme_switched" option
113 | * and return false if we're in the middle of a deployment.
114 | *
115 | * @since 1.7.0
116 | *
117 | * @param mixed $value Value of the option. If stored serialized, it will be unserialized prior
118 | * to being returned.
119 | * @param string $option Option name.
120 | *
121 | */
122 | public function stop_switch_theme( $value, $option ) {
123 | return $this->deploy_status->is_deploying() ? false : $value;
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/pages/templates/boldgrid-inspirations.php:
--------------------------------------------------------------------------------
1 |
19 |
20 |
69 |
70 |
83 |
84 |
--------------------------------------------------------------------------------
/includes/class-boldgrid-inspirations-blog.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 |
11 | /**
12 | * BoldGrid Blog class.
13 | *
14 | * @since 1.4
15 | */
16 | class Boldgrid_Inspirations_Blog {
17 |
18 | /**
19 | * Configs.
20 | *
21 | * @since 1.4
22 | * @var array
23 | */
24 | public $configs;
25 |
26 | /**
27 | * The page id of the blog page.
28 | *
29 | * @since SINCEVERSION
30 | * @var int
31 | */
32 | public $page_id;
33 |
34 | /**
35 | * The title of our blog page.
36 | *
37 | * @since SINCEVERSION
38 | * @var string
39 | */
40 | public $title;
41 |
42 | /**
43 | * Constructor.
44 | *
45 | * @since 1.4
46 | *
47 | * @param array $configs
48 | */
49 | public function __construct( $configs = array() ) {
50 | $this->configs = $configs;
51 | $this->title = __( 'Blog', 'boldgrid-inspirations' );
52 | }
53 |
54 | /**
55 | * Create the blog menu item.
56 | *
57 | * @since 1.4
58 | *
59 | * @param int $menu_id
60 | * @param int $menu_order Default value is 150. This number was previously in the code without
61 | * any comments.
62 | */
63 | public function create_menu_item( $menu_id, $menu_order = 150 ) {
64 | $data = array(
65 | 'menu-item-object-id' => $this->page_id,
66 | 'menu-item-parent-id' => 0,
67 | 'menu-item-object' => 'page',
68 | 'menu-item-type' => 'post_type',
69 | 'menu-item-status' => 'publish',
70 | 'menu-item-position' => $menu_order,
71 | );
72 |
73 | return wp_update_nav_menu_item( $menu_id, 0, $data );
74 | }
75 |
76 | /**
77 | * Create our blog page.
78 | *
79 | * @since SINCEVERSION
80 | */
81 | public function create_page() {
82 | $page = Boldgrid_Inspirations_Utility::get_page_by_title( $this->title );
83 |
84 | if ( ! empty( $page->post_status ) && 'published' === $page->post_status ) {
85 | $page_id = $page->ID;
86 | } else {
87 | $page_id = wp_insert_post( array(
88 | 'post_title' => $this->title,
89 | 'post_name' => sanitize_key( $this->title ),
90 | 'post_status' => 'publish',
91 | 'post_type' => 'page',
92 | 'comment_status' => 'closed',
93 | ) );
94 | }
95 |
96 | $this->page_id = (int) $page_id;
97 |
98 | return ! empty( $this->page_id );
99 | }
100 |
101 | /**
102 | * Create widgets.
103 | *
104 | * During an Inspirations Deployment, if we are installing a blog, create a set of widgets and
105 | * add them to the sidebar.
106 | *
107 | * @since 1.4
108 | */
109 | public function create_sidebar_widgets() {
110 | /*
111 | * Set our sidebar id.
112 | *
113 | * With v1 themes it used to be 'sidebar-1'. As Inspirations has transitioned to installing
114 | * Crio themes, the sidebar is now 'primary-sidebar'.
115 | */
116 | $theme = wp_get_theme();
117 | $sidebar = 'Crio' === $theme->get( 'Name' ) ? 'primary-sidebar' : 'sidebar-1';
118 |
119 | /**
120 | * Filter the sidebar to add our new widgets to.
121 | *
122 | * Not all themes have a 'sidebar-1'.
123 | *
124 | * @since 1.4
125 | *
126 | * @param string $sidebar.
127 | */
128 | $sidebar = apply_filters( 'boldgrid_deploy_blog_sidebar', $sidebar );
129 |
130 | $widgets_to_create = $this->configs[ 'new_blog_widgets' ];
131 |
132 | /**
133 | * Filter the widgets that we will create.
134 | *
135 | * @since 1.4
136 | *
137 | * @param array $widgets_to_create An array of widgets.
138 | */
139 | $widgets_to_create = apply_filters( 'boldgrid_deploy_blog_widgets', $widgets_to_create );
140 |
141 | /*
142 | * Empty the sidebar before we start adding widgets to it, otherwise we will end up with
143 | * duplicate items in the sidebar after more than one deployment.
144 | */
145 | Boldgrid_Inspirations_Widget::empty_sidebar( $sidebar );
146 |
147 | foreach( $widgets_to_create as $widget ) {
148 | $key = Boldgrid_Inspirations_Widget::create_widget( $widget['type'], $widget['value'] );
149 |
150 | Boldgrid_Inspirations_Widget::add_to_sidebars( $sidebar, $widget['type'] . '-' . $key );
151 | }
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/assets/js/ajax/ajax.js:
--------------------------------------------------------------------------------
1 | var IMHWPB = IMHWPB || {};
2 |
3 | IMHWPB.Ajax = function( configs ) {
4 | var self = this;
5 |
6 | this.configs = configs;
7 | this.api_url = this.configs.asset_server;
8 | this.api_key = this.configs.api_key;
9 | this.site_hash = this.configs.site_hash;
10 | this.lang = BoldGridInspirationsAjax;
11 |
12 | /**
13 | * Execute an AJAX call.
14 | *
15 | * @param array data Data to sent via POST.
16 | * @param string requestUrlKey Configuration index for the URL.
17 | * @param function successAction The success/done callback function.
18 | * @param function errorAction The errorAction/fail callback function.
19 | * @param function completeAction The completeAction/always callback function.
20 | */
21 | this.ajaxCall = function( data, requestUrlKey, successAction, errorAction, completeAction ) {
22 | self.data = data || {};
23 | self.requestUrlKey = requestUrlKey;
24 |
25 | if ( 'function' !== typeof errorAction ) {
26 | errorAction = self.errorAction;
27 | }
28 | if ( 'function' !== typeof completeAction ) {
29 | completeAction = function() {
30 | /** No Default * */
31 | };
32 | }
33 |
34 | data.key = self.api_key;
35 | data.site_hash = self.site_hash;
36 |
37 | jQuery.ajax( {
38 | type : 'POST',
39 | url : self.api_url + self.configs.ajax_calls[requestUrlKey],
40 | data : data,
41 | timeout : 120000,
42 | requestHeaders : {
43 | Accept : 'application/json'
44 | },
45 | dataType : 'json',
46 | } )
47 | .done( successAction )
48 | .fail ( [
49 | errorAction,
50 | self.errorLogAction
51 | ] )
52 | .always( completeAction );
53 | };
54 |
55 | /**
56 | * Error handling.
57 | */
58 | this.errorAction = function( jqXHR, textStatus, errorThrown ) {
59 | var message, $wpbody;
60 |
61 | switch ( textStatus ) {
62 | case 'timeout':
63 | message = self.lang.timeout;
64 | break;
65 |
66 | case 'parsererror':
67 | message = self.lang.unexpected;
68 | break;
69 |
70 | default:
71 | break;
72 | }
73 |
74 | if ( window.parent.jQuery( '#wpbody-content' ).length ) {
75 | $wpbody = window.parent.jQuery( '#wpbody-content' );
76 | } else {
77 | $wpbody = jQuery( '#wpbody-content' );
78 | }
79 |
80 | // Provide a friendly error for comm failure, if notice is not already displayed.
81 | if ( ! window.parent.jQuery( '#container_boldgrid_connection_notice' ).length &&
82 | ! jQuery( '#container_boldgrid_connection_notice' ).length ) {
83 | if ( message ) {
84 | message += ' ';
85 | } else {
86 | message = '';
87 | }
88 |
89 | $wpbody
90 | .hide()
91 | .before(
92 | '
103 | BoldGrid Inspirations', esc_url( add_query_arg( 'page', 'boldgrid-inspirations', admin_url( 'admin.php' ) ) ) );
105 | // translators: 1 The url to access BoldGrid Inspirations in your WordPress dashboard.
106 | printf( __( 'You do not have a BoldGrid site to delete! You can build a new website using %1$s.', 'boldgrid-inspirations' ), $link );
107 | ?>
108 |