title: Notice: Undefined variable - WordPress / Parse Server Plugin - PHP Error
body: <p>So I'm putting together a WordPress plugin for a client based on <a href="https://github.com/norman784/wp-parse-api" rel="nofollow noreferrer">this Github project</a>, which would allow you to pull in posts from WordPress.</p>
  
  <p>Basically I pulled down the project and I had several errors. I've been tackling them one at a time. I had <a href="https://stackoverflow.com/questions/48073292/notice-undefined-index-parse-server-wordpress-plugin">posted a question here</a> before in relation to the first error in the bunch. I took the advice from user 'dipmala' and address that issue but now have this new issue that pops up when I try to run the 'sync' function.</p>
  
  <blockquote>
    <p>Notice: Undefined variable: options in
    /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/WP-Plugin/includes/class-wp-parse-api-admin-settings.php
    on line 42</p>
  </blockquote>
  
  <p>It appears that the sync fails. I'm thinking that one of the fixes I implemented is causing one of the variables to not be assigned.</p>
  
  <p>(UPDATE - I looked at the the link provided by 'cale_b', however I do believe the real underlining problem is beyond an undefined variable, as mentioned by 'benito', in his response. I'd like to get the underlining problem fixed, not just side step the error.)</p>
  
  <p>I would appreciate very much if someone could offer me some insight on how to fix this issue so that the plugin successfully syncs to the Parse Server instance.</p>
  
  <p>The Parse Server is being hosted by Back4App.</p>
  
  <p>I've posted the code from 'class-wp-parse-api-admin-settings.php' <a href="https://pastebin.com/vMe0reun" rel="nofollow noreferrer">here on PasteBin and below...</a></p>
  
  <pre><code>&lt;?php
  if (!defined('WP_PARSE_API_PATH')) die('.______.');
  
  if (is_admin()){     // admin actions
      add_action('admin_menu', 'wp_parse_api_menu');
      add_action('admin_post_wp_parse_api_sync', 'wp_parse_api_sync');
  
      function wp_parse_api_menu() {
          add_options_page('Parse Api Options', 'Parse Api', 'manage_options', 'wp-parse-api-options', 'wp_parse_api_page');
          add_action('admin_init', 'wp_parse_api_admin_init');
      }
  
      function wp_parse_api_admin_init() {
          //register our settings
          register_setting('wp-parse-api-settings-group', 'app_id');
          register_setting('wp-parse-api-settings-group', 'app_masterkey');
          register_setting('wp-parse-api-settings-group', 'app_restkey');
          register_setting('wp-parse-api-settings-group', 'app_url');
          register_setting('wp-parse-api-settings-group', 'app_push_notifications');
          register_setting('wp-parse-api-settings-group', 'object_name');
          register_setting('wp-parse-api-settings-group', 'lang');
      }
  
      function wp_parse_api_page() {
          require WP_PARSE_API_PATH .'includes/class-wp-parse-api-admin-settings-template.php';
      }
  
      function wp_parse_api_sync() {
          $numberposts = 10;
  
          if (isset($_GET['wp-parse-api-page'])) {
              $_GET['wp-parse-api-page'] = (int)$_GET['wp-parse-api-page'];
              if ($_GET['wp-parse-api-page'] &lt; 1) $_GET['wp-parse-api-page'] = 1;
  
              $options = array(
              'numberposts' =&gt; $numberposts,
              'offset' =&gt; ($_GET['wp-parse-api-page'] * $numberposts) - $numberposts,
              );
          }
  
  
          $wp_posts = get_posts($options);    
          if (count($wp_posts) == 0) {
              wp_redirect( 'options-general.php?page=wp-parse-api-options' );
              exit;
          }
  
          foreach ($wp_posts as $wp) {
              if ($wp-&gt;post_status != 'publish') continue;
  
              $post = WpParseApiHelpers::postToObject($wp-&gt;ID);
              $q = new parseQuery(WP_PARSE_API_OBJECT_NAME);
              $q-&gt;whereEqualTo('wpId', $wp-&gt;ID);
              $q-&gt;setLimit(1);
              $result = $q-&gt;find();
  
              if ($result-&gt;results[0]) {
                  $post-&gt;update($result-&gt;results[0]-&gt;objectId);
              } else {
                  $post-&gt;save();
              }
          }
  
          ++$_GET['wp-parse-api-page'];
          $url = $_SERVER['PHP_SELF'];
  
          foreach ($_GET as $k=&gt;$v):
              $qs = (strpos($url, '?') === false ? '?' : '&amp;');
              $url .= sprintf("%s%s=%s", $qs, $k, $v);
          endforeach;
  
          //wp_redirect( $url );
          echo "Page:". ($_GET['wp-parse-api-page']-1) ."&lt;script&gt; setTimeout(\"document.location='$url'\", 1000); &lt;/script&gt;";
          exit;   
      }
  }
  </code></pre>