/**
  * Explodes a JLSuggest database string into an array with the destination type and the destination ID.
  * 
  * @since 6.0
  * 
  * @param $valstr The database string, e.g. http://example.com or obj_posttype_post/1
  * @return array
  */
 function jlsuggest_value_explode($valstr)
 {
     if (is_array($valstr)) {
         if (count($valstr) == 3) {
             return $valstr;
         }
     } elseif (is_string($valstr)) {
         if (sustr::startswith($valstr, 'obj_')) {
             $valstr = sustr::ltrim_str($valstr, 'obj_');
             $valarr = explode('/', $valstr);
             if (count($valarr) == 2) {
                 $valarr_type = explode('_', $valarr[0], 2);
                 if (count($valarr_type) == 2) {
                     return array($valarr_type[0], $valarr_type[1], $valarr[1]);
                 } else {
                     return array($valarr[0], null, $valarr[1]);
                 }
             } else {
                 return array($valstr, null, null);
             }
         } else {
             return array('url', null, $valstr);
         }
     }
     return array('url', null, '');
 }
 function admin_page_contents()
 {
     echo "\n<p>";
     _e('The Content Links section of Deeplink Juggernaut lets you automatically link a certain word or phrase in your post/page content to a URL you specify.', 'seo-ultimate');
     echo "</p>\n";
     $links = $this->get_setting('links', array());
     $num_links = count($links);
     if ($this->is_action('update')) {
         $links = array();
         $guid = stripslashes($_POST['_link_guid']);
         for ($i = 0; $i <= $num_links; $i++) {
             $anchor = stripslashes($_POST["link_{$i}_anchor"]);
             $to = stripslashes($_POST["link_{$i}_to"]);
             if (sustr::startswith($to, 'obj_')) {
                 $to = sustr::ltrim_str($to, 'obj_');
                 $to = explode('/', $to);
                 if (count($to) == 2) {
                     $to_type = $to[0];
                     $to_id = $to[1];
                 } else {
                     $to_type = $to[0];
                     $to_id = null;
                 }
             } else {
                 $to_type = 'url';
                 $to_id = $to;
             }
             $title = stripslashes($_POST["link_{$i}_title"]);
             $dampen_sitewide_lpa = sustr::preg_filter('0-9', strval($_POST["link_{$i}_dampen_sitewide_lpa"]));
             $dampen_sitewide_lpa = $dampen_sitewide_lpa === '' ? false : intval($dampen_sitewide_lpa);
             $sitewide_lpa = isset($_POST["link_{$i}_sitewide_lpa"]) ? sustr::preg_filter('0-9', strval($_POST["link_{$i}_sitewide_lpa"])) : '';
             $sitewide_lpa = $sitewide_lpa === '' ? false : intval($sitewide_lpa);
             $target = empty($_POST["link_{$i}_target"]) ? 'self' : 'blank';
             $nofollow = isset($_POST["link_{$i}_nofollow"]) ? intval($_POST["link_{$i}_nofollow"]) == 1 : false;
             $delete = isset($_POST["link_{$i}_delete"]) ? intval($_POST["link_{$i}_delete"]) == 1 : false;
             if (!$delete && (strlen($anchor) || $to_id)) {
                 $links[] = compact('anchor', 'to_type', 'to_id', 'title', 'dampen_sitewide_lpa', 'sitewide_lpa', 'nofollow', 'target');
             }
         }
         $this->update_setting('links', $links);
         $num_links = count($links);
     }
     $this->legacy_sitewide_lpa_in_use = false;
     foreach ($links as $link) {
         if (isset($link['sitewide_lpa']) && $link['sitewide_lpa']) {
             $this->legacy_sitewide_lpa_in_use = true;
             break;
         }
     }
     if ($this->legacy_sitewide_lpa_in_use) {
         $this->print_message('warning', __('<strong>Functionality Change Notice:</strong> The &#8220;Site Cap&#8221; feature (which allowed you set a per-link sitewide quantity limit) has been replaced with a more efficient &#8220;Dampener&#8221; feature that lets you reduce autolinking frequency by a percentage. Although the Site Cap feature has been replaced, we retained the &#8220;Site Cap&#8221; column for you in the table below, since it looks like you&#8217;ve used the Site Cap feature in the past. We retained the column to help you remember which links used the old feature, so that you know to which links to apply the new &#8220;Dampener&#8221; feature. Once you&#8217;re done migrating the Site Cap values to Dampener percentages, just clear the &#8220;Site Cap&#8221; boxes to make those boxes (and this message) go away.', 'seo-ultimate'));
     }
     $guid = substr(md5(time()), 0, 10);
     if ($num_links > 0) {
         $this->admin_subheader(__('Edit Existing Links', 'seo-ultimate'));
         $this->content_links_form($guid, 0, $links);
     }
     $this->admin_subheader(__('Add a New Link', 'seo-ultimate'));
     $this->content_links_form($guid, $num_links, array(array()), false);
 }