| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: Info Cards |
| 5 |
* Description: Create beautiful cards with text and image. |
| 6 |
* Requires at least: 5.8 |
| 7 |
* Requires PHP: 7.1 |
| 8 |
* Version: 3.0.0 |
| 9 |
* Author: bPlugins |
| 10 |
* Author URI: http://bplugins.com |
| 11 |
* Plugin URI: https://wordpress.org/plugins/info-cards/ |
| 12 |
* License: GPL-2.0-or-later |
| 13 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 14 |
* Text Domain: info-cards |
| 15 |
*/ |
| 16 |
if ( !defined( 'ABSPATH' ) ) { |
| 17 |
exit; |
| 18 |
} |
| 19 |
if ( function_exists( 'ic_fs' ) ) { |
| 20 |
register_activation_hook( __FILE__, function () { |
| 21 |
if ( !function_exists( 'is_plugin_active' ) ) { |
| 22 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 23 |
} |
| 24 |
if ( is_plugin_active( 'info-cards/info-cards.php' ) ) { |
| 25 |
deactivate_plugins( 'info-cards/info-cards.php' ); |
| 26 |
} |
| 27 |
if ( is_plugin_active( 'info-cards-pro/info-cards.php' ) ) { |
| 28 |
deactivate_plugins( 'info-cards-pro/info-cards.php' ); |
| 29 |
} |
| 30 |
} ); |
| 31 |
} else { |
| 32 |
define( 'INFO_CARDS_PRO', file_exists( dirname( __FILE__ ) . '/freemius/start.php' ) ); |
| 33 |
define( 'ICB_VERSION', ( isset( $_SERVER['HTTP_HOST'] ) && 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '3.0.0' ) ); |
| 34 |
define( 'ICB_DIR_URL', plugin_dir_url( __FILE__ ) ); |
| 35 |
define( 'ICB_DIR_PATH', plugin_dir_path( __FILE__ ) ); |
| 36 |
define( 'ICB_DIR', ICB_DIR_URL ); |
| 37 |
define( 'ICB_DIR_PATH_LEGACY', ICB_DIR_PATH ); |
| 38 |
if ( !function_exists( 'ic_fs' ) ) { |
| 39 |
function ic_fs() { |
| 40 |
global $ic_fs; |
| 41 |
if ( !isset( $ic_fs ) ) { |
| 42 |
if ( INFO_CARDS_PRO ) { |
| 43 |
require_once dirname( __FILE__ ) . '/freemius/start.php'; |
| 44 |
} else { |
| 45 |
require_once dirname( __FILE__ ) . '/freemius-lite/start.php'; |
| 46 |
} |
| 47 |
$apbConfig = [ |
| 48 |
'id' => '17727', |
| 49 |
'slug' => 'info-cards', |
| 50 |
'type' => 'plugin', |
| 51 |
'public_key' => 'pk_a98bc1d71dc1e0a8bf0aede3af3e0', |
| 52 |
'is_premium' => false, |
| 53 |
'premium_suffix' => 'Pro', |
| 54 |
'has_premium_version' => true, |
| 55 |
'has_addons' => false, |
| 56 |
'has_paid_plans' => true, |
| 57 |
'trial' => [ |
| 58 |
'days' => 7, |
| 59 |
'is_require_payment' => false, |
| 60 |
], |
| 61 |
'menu' => [ |
| 62 |
'slug' => 'info-cards-dashboard', |
| 63 |
'first-path' => 'admin.php?page=info-cards-dashboard#/welcome', |
| 64 |
'support' => false, |
| 65 |
], |
| 66 |
]; |
| 67 |
$ic_fs = ( INFO_CARDS_PRO ? fs_dynamic_init( $apbConfig ) : fs_lite_dynamic_init( $apbConfig ) ); |
| 68 |
} |
| 69 |
return $ic_fs; |
| 70 |
} |
| 71 |
|
| 72 |
ic_fs(); |
| 73 |
do_action( 'ic_fs_loaded' ); |
| 74 |
} |
| 75 |
require_once ICB_DIR_PATH . 'inc/Helpers.php'; |
| 76 |
if ( INFO_CARDS_PRO ) { |
| 77 |
require_once ICB_DIR_PATH . 'inc/LicenseActivation.php'; |
| 78 |
} |
| 79 |
require_once ICB_DIR_PATH . 'inc/Init.php'; |
| 80 |
require_once ICB_DIR_PATH . 'inc/Admin.php'; |
| 81 |
require_once ICB_DIR_PATH . 'inc/RestApi.php'; |
| 82 |
require_once ICB_DIR_PATH . 'inc/Posts.php'; |
| 83 |
require_once ICB_DIR_PATH . 'inc/IcbShortcode.php'; |
| 84 |
new ICB\Init(); |
| 85 |
new ICB\Admin(); |
| 86 |
new ICB\RestApi(); |
| 87 |
// ----------------------------------------------------------------------- |
| 88 |
// Register Gutenberg Block Category |
| 89 |
// ----------------------------------------------------------------------- |
| 90 |
add_filter( |
| 91 |
'block_categories_all', |
| 92 |
'icb_register_block_category', |
| 93 |
10, |
| 94 |
2 |
| 95 |
); |
| 96 |
function icb_register_block_category( $categories, $context ) { |
| 97 |
if ( !is_array( $categories ) ) { |
| 98 |
$categories = []; |
| 99 |
} |
| 100 |
// Prevent duplicate category |
| 101 |
foreach ( $categories as $category ) { |
| 102 |
if ( isset( $category['slug'] ) && 'info-cards' === $category['slug'] ) { |
| 103 |
return $categories; |
| 104 |
} |
| 105 |
} |
| 106 |
// Add category at top |
| 107 |
array_unshift( $categories, [ |
| 108 |
'slug' => 'info-cards', |
| 109 |
'title' => __( 'Info Cards', 'info-cards' ), |
| 110 |
'icon' => null, |
| 111 |
] ); |
| 112 |
return $categories; |
| 113 |
} |
| 114 |
|
| 115 |
add_action( 'enqueue_block_assets', function () { |
| 116 |
// wp_enqueue_script( |
| 117 |
// 'unicorn-studio', |
| 118 |
// 'https://cdn.jsdelivr.net/gh/hiunicornstudio/unicornstudio.js@v1.4.25/dist/unicornStudio.umd.js', |
| 119 |
// [], |
| 120 |
// '1.4.25', |
| 121 |
// true |
| 122 |
// ); |
| 123 |
// wp_enqueue_script( 'mgc-jquery-cdn', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js', [], '3.6.0', true ); |
| 124 |
// wp_enqueue_script( 'mgc-gsap', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/gsap.min.js', [], '3.11.3', true ); |
| 125 |
// wp_enqueue_script( 'mgc-splitting', 'https://unpkg.com/splitting/dist/splitting.min.js', [], null, true ); |
| 126 |
// wp_enqueue_style( 'owl-carousel', 'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css', [], '2.3.4' ); |
| 127 |
// wp_enqueue_style( 'owl-carousel-theme', 'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css', [ 'owl-carousel' ], '2.3.4' ); |
| 128 |
// wp_enqueue_script( 'owl-jquery', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js', [], '3.7.1', true ); |
| 129 |
// wp_enqueue_script( 'owl-carousel-js', 'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js', [ 'owl-jquery' ], '2.3.4', true ); |
| 130 |
// wp_enqueue_script( 'owl-carousel-mousewheel', 'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.mousewheel.min.js', [ 'owl-carousel-js' ], '2.3.4', true ); |
| 131 |
// jQuery (single) |
| 132 |
// wp_enqueue_script( 'jquery' ); |
| 133 |
// Core Dependencies for Blocks and AJAX |
| 134 |
// wp_enqueue_script( 'wp-util' ); |
| 135 |
// wp_enqueue_script( 'wp-element' ); |
| 136 |
// Define ajaxurl for the frontend if it's not defined |
| 137 |
if ( !is_admin() ) { |
| 138 |
wp_add_inline_script( 'wp-util', 'var ajaxurl = "' . admin_url( 'admin-ajax.php' ) . '";', 'before' ); |
| 139 |
} |
| 140 |
// Unicorn Studio |
| 141 |
wp_enqueue_script( |
| 142 |
'unicorn-studio', |
| 143 |
'https://cdn.jsdelivr.net/gh/hiunicornstudio/unicornstudio.js@v1.4.25/dist/unicornStudio.umd.js', |
| 144 |
[], |
| 145 |
'1.4.25', |
| 146 |
true |
| 147 |
); |
| 148 |
// GSAP + Splitting |
| 149 |
wp_enqueue_script( |
| 150 |
'jquery-cdn', |
| 151 |
'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js', |
| 152 |
[], |
| 153 |
'3.7.1', |
| 154 |
true |
| 155 |
); |
| 156 |
wp_enqueue_script( |
| 157 |
'mgc-gsap', |
| 158 |
'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/gsap.min.js', |
| 159 |
[], |
| 160 |
'3.11.3', |
| 161 |
true |
| 162 |
); |
| 163 |
wp_enqueue_script( |
| 164 |
'mgc-splitting', |
| 165 |
'https://unpkg.com/splitting/dist/splitting.min.js', |
| 166 |
[], |
| 167 |
null, |
| 168 |
true |
| 169 |
); |
| 170 |
// Owl Carousel |
| 171 |
wp_enqueue_style( |
| 172 |
'owl-carousel', |
| 173 |
'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css', |
| 174 |
[], |
| 175 |
'2.3.4' |
| 176 |
); |
| 177 |
wp_enqueue_style( |
| 178 |
'owl-carousel-theme', |
| 179 |
'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css', |
| 180 |
['owl-carousel'], |
| 181 |
'2.3.4' |
| 182 |
); |
| 183 |
wp_enqueue_script( |
| 184 |
'owl-carousel-js', |
| 185 |
'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js', |
| 186 |
['jquery'], |
| 187 |
'2.3.4', |
| 188 |
true |
| 189 |
); |
| 190 |
wp_enqueue_script( |
| 191 |
'owl-carousel-mousewheel', |
| 192 |
'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.mousewheel.min.js', |
| 193 |
['owl-carousel-js'], |
| 194 |
'2.3.4', |
| 195 |
true |
| 196 |
); |
| 197 |
} ); |
| 198 |
// ----------------------------------------------------------------------- |
| 199 |
// Helpers for Gutenberg page creation via URL params |
| 200 |
// ----------------------------------------------------------------------- |
| 201 |
add_filter( |
| 202 |
'default_title', |
| 203 |
function ( $title, $post = null ) { |
| 204 |
if ( is_object( $post ) && isset( $post->post_type ) && 'page' === $post->post_type && isset( $_GET['title'] ) ) { |
| 205 |
return sanitize_text_field( wp_unslash( $_GET['title'] ) ); |
| 206 |
} |
| 207 |
return $title; |
| 208 |
}, |
| 209 |
10, |
| 210 |
2 |
| 211 |
); |
| 212 |
add_filter( |
| 213 |
'default_content', |
| 214 |
function ( $content, $post = null ) { |
| 215 |
if ( is_object( $post ) && isset( $post->post_type ) && 'page' === $post->post_type && isset( $_GET['content'] ) ) { |
| 216 |
return wp_unslash( $_GET['content'] ); |
| 217 |
} |
| 218 |
return $content; |
| 219 |
}, |
| 220 |
10, |
| 221 |
2 |
| 222 |
); |
| 223 |
// ----------------------------------------------------------------------- |
| 224 |
// Plugin action links |
| 225 |
// ----------------------------------------------------------------------- |
| 226 |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), function ( $links ) { |
| 227 |
if ( !is_array( $links ) ) { |
| 228 |
$links = []; |
| 229 |
} |
| 230 |
$dashboard_link = '<a href="' . admin_url( 'admin.php?page=info-cards-dashboard' ) . '" style="color:#f18500;font-weight:bold;">Help And Demo</a>'; |
| 231 |
array_unshift( $links, $dashboard_link ); |
| 232 |
return $links; |
| 233 |
} ); |
| 234 |
} |