$product ) { if ( $product['id'] === $id ) { $status = ( isset( $product['status'] ) ) ? $product['status'] : ''; break; } } } return $status; } } if ( ! function_exists( 'get_bundled_plugins' ) ) { /** * Retrieves bundled plugin data. * * @param string $template product template. * @return void */ function get_bundled_plugins( $template = '' ) { global $ultimate_referer; $brainstrom_products = get_option( 'brainstrom_products', array() ); $prd_ids = array(); // If brainstrom_products is not yet set, call bsf core init. if ( is_array( $brainstrom_products ) ) { init_bsf_core(); $brainstrom_products = get_option( 'brainstrom_products', array() ); } foreach ( $brainstrom_products as $key => $value ) { foreach ( $value as $key => $value2 ) { array_push( $prd_ids, $key ); } } $path = bsf_get_api_url() . '?referer=' . $ultimate_referer; $data = array( 'action' => 'bsf_fetch_brainstorm_products', 'id' => $prd_ids, ); $request = wp_remote_post( $path, array( 'body' => $data, 'timeout' => '10', ) ); // Request http URL if the https version fails. if ( is_wp_error( $request ) && wp_remote_retrieve_response_code( $request ) !== 200 ) { $path = bsf_get_api_url( true ) . '?referer=' . $ultimate_referer; $request = wp_remote_post( $path, array( 'body' => $data, 'timeout' => '8', ) ); } if ( ! is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) === 200 ) { $result = json_decode( $request['body'] ); $bundled = array(); $simple = array(); if ( ! empty( $result ) ) { if ( ! empty( $result->bundled ) ) { $bundled = $result->bundled; } if ( ! empty( $result->simple ) ) { $simple = $result->simple; } } foreach ( $bundled as $key => $value ) { if ( empty( $value ) ) { unset( $bundled->$key ); } } $brainstrom_bundled_products = (array) $bundled; update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products ); // update 'brainstorm_products'. $simple = json_decode( wp_json_encode( $simple ), 1 ); foreach ( $brainstrom_products as $type => $products ) { foreach ( $products as $key => $product ) { $old_id = isset( $product['id'] ) ? $product['id'] : ''; $simple[ $type ][ $old_id ]['template'] = isset( $brainstrom_products[ $type ][ $old_id ]['template'] ) ? $brainstrom_products[ $type ][ $old_id ]['template'] : ''; $simple[ $type ][ $old_id ]['remote'] = isset( $simple[ $type ][ $old_id ]['version'] ) ? $simple[ $type ][ $old_id ]['version'] : ''; $simple[ $type ][ $old_id ]['version'] = isset( $brainstrom_products[ $type ][ $old_id ]['version'] ) ? $brainstrom_products[ $type ][ $old_id ]['version'] : ''; $simple[ $type ][ $old_id ]['purchase_key'] = isset( $brainstrom_products[ $type ][ $old_id ]['purchase_key'] ) ? $brainstrom_products[ $type ][ $old_id ]['purchase_key'] : ''; $simple[ $type ][ $old_id ]['status'] = isset( $brainstrom_products[ $type ][ $old_id ]['status'] ) ? $brainstrom_products[ $type ][ $old_id ]['status'] : ''; $simple[ $type ][ $old_id ]['message'] = isset( $brainstrom_products[ $type ][ $old_id ]['message'] ) ? $brainstrom_products[ $type ][ $old_id ]['message'] : ''; } } update_option( 'brainstrom_products', $simple ); } } } /** * Displays bundled product list for product. * * @param string $product_id Product ID. * @param bool $installed Show installed products?. * @return string */ function bsf_render_bundled_products( $product_id, $installed ) { $product_status = check_bsf_product_status( $product_id ); $brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() ); if ( isset( $brainstrom_bundled_products[ $product_id ] ) ) { $brainstrom_bundled_products = $brainstrom_bundled_products[ $product_id ]; } usort( $brainstrom_bundled_products, 'bsf_sort' ); $global_plugin_installed = 0; $global_plugin_activated = 0; $total_bundled_plugins = count( $brainstrom_bundled_products ); foreach ( $brainstrom_bundled_products as $key => $product ) { if ( ! isset( $product->id ) || empty( $product->id ) ) { continue; } if ( isset( $request_product_id ) && $request_product_id !== $product->id ) { continue; } $plugin_abs_path = WP_PLUGIN_DIR . '/' . $product->init; if ( is_file( $plugin_abs_path ) ) { $global_plugin_installed++; if ( is_plugin_active( $product->init ) ) { $global_plugin_activated++; } } } ob_start(); if ( $total_bundled_plugins === $global_plugin_installed ) { ?>

$product ) { if ( ! isset( $product->id ) || empty( $product->id ) ) { continue; } if ( isset( $request_product_id ) && $request_product_id !== $product->id ) { continue; } $is_plugin_installed = false; $is_plugin_activated = false; $plugin_abs_path = WP_PLUGIN_DIR . '/' . $product->init; if ( is_file( $plugin_abs_path ) ) { $is_plugin_installed = true; if ( is_plugin_active( $product->init ) ) { $is_plugin_activated = true; } } if ( ( $is_plugin_installed && ! $installed ) || ( ! $is_plugin_installed && $installed ) ) { continue; } if ( $is_plugin_installed && $is_plugin_activated ) { $class = 'active-plugin'; } elseif ( $is_plugin_installed && ! $is_plugin_activated ) { $class = 'inactive-plugin'; } else { $class = 'plugin-not-installed'; } ?>
  • product_image ) ) { ?>
    image
    short_name ) ) ? $product->short_name : $product->name; ?>

    description ); ?>By author ); ?>

    licence_require || 'false' === $product->licence_require ) || 'registered' === $product_status ) { $installer_url = bsf_exension_installer_url( $product_id ); $button = __( 'Install', 'bsf' ); $button_class = 'bsf-install-button install-now'; } elseif ( ( $product->licence_require || 'true' === $product->licence_require ) && 'registered' !== $product_status ) { $installer_url = bsf_registration_page_url( '&id=' . $product_id, $product_id ); $button = __( 'Validate Purchase', 'bsf' ); $button_class = 'bsf-validate-licence-button'; } } else { $current_name = strtolower( bsf_get_current_name( $product->init, $product->type ) ); $current_name = preg_replace( '![^a-z0-9]+!i', '-', $current_name ); if ( is_multisite() ) { $installer_url = network_admin_url( 'plugins.php#' . $current_name ); } else { $installer_url = admin_url( 'plugins.php#' . $current_name ); } $button = __( 'Installed', 'bsf' ); } ?>