Skip to content

Commit

Permalink
1.2.0, block types, updater
Browse files Browse the repository at this point in the history
  • Loading branch information
JiveDig committed Jun 20, 2023
1 parent bf12141 commit dec430f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 1.2.0 (6/20/23)
* Changed: Rename to Mai Theme Pro plugin.
* Changed: Update the updater.
* Added: Add Block Types to Mai Post Grid patterns.

## 1.1.0 (8/10/22)
* Added: Block patterns are now included inside the plugin. Easily insert them directly into your posts/pages.
Expand Down
34 changes: 17 additions & 17 deletions mai-design-pack.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

/**
* Plugin Name: Mai Design Pack
* Plugin URI: https://bizbudding.com/mai-design-pack/
* Plugin Name: Mai Theme Pro Plugin (formerly Mai Design Pack)
* Plugin URI: https://bizbudding.com/mai-theme-pro/
* Description: Unlimited access to all Mai Plugins, and more. Requires Mai Theme v2.
* Version: 1.1.0
* Version: 1.2.0
*
* Author: BizBudding
* Author URI: https://bizbudding.com
Expand All @@ -13,6 +13,9 @@
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;

// Must be at the top of the file.
use YahnisElsts\PluginUpdateChecker\v5\PucFactory;

/**
* Main Mai_Design_Pack Class.
*
Expand Down Expand Up @@ -88,7 +91,7 @@ public function __wakeup() {
private function setup_constants() {
// Plugin version.
if ( ! defined( 'MAI_DESIGN_PACK_VERSION' ) ) {
define( 'MAI_DESIGN_PACK_VERSION', '1.1.0' );
define( 'MAI_DESIGN_PACK_VERSION', '1.2.0' );
}

// Plugin Folder Path.
Expand Down Expand Up @@ -140,7 +143,7 @@ private function includes() {
public function hooks() {
$plugins_link_hook = 'plugin_action_links_mai-design-pack/mai-design-pack.php';
add_filter( $plugins_link_hook, [ $this, 'plugins_link' ], 10, 4 );
add_action( 'plugins_loaded', [ $this, 'updater' ] );
add_action( 'plugins_loaded', [ $this, 'updater' ], 12 );
add_action( 'init', [ $this, 'register_block_pattern_categories' ], 4 );
add_action( 'init', [ $this, 'unregister_block_pattern_categories' ] );
add_action( 'init', [ $this, 'register_block_patterns' ], 4 );
Expand Down Expand Up @@ -178,18 +181,12 @@ function plugins_link( $actions, $plugin_file, $plugin_data, $context ) {
* @return void
*/
public function updater() {
// Bail if current user cannot manage plugins.
if ( ! current_user_can( 'install_plugins' ) ) {
return;
}

// Bail if plugin updater is not loaded.
if ( ! class_exists( 'Puc_v4_Factory' ) ) {
if ( ! class_exists( 'YahnisElsts\PluginUpdateChecker\v5\PucFactory' ) ) {
return;
}

// Setup the updater.
$updater = Puc_v4_Factory::buildUpdateChecker( 'https://github.com/maithemewp/mai-design-pack/', __FILE__, 'mai-design-pack' );
PucFactory::buildUpdateChecker( 'https://github.com/maithemewp/mai-design-pack/', __FILE__, 'mai-design-pack' );

// Maybe set github api token.
if ( defined( 'MAI_GITHUB_API_TOKEN' ) ) {
Expand Down Expand Up @@ -294,15 +291,17 @@ function register_block_patterns() {
'description' => __( 'Description', 'mai-engine' ),
'categories' => __( 'Categories', 'mai-engine' ),
'keywords' => __( 'Keywords', 'mai-engine' ),
'block_types' => __( 'Block Types', 'mai-engine' ),
]
);

ob_start();
include $file;
$content = ob_get_clean();
$title = function_exists( 'mai_convert_case' ) ? mai_convert_case( $base, 'title' ) : $base;
$categories = array_map( 'trim', explode( ',', $data['categories'] ) );
$keywords = array_map( 'trim', explode( ',', $data['keywords'] ) );
$content = ob_get_clean();
$title = function_exists( 'mai_convert_case' ) ? mai_convert_case( $base, 'title' ) : $base;
$categories = array_map( 'trim', explode( ',', $data['categories'] ) );
$keywords = array_map( 'trim', explode( ',', $data['keywords'] ) );
$block_types = array_map( 'trim', explode( ',', $data['block_types'] ) );

// Adds `mai_` prefix.
foreach ( $categories as $index => $category ) {
Expand All @@ -326,6 +325,7 @@ function register_block_patterns() {
'content' => trim( $content ),
'categories' => $categories,
'keywords' => $keywords,
'blockTypes' => $block_types,
]
);
}
Expand Down

0 comments on commit dec430f

Please sign in to comment.