@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | - exit; |
|
| 7 | + exit; |
|
| 8 | 8 | } |
| 9 | 9 | add_ThickBox(); |
| 10 | 10 | ?> |
@@ -14,18 +14,18 @@ discard block |
||
| 14 | 14 | <?php if ( $tabs ){ ?> |
| 15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
| 16 | 16 | <?php |
| 17 | - foreach ( $tabs as $name => $label ) { |
|
| 18 | - echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>'; |
|
| 19 | - } |
|
| 20 | - do_action( 'wpi_addons_tabs' ); |
|
| 21 | - ?> |
|
| 17 | + foreach ( $tabs as $name => $label ) { |
|
| 18 | + echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>'; |
|
| 19 | + } |
|
| 20 | + do_action( 'wpi_addons_tabs' ); |
|
| 21 | + ?> |
|
| 22 | 22 | </nav> |
| 23 | 23 | |
| 24 | 24 | <?php |
| 25 | 25 | |
| 26 | - if($current_tab == 'membership'){ |
|
| 26 | + if($current_tab == 'membership'){ |
|
| 27 | 27 | |
| 28 | - ?> |
|
| 28 | + ?> |
|
| 29 | 29 | |
| 30 | 30 | <div class="wpi-membership-tab-conatiner"> |
| 31 | 31 | <h2>With our WPInvoicing Membership you get access to all our products!</h2> |
@@ -36,28 +36,28 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | <p> |
| 38 | 38 | <?php |
| 39 | - $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1'); |
|
| 40 | - echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108)); |
|
| 41 | - ?> |
|
| 39 | + $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1'); |
|
| 40 | + echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108)); |
|
| 41 | + ?> |
|
| 42 | 42 | </p> |
| 43 | 43 | <?php }?> |
| 44 | 44 | </div> |
| 45 | 45 | |
| 46 | 46 | <?php |
| 47 | - }else{ |
|
| 48 | - $installed_plugins = get_plugins(); |
|
| 47 | + }else{ |
|
| 48 | + $installed_plugins = get_plugins(); |
|
| 49 | 49 | $addon_obj = new WPInv_Admin_Addons(); |
| 50 | - if ($addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
| 51 | - ?> |
|
| 50 | + if ($addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
| 51 | + ?> |
|
| 52 | 52 | <ul class="wpi-products"><?php foreach ( $addons as $addon ) : |
| 53 | 53 | if(965==$addon->info->id){continue;}// don't show quote add on |
| 54 | - ?><li class="wpi-product"> |
|
| 54 | + ?><li class="wpi-product"> |
|
| 55 | 55 | <div class="wpi-product-title"> |
| 56 | 56 | <h3><?php |
| 57 | - if ( ! empty( $addon->info->excerpt) ){ |
|
| 58 | - echo wpi_help_tip( $addon->info->excerpt ); |
|
| 59 | - } |
|
| 60 | - echo esc_html( $addon->info->title ); ?></h3> |
|
| 57 | + if ( ! empty( $addon->info->excerpt) ){ |
|
| 58 | + echo wpi_help_tip( $addon->info->excerpt ); |
|
| 59 | + } |
|
| 60 | + echo esc_html( $addon->info->title ); ?></h3> |
|
| 61 | 61 | </div> |
| 62 | 62 | |
| 63 | 63 | <span class="wpi-product-image"> |
@@ -65,27 +65,27 @@ discard block |
||
| 65 | 65 | <img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/> |
| 66 | 66 | <?php endif; |
| 67 | 67 | |
| 68 | - if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){ |
|
| 69 | - echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&TB_iframe=true&width=770&height=660" class="thickbox" >'; |
|
| 70 | - echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
| 71 | - echo '</a>'; |
|
| 72 | - }elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){ |
|
| 73 | - if(defined('WP_EASY_UPDATES_ACTIVE')){ |
|
| 74 | - $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&TB_iframe=true&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com'); |
|
| 75 | - }else{ |
|
| 76 | - // if installed show activation link |
|
| 77 | - if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){ |
|
| 78 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
| 79 | - }else{ |
|
| 80 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - echo '<a href="'.$url.'" class="thickbox">'; |
|
| 84 | - echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
| 85 | - echo '</a>'; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - ?> |
|
| 68 | + if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){ |
|
| 69 | + echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&TB_iframe=true&width=770&height=660" class="thickbox" >'; |
|
| 70 | + echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
| 71 | + echo '</a>'; |
|
| 72 | + }elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){ |
|
| 73 | + if(defined('WP_EASY_UPDATES_ACTIVE')){ |
|
| 74 | + $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&TB_iframe=true&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com'); |
|
| 75 | + }else{ |
|
| 76 | + // if installed show activation link |
|
| 77 | + if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){ |
|
| 78 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
| 79 | + }else{ |
|
| 80 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + echo '<a href="'.$url.'" class="thickbox">'; |
|
| 84 | + echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
| 85 | + echo '</a>'; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + ?> |
|
| 89 | 89 | |
| 90 | 90 | </span> |
| 91 | 91 | |
@@ -93,15 +93,15 @@ discard block |
||
| 93 | 93 | <span class="wpi-product-button"> |
| 94 | 94 | <?php |
| 95 | 95 | $addon_obj->output_button( $addon ); |
| 96 | - ?> |
|
| 96 | + ?> |
|
| 97 | 97 | </span> |
| 98 | 98 | |
| 99 | 99 | <span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul> |
| 100 | 100 | <?php endif; |
| 101 | - } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - } |
|
| 104 | - ?> |
|
| 103 | + } |
|
| 104 | + ?> |
|
| 105 | 105 | |
| 106 | 106 | |
| 107 | 107 | <div class="clearfix" ></div> |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | <input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button> |
| 121 | 121 | <br> |
| 122 | 122 | <?php |
| 123 | - echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' ); |
|
| 124 | - ?> |
|
| 123 | + echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' ); |
|
| 124 | + ?> |
|
| 125 | 125 | </span> |
| 126 | 126 | </div> |
| 127 | 127 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | </div> |
| 45 | 45 | |
| 46 | 46 | <?php |
| 47 | - }else{ |
|
| 47 | + } else{ |
|
| 48 | 48 | $installed_plugins = get_plugins(); |
| 49 | 49 | $addon_obj = new WPInv_Admin_Addons(); |
| 50 | 50 | if ($addons = $addon_obj->get_section_data( $current_tab ) ) : |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&TB_iframe=true&width=770&height=660" class="thickbox" >'; |
| 70 | 70 | echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
| 71 | 71 | echo '</a>'; |
| 72 | - }elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){ |
|
| 72 | + } elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){ |
|
| 73 | 73 | if(defined('WP_EASY_UPDATES_ACTIVE')){ |
| 74 | 74 | $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&TB_iframe=true&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com'); |
| 75 | - }else{ |
|
| 75 | + } else{ |
|
| 76 | 76 | // if installed show activation link |
| 77 | 77 | if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){ |
| 78 | 78 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
| 79 | - }else{ |
|
| 79 | + } else{ |
|
| 80 | 80 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | - exit; |
|
| 9 | + exit; |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -15,71 +15,71 @@ discard block |
||
| 15 | 15 | class WPInv_Admin_Addons extends Ayecode_Addons { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Get the extensions page tabs. |
|
| 20 | - * |
|
| 21 | - * @return array of tabs. |
|
| 22 | - */ |
|
| 23 | - public function get_tabs(){ |
|
| 24 | - $tabs = array( |
|
| 25 | - 'addons' => __("Addons", "invoicing"), |
|
| 18 | + /** |
|
| 19 | + * Get the extensions page tabs. |
|
| 20 | + * |
|
| 21 | + * @return array of tabs. |
|
| 22 | + */ |
|
| 23 | + public function get_tabs(){ |
|
| 24 | + $tabs = array( |
|
| 25 | + 'addons' => __("Addons", "invoicing"), |
|
| 26 | 26 | 'gateways' => __("Payment Gateways", "invoicing"), |
| 27 | 27 | 'recommended_plugins' => __("Recommended plugins", "invoicing"), |
| 28 | 28 | 'membership' => __("Membership", "invoicing"), |
| 29 | - ); |
|
| 30 | - |
|
| 31 | - return $tabs; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Get section content for the addons screen. |
|
| 36 | - * |
|
| 37 | - * @param string $section_id |
|
| 38 | - * |
|
| 39 | - * @return array |
|
| 40 | - */ |
|
| 41 | - public function get_section_data( $section_id ) { |
|
| 42 | - $section = self::get_tab( $section_id ); |
|
| 43 | - $api_url = "https://wpinvoicing.com/edd-api/v2/products/"; |
|
| 44 | - $section_data = new stdClass(); |
|
| 45 | - |
|
| 46 | - if($section_id=='recommended_plugins'){ |
|
| 47 | - $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
| 48 | - } |
|
| 49 | - elseif ( ! empty( $section ) ) { |
|
| 50 | - if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
| 51 | - //if ( 1==1) { |
|
| 52 | - |
|
| 53 | - $query_args = array( 'category' => $section_id, 'number' => 100); |
|
| 54 | - $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id); |
|
| 55 | - |
|
| 56 | - $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout' => 15, ) ); |
|
| 57 | - |
|
| 58 | - if ( ! is_wp_error( $raw_section ) ) { |
|
| 59 | - $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
| 60 | - |
|
| 61 | - if ( ! empty( $section_data->products ) ) { |
|
| 62 | - set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - $products = isset($section_data->products) ? $section_data->products : ''; |
|
| 69 | - |
|
| 70 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Outputs a button. |
|
| 75 | - *ccc |
|
| 76 | - * @param string $url |
|
| 77 | - * @param string $text |
|
| 78 | - * @param string $theme |
|
| 79 | - * @param string $plugin |
|
| 80 | - */ |
|
| 81 | - public function output_button( $addon ) { |
|
| 82 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 29 | + ); |
|
| 30 | + |
|
| 31 | + return $tabs; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Get section content for the addons screen. |
|
| 36 | + * |
|
| 37 | + * @param string $section_id |
|
| 38 | + * |
|
| 39 | + * @return array |
|
| 40 | + */ |
|
| 41 | + public function get_section_data( $section_id ) { |
|
| 42 | + $section = self::get_tab( $section_id ); |
|
| 43 | + $api_url = "https://wpinvoicing.com/edd-api/v2/products/"; |
|
| 44 | + $section_data = new stdClass(); |
|
| 45 | + |
|
| 46 | + if($section_id=='recommended_plugins'){ |
|
| 47 | + $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
| 48 | + } |
|
| 49 | + elseif ( ! empty( $section ) ) { |
|
| 50 | + if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
| 51 | + //if ( 1==1) { |
|
| 52 | + |
|
| 53 | + $query_args = array( 'category' => $section_id, 'number' => 100); |
|
| 54 | + $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id); |
|
| 55 | + |
|
| 56 | + $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout' => 15, ) ); |
|
| 57 | + |
|
| 58 | + if ( ! is_wp_error( $raw_section ) ) { |
|
| 59 | + $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
| 60 | + |
|
| 61 | + if ( ! empty( $section_data->products ) ) { |
|
| 62 | + set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + $products = isset($section_data->products) ? $section_data->products : ''; |
|
| 69 | + |
|
| 70 | + return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Outputs a button. |
|
| 75 | + *ccc |
|
| 76 | + * @param string $url |
|
| 77 | + * @param string $text |
|
| 78 | + * @param string $theme |
|
| 79 | + * @param string $plugin |
|
| 80 | + */ |
|
| 81 | + public function output_button( $addon ) { |
|
| 82 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 83 | 83 | // $button_text = __('Free','invoicing'); |
| 84 | 84 | // $licensing = false; |
| 85 | 85 | // $installed = false; |
@@ -91,123 +91,123 @@ discard block |
||
| 91 | 91 | // $install_status = 'get'; |
| 92 | 92 | // $onclick = ''; |
| 93 | 93 | |
| 94 | - $wp_org_themes = array('supreme-directory','directory-starter'); |
|
| 95 | - |
|
| 96 | - $button_args = array( |
|
| 97 | - 'type' => $current_tab, |
|
| 98 | - 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
|
| 99 | - 'title' => isset($addon->info->title) ? $addon->info->title : '', |
|
| 100 | - 'button_text' => __('Free','invoicing'), |
|
| 101 | - 'price_text' => __('Free','invoicing'), |
|
| 102 | - 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
|
| 103 | - 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
|
| 104 | - 'class' => 'button-primary', |
|
| 105 | - 'install_status' => 'get', |
|
| 106 | - 'installed' => false, |
|
| 107 | - 'price' => '', |
|
| 108 | - 'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false, |
|
| 109 | - 'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '', |
|
| 110 | - 'onclick' => '', |
|
| 111 | - 'slug' => isset($addon->info->slug) ? $addon->info->slug : '', |
|
| 112 | - 'active' => false, |
|
| 113 | - 'file' => '', |
|
| 114 | - 'update_url' => '', |
|
| 115 | - ); |
|
| 116 | - |
|
| 117 | - if($current_tab == 'addons' && isset($addon->info->id) && $addon->info->id){ |
|
| 118 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 119 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 120 | - $status = self::install_plugin_install_status($addon); |
|
| 121 | - $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
| 122 | - if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
| 123 | - $button_args['update_url'] = "https://wpinvoicing.com"; |
|
| 124 | - }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
| 125 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 126 | - $button_args['installed'] = self::is_theme_installed($addon); |
|
| 127 | - if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
| 128 | - $button_args['update_url'] = "https://wpinvoicing.com"; |
|
| 129 | - } |
|
| 130 | - }elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){ |
|
| 131 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 132 | - $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
| 133 | - $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
|
| 134 | - $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // set price |
|
| 138 | - if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
| 139 | - if(is_object($addon->pricing)){ |
|
| 140 | - $prices = (Array)$addon->pricing; |
|
| 141 | - $button_args['price'] = reset($prices); |
|
| 142 | - }elseif(isset($addon->pricing)){ |
|
| 143 | - $button_args['price'] = $addon->pricing; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // set price text |
|
| 148 | - if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
| 149 | - $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - // set if installed |
|
| 154 | - if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
| 155 | - $button_args['installed'] = true; |
|
| 156 | - } |
|
| 94 | + $wp_org_themes = array('supreme-directory','directory-starter'); |
|
| 95 | + |
|
| 96 | + $button_args = array( |
|
| 97 | + 'type' => $current_tab, |
|
| 98 | + 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
|
| 99 | + 'title' => isset($addon->info->title) ? $addon->info->title : '', |
|
| 100 | + 'button_text' => __('Free','invoicing'), |
|
| 101 | + 'price_text' => __('Free','invoicing'), |
|
| 102 | + 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
|
| 103 | + 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
|
| 104 | + 'class' => 'button-primary', |
|
| 105 | + 'install_status' => 'get', |
|
| 106 | + 'installed' => false, |
|
| 107 | + 'price' => '', |
|
| 108 | + 'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false, |
|
| 109 | + 'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '', |
|
| 110 | + 'onclick' => '', |
|
| 111 | + 'slug' => isset($addon->info->slug) ? $addon->info->slug : '', |
|
| 112 | + 'active' => false, |
|
| 113 | + 'file' => '', |
|
| 114 | + 'update_url' => '', |
|
| 115 | + ); |
|
| 116 | + |
|
| 117 | + if($current_tab == 'addons' && isset($addon->info->id) && $addon->info->id){ |
|
| 118 | + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 119 | + if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 120 | + $status = self::install_plugin_install_status($addon); |
|
| 121 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
| 122 | + if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
| 123 | + $button_args['update_url'] = "https://wpinvoicing.com"; |
|
| 124 | + }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
| 125 | + if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 126 | + $button_args['installed'] = self::is_theme_installed($addon); |
|
| 127 | + if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
| 128 | + $button_args['update_url'] = "https://wpinvoicing.com"; |
|
| 129 | + } |
|
| 130 | + }elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){ |
|
| 131 | + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 132 | + $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
| 133 | + $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
|
| 134 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // set price |
|
| 138 | + if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
| 139 | + if(is_object($addon->pricing)){ |
|
| 140 | + $prices = (Array)$addon->pricing; |
|
| 141 | + $button_args['price'] = reset($prices); |
|
| 142 | + }elseif(isset($addon->pricing)){ |
|
| 143 | + $button_args['price'] = $addon->pricing; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // set price text |
|
| 148 | + if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
| 149 | + $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + // set if installed |
|
| 154 | + if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
| 155 | + $button_args['installed'] = true; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | 158 | // print_r($button_args); |
| 159 | - // set if active |
|
| 160 | - if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
| 161 | - if($button_args['type'] != 'themes'){ |
|
| 162 | - $button_args['active'] = is_plugin_active($button_args['file']); |
|
| 163 | - }else{ |
|
| 164 | - $button_args['active'] = self::is_theme_active($addon); |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // set button text and class |
|
| 169 | - if($button_args['active']){ |
|
| 170 | - $button_args['button_text'] = __('Active','invoicing'); |
|
| 171 | - $button_args['class'] = ' button-secondary disabled '; |
|
| 172 | - }elseif($button_args['installed']){ |
|
| 173 | - $button_args['button_text'] = __('Activate','invoicing'); |
|
| 174 | - |
|
| 175 | - if($button_args['type'] != 'themes'){ |
|
| 176 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 177 | - $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
| 178 | - }else{ |
|
| 179 | - $button_args['url'] = '#'; |
|
| 180 | - } |
|
| 181 | - }else{ |
|
| 182 | - if ( current_user_can( 'switch_themes' ) ) { |
|
| 183 | - $button_args['url'] = self::get_theme_activation_url($addon); |
|
| 184 | - }else{ |
|
| 185 | - $button_args['url'] = '#'; |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - }else{ |
|
| 190 | - if($button_args['type'] == 'recommended_plugins'){ |
|
| 191 | - $button_args['button_text'] = __('Install','invoicing'); |
|
| 192 | - }else{ |
|
| 193 | - $button_args['button_text'] = __('Get it','invoicing'); |
|
| 194 | - |
|
| 195 | - /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
| 159 | + // set if active |
|
| 160 | + if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
| 161 | + if($button_args['type'] != 'themes'){ |
|
| 162 | + $button_args['active'] = is_plugin_active($button_args['file']); |
|
| 163 | + }else{ |
|
| 164 | + $button_args['active'] = self::is_theme_active($addon); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // set button text and class |
|
| 169 | + if($button_args['active']){ |
|
| 170 | + $button_args['button_text'] = __('Active','invoicing'); |
|
| 171 | + $button_args['class'] = ' button-secondary disabled '; |
|
| 172 | + }elseif($button_args['installed']){ |
|
| 173 | + $button_args['button_text'] = __('Activate','invoicing'); |
|
| 174 | + |
|
| 175 | + if($button_args['type'] != 'themes'){ |
|
| 176 | + if ( current_user_can( 'manage_options' ) ) { |
|
| 177 | + $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
| 178 | + }else{ |
|
| 179 | + $button_args['url'] = '#'; |
|
| 180 | + } |
|
| 181 | + }else{ |
|
| 182 | + if ( current_user_can( 'switch_themes' ) ) { |
|
| 183 | + $button_args['url'] = self::get_theme_activation_url($addon); |
|
| 184 | + }else{ |
|
| 185 | + $button_args['url'] = '#'; |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + }else{ |
|
| 190 | + if($button_args['type'] == 'recommended_plugins'){ |
|
| 191 | + $button_args['button_text'] = __('Install','invoicing'); |
|
| 192 | + }else{ |
|
| 193 | + $button_args['button_text'] = __('Get it','invoicing'); |
|
| 194 | + |
|
| 195 | + /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
| 196 | 196 | $button_args['button_text'] = __('Install','invoicing'); |
| 197 | 197 | $button_args['url'] = self::get_theme_install_url($button_args['slug']); |
| 198 | 198 | $button_args['onclick'] = 'gd_set_button_installing(this);'; |
| 199 | 199 | }*/ |
| 200 | 200 | |
| 201 | - } |
|
| 202 | - } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | |
| 205 | - // filter the button arguments |
|
| 206 | - $button_args = apply_filters('edd_api_button_args',$button_args); |
|
| 205 | + // filter the button arguments |
|
| 206 | + $button_args = apply_filters('edd_api_button_args',$button_args); |
|
| 207 | 207 | |
| 208 | - // set price text |
|
| 209 | - if(isset($button_args['price_text'])){ |
|
| 210 | - ?> |
|
| 208 | + // set price text |
|
| 209 | + if(isset($button_args['price_text'])){ |
|
| 210 | + ?> |
|
| 211 | 211 | <a |
| 212 | 212 | target="_blank" |
| 213 | 213 | class="addons-price-text" |
@@ -215,15 +215,15 @@ discard block |
||
| 215 | 215 | <?php echo esc_html( $button_args['price_text'] ); ?> |
| 216 | 216 | </a> |
| 217 | 217 | <?php |
| 218 | - } |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | 220 | |
| 221 | - $target = ''; |
|
| 222 | - if ( ! empty( $button_args['url'] ) ) { |
|
| 223 | - $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
|
| 224 | - } |
|
| 221 | + $target = ''; |
|
| 222 | + if ( ! empty( $button_args['url'] ) ) { |
|
| 223 | + $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - ?> |
|
| 226 | + ?> |
|
| 227 | 227 | <a |
| 228 | 228 | data-licence="<?php echo esc_attr($button_args['license']);?>" |
| 229 | 229 | data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>" |
@@ -246,28 +246,28 @@ discard block |
||
| 246 | 246 | <?php |
| 247 | 247 | |
| 248 | 248 | |
| 249 | - } |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Handles output of the addons page in admin. |
|
| 254 | - */ |
|
| 255 | - public function output() { |
|
| 256 | - $tabs = self::get_tabs(); |
|
| 257 | - $sections = self::get_sections(); |
|
| 258 | - $theme = wp_get_theme(); |
|
| 259 | - $section_keys = array_keys( $sections ); |
|
| 260 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
| 261 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 262 | - include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * A list of recommended wp.org plugins. |
|
| 267 | - * @return array |
|
| 268 | - */ |
|
| 269 | - public function get_recommend_wp_plugins(){ |
|
| 270 | - $plugins = array( |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Handles output of the addons page in admin. |
|
| 254 | + */ |
|
| 255 | + public function output() { |
|
| 256 | + $tabs = self::get_tabs(); |
|
| 257 | + $sections = self::get_sections(); |
|
| 258 | + $theme = wp_get_theme(); |
|
| 259 | + $section_keys = array_keys( $sections ); |
|
| 260 | + $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
| 261 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 262 | + include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * A list of recommended wp.org plugins. |
|
| 267 | + * @return array |
|
| 268 | + */ |
|
| 269 | + public function get_recommend_wp_plugins(){ |
|
| 270 | + $plugins = array( |
|
| 271 | 271 | 'invoicing-quotes' => array( |
| 272 | 272 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
| 273 | 273 | 'slug' => 'invoicing-quotes', |
@@ -287,8 +287,8 @@ discard block |
||
| 287 | 287 | 'name' => 'UsersWP', |
| 288 | 288 | 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'), |
| 289 | 289 | ), |
| 290 | - ); |
|
| 290 | + ); |
|
| 291 | 291 | |
| 292 | - return $plugins; |
|
| 293 | - } |
|
| 292 | + return $plugins; |
|
| 293 | + } |
|
| 294 | 294 | } |
@@ -45,8 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | if($section_id=='recommended_plugins'){ |
| 47 | 47 | $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
| 48 | - } |
|
| 49 | - elseif ( ! empty( $section ) ) { |
|
| 48 | + } elseif ( ! empty( $section ) ) { |
|
| 50 | 49 | if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
| 51 | 50 | //if ( 1==1) { |
| 52 | 51 | |
@@ -121,13 +120,13 @@ discard block |
||
| 121 | 120 | $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
| 122 | 121 | if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
| 123 | 122 | $button_args['update_url'] = "https://wpinvoicing.com"; |
| 124 | - }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
| 123 | + } elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
| 125 | 124 | if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
| 126 | 125 | $button_args['installed'] = self::is_theme_installed($addon); |
| 127 | 126 | if(!in_array($button_args['slug'],$wp_org_themes)){ |
| 128 | 127 | $button_args['update_url'] = "https://wpinvoicing.com"; |
| 129 | 128 | } |
| 130 | - }elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){ |
|
| 129 | + } elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){ |
|
| 131 | 130 | include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
| 132 | 131 | $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
| 133 | 132 | $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
@@ -139,7 +138,7 @@ discard block |
||
| 139 | 138 | if(is_object($addon->pricing)){ |
| 140 | 139 | $prices = (Array)$addon->pricing; |
| 141 | 140 | $button_args['price'] = reset($prices); |
| 142 | - }elseif(isset($addon->pricing)){ |
|
| 141 | + } elseif(isset($addon->pricing)){ |
|
| 143 | 142 | $button_args['price'] = $addon->pricing; |
| 144 | 143 | } |
| 145 | 144 | } |
@@ -160,7 +159,7 @@ discard block |
||
| 160 | 159 | if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
| 161 | 160 | if($button_args['type'] != 'themes'){ |
| 162 | 161 | $button_args['active'] = is_plugin_active($button_args['file']); |
| 163 | - }else{ |
|
| 162 | + } else{ |
|
| 164 | 163 | $button_args['active'] = self::is_theme_active($addon); |
| 165 | 164 | } |
| 166 | 165 | } |
@@ -169,27 +168,27 @@ discard block |
||
| 169 | 168 | if($button_args['active']){ |
| 170 | 169 | $button_args['button_text'] = __('Active','invoicing'); |
| 171 | 170 | $button_args['class'] = ' button-secondary disabled '; |
| 172 | - }elseif($button_args['installed']){ |
|
| 171 | + } elseif($button_args['installed']){ |
|
| 173 | 172 | $button_args['button_text'] = __('Activate','invoicing'); |
| 174 | 173 | |
| 175 | 174 | if($button_args['type'] != 'themes'){ |
| 176 | 175 | if ( current_user_can( 'manage_options' ) ) { |
| 177 | 176 | $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
| 178 | - }else{ |
|
| 177 | + } else{ |
|
| 179 | 178 | $button_args['url'] = '#'; |
| 180 | 179 | } |
| 181 | - }else{ |
|
| 180 | + } else{ |
|
| 182 | 181 | if ( current_user_can( 'switch_themes' ) ) { |
| 183 | 182 | $button_args['url'] = self::get_theme_activation_url($addon); |
| 184 | - }else{ |
|
| 183 | + } else{ |
|
| 185 | 184 | $button_args['url'] = '#'; |
| 186 | 185 | } |
| 187 | 186 | } |
| 188 | 187 | |
| 189 | - }else{ |
|
| 188 | + } else{ |
|
| 190 | 189 | if($button_args['type'] == 'recommended_plugins'){ |
| 191 | 190 | $button_args['button_text'] = __('Install','invoicing'); |
| 192 | - }else{ |
|
| 191 | + } else{ |
|
| 193 | 192 | $button_args['button_text'] = __('Get it','invoicing'); |
| 194 | 193 | |
| 195 | 194 | /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
@@ -1,6 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | + exit; |
|
| 5 | +} |
|
| 4 | 6 | if(!class_exists('Ayecode_Addons')) { |
| 5 | 7 | |
| 6 | 8 | abstract class Ayecode_Addons |