free_addons = apply_filters( 'modula_free_extensions', array( 'modula-foo-migrator' => array( 'slug' => 'modula-foo-migrator', 'name' => __( 'Migrate away from FooGallery', 'modula-best-grid-gallery' ), 'image' => 'https://wp-modula.com/wp-content/uploads/edd/2021/04/069-refresh.png', 'description' => esc_html__('Want to change your gallery plugin and impress your potential clients with a fully customizable WordPress gallery plugin that\'s fully mobile responsive', 'moudla-best-grid-gallery') ), 'modula-nextgen-migrator' => array( 'slug' => 'modula-nextgen-migrator', 'name' => __( 'Migrate away from NextGEN', 'modula-best-grid-gallery' ), 'image' => 'https://wp-modula.com/wp-content/uploads/edd/2021/04/069-refresh.png', 'description' => esc_html__('Want to change your gallery plugin and impress your potential clients with a fully customizable WordPress gallery plugin that\'s fully mobile responsive', 'moudla-best-grid-gallery') ), 'modula-envira-migrator' => array( 'slug' => 'modula-envira-migrator', 'name' => __( 'Migrate away from Envira', 'modula-best-grid-gallery' ), 'image' => 'https://wp-modula.com/wp-content/uploads/edd/2021/04/069-refresh.png', 'description' => esc_html__('Want to change your gallery plugin and impress your potential clients with a fully customizable WordPress gallery plugin that\'s fully mobile responsive', 'moudla-best-grid-gallery') ), 'modula-photoblocks-gallery-migrator' => array( 'slug' => 'modula-photoblocks-gallery-migrator', 'name' => __( 'Migrate away from PhotoBlocks', 'modula-best-grid-gallery' ), 'image' => 'https://wp-modula.com/wp-content/uploads/edd/2021/04/069-refresh.png', 'description' => esc_html__('Want to change your gallery plugin and impress your potential clients with a fully customizable WordPress gallery plugin that\'s fully mobile responsive', 'moudla-best-grid-gallery') ), 'modula-final-tiles-migrator' => array( 'slug' => 'modula-final-tiles-migrator', 'name' => __( 'Migrate away from Final Tiles', 'modula-best-grid-gallery' ), 'image' => 'https://wp-modula.com/wp-content/uploads/edd/2021/04/069-refresh.png', 'description' => esc_html__('Want to change your gallery plugin and impress your potential clients with a fully customizable WordPress gallery plugin that\'s fully mobile responsive', 'moudla-best-grid-gallery') ) ) ); } private function check_for_addons() { $data = get_transient( 'modula_all_extensions' ); if ( false !== $data ) { return $data; } $addons = array(); $url = MODULA_PRO_STORE_URL . '/wp-json/mt/v1/get-all-extensions'; // Get data from the remote URL. $response = wp_remote_get( $url ); if ( ! is_wp_error( $response ) ) { // Decode the data that we got. $data = json_decode( wp_remote_retrieve_body( $response ), true ); if ( ! empty( $data ) && is_array( $data ) ) { $addons = $data; // Store the data for a week. set_transient( 'modula_all_extensions', $data, 30 * DAY_IN_SECONDS ); } } return apply_filters( 'modula_addons', $addons ); } public function render_addons() { $this->addons = $this->check_for_addons(); $addons_images = array( 'modula-whitelabel', 'modula-roles', 'modula-defaults', 'modula-zoom', 'modula-download', 'modula-exif', 'modula-albums', 'modula-slider', 'modula-password-protect', 'modula-watermark', 'modula-deeplink', 'modula-speedup', 'modula-video','modula-advanced-shortcodes','modula-slideshow','modula-protection', 'modula-fullscreen' ); $addons = apply_filters( 'modula_package_sortage', $this->addons ); if ( ! empty( $addons ) ) { foreach ( $addons as $addon ) { $this->render_addon_top( $addon, $addons_images ); echo '
'; echo apply_filters( 'modula_addon_settings_link','', $addon ); echo apply_filters( "modula_addon_button_action", '' . esc_html__( 'Upgrade to unlock this feature', 'modula-best-grid-gallery' ) . '', $addon ); echo '
'; // .modula-addon-actions echo ''; } } } /** * Function to render our free extensions * * @since 2.5.5 */ public function render_free_addons() { if ( ! empty( $this->free_addons ) ) { foreach ( $this->free_addons as $addon ) { $slug = $addon['slug']; $plugin_path = $slug . '/' . $slug . '.php'; if ( 'modula-foo-migrator' === $slug ) { $plugin_path = $slug . '/migrate-away-from-foogallery.php'; } if ( 'modula-nextgen-migrator' === $slug ) { $plugin_path = $slug . '/migrate-away-from-nextgen.php'; } $activate_url = add_query_arg( array( 'action' => 'activate', 'plugin' => rawurlencode( $plugin_path ), 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin_path ), ), admin_url( 'plugins.php' ) ); $deactivate_url = add_query_arg( array( 'action' => 'deactivate', 'plugin' => rawurlencode( $plugin_path ), 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'deactivate-plugin_' . $plugin_path ), ), admin_url( 'plugins.php' ) ); if ( ! function_exists( 'get_plugin_data' ) || ! function_exists( 'is_plugin_active' ) ) { require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); } $action = 'install'; if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_path ) ) { $action = 'activate'; } if ( is_plugin_active( $plugin_path ) ) { $action = 'installed'; } $this->render_addon_top( $addon ); echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo '
'; // .modula-free-addon-actions echo ''; } } } /** * Reload addons in the Extensions tab * * @moved here from class-modula.php file in version 2.5.0 */ public function reload_extensions() { // Run a security check first. check_admin_referer( 'modula-reload-extensions', 'nonce' ); delete_transient( 'modula_all_extensions' ); delete_transient( 'modula_pro_licensed_extensions' ); $this->addons = $this->check_for_addons(); die; } /** * Check if there are free addons * * @return bool * @since 2.5.5 */ public function check_free_addons() { return !empty( $this->free_addons ); } /** * Render the top markup for addons */ public function render_addon_top( $addon = false, $addons_images = false ) { if ( ! $addon ) { return; } if( ! function_exists( 'get_plugin_data' ) ) { require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); } $plugin_data = false; if(file_exists(WP_PLUGIN_DIR .'/' . $addon['slug'] . '/' . $addon['slug'] . '.php') ){ $plugin_data = get_plugin_data( WP_PLUGIN_DIR .'/' . $addon['slug'] . '/' . $addon['slug'] . '.php' ); } $image = ( $addons_images && in_array( $addon[ 'slug' ], $addons_images ) ) ? MODULA_URL . 'assets/images/addons/' . $addon[ 'slug' ] . '.png' : MODULA_URL . 'assets/images/modula-logo.jpg'; echo '
'; echo '
'; if ( !isset( $addon['image'] ) || '' == $addon['image'] ){ echo '
'; } else { echo '
'; } echo '
'; echo '

' . esc_html( $addon['name'] ) . '

'; echo ( isset( $addon['version'] ) ) ? '' . esc_html( 'V ' . $addon['version'] ) . '' : ''; echo '
' . wp_kses_post( $addon['description'] ) . '
'; echo '
'; echo '
'; } /** * Check if the free addons were released */ public function check_for_release( $addons ) { return $addons; } } $addons = new Modula_Addons();