From 6cfd0a3f51fbca11dc037341c1d7cbc640125d5b Mon Sep 17 00:00:00 2001 From: Daniel Espinoza Date: Wed, 10 Oct 2018 15:02:51 -0500 Subject: [PATCH] Adding a check for PMPro constant before querying the data. --- admin/class-convertkit-pmp-admin.php | 83 +++++++++++++++++----------- 1 file changed, 52 insertions(+), 31 deletions(-) diff --git a/admin/class-convertkit-pmp-admin.php b/admin/class-convertkit-pmp-admin.php index 41b43d7..bd83e6f 100644 --- a/admin/class-convertkit-pmp-admin.php +++ b/admin/class-convertkit-pmp-admin.php @@ -110,39 +110,48 @@ public function register_settings() { $this->plugin_name ); - // Get all PMP membership levels - $levels = $this->get_pmp_membership_levels(); + if ( defined( 'PMPRO_VERSION' ) ) { + // Get all PMP membership levels + $levels = $this->get_pmp_membership_levels(); - // Get all tags from ConvertKit - $tags = $this->api->get_tags(); + // Get all tags from ConvertKit + $tags = $this->api->get_tags(); - // No PMP mappings created yet - if ( empty ( $levels ) ){ + // No PMP mappings created yet + if ( empty ( $levels ) ) { + add_settings_field( + 'convertkit-empty-mapping', + apply_filters( $this->plugin_name . '-display-convertkit-mapping', __( 'Mapping', 'convertkit-pmp' ) ), + array( $this, 'display_options_empty_mapping' ), + $this->plugin_name, + $this->plugin_name . '-ck-mapping' + ); + } else { + foreach ( $levels as $key => $name ) { + + add_settings_field( + 'convertkit-mapping-' . $key, + apply_filters( $this->plugin_name . '-display-convertkit-mapping-' . $key, $name ), + array( $this, 'display_options_convertkit_mapping' ), + $this->plugin_name, + $this->plugin_name . '-ck-mapping', + array( + 'key' => $key, + 'name' => $name, + 'tags' => $tags, + ) + ); + } + } + } else { add_settings_field( 'convertkit-empty-mapping', apply_filters( $this->plugin_name . '-display-convertkit-mapping', __( 'Mapping', 'convertkit-pmp' ) ), - array( $this, 'display_options_empty_mapping' ), + array( $this, 'plugin_not_active' ), $this->plugin_name, $this->plugin_name . '-ck-mapping' ); - - } else { - foreach( $levels as $key => $name ) { - - add_settings_field( - 'convertkit-mapping-' . $key, - apply_filters( $this->plugin_name . '-display-convertkit-mapping-' . $key , $name ), - array( $this, 'display_options_convertkit_mapping' ), - $this->plugin_name, - $this->plugin_name . '-ck-mapping', - array( 'key' => $key, - 'name' => $name, - 'tags' => $tags, - ) - ); - } - } } @@ -173,12 +182,13 @@ public function add_menu() { * @return void */ public function options_page() { - ?>

-
plugin_name ); - submit_button( 'Save Settings' ); - ?>
+

+
plugin_name ); + submit_button( 'Save Settings' ); + ?>
+

+ pmpro_membership_levels ";