Skip to content
Snippets Groups Projects
civicrm.basepage.php 28.8 KiB
Newer Older
  • Learn to ignore specific revisions
  •     return get_permalink($basepage->ID);
    
      }
    
      /**
       * Gets the Base Page title.
       *
       * @since 5.66
       *
       * @return string $basepage_title The title of the CiviCRM entity.
       */
      public function title_get() {
        return $this->basepage_title;
      }
    
      /**
       * Checks a Post ID against the Base Page ID.
       *
       * @since 5.66
       *
       * @param int $post_id The Post ID to check.
       * @return bool TRUE if the Post ID matches the Base Page ID, or FALSE otherwise.
       */
      public function is_match($post_id) {
    
        // Get the Base Page ID.
        $basepage_id = $this->id_get();
        if ($basepage_id === FALSE) {
          return FALSE;
        }
    
        // Determine if the given Post is the Base Page.
        $is_basepage = $basepage_id === $post_id ? TRUE : FALSE;
    
        /**
         * Filters the CiviCRM Base Page match.
         *
         * @since 5.66
         *
         * @param bool $is_basepage TRUE if the Post ID matches the Base Page ID, FALSE otherwise.
         * @param int $post_id The WordPress Post ID to check.
         */
        return apply_filters('civicrm/basepage/match', $is_basepage, $post_id);
    
      }
    
      /**
       * Gets the current Base Page setting.
       *
       * @since 5.66
       *
       * @return string|bool $setting The Base Page setting, or FALSE on failure.
       */
      public function setting_get() {
    
        // Bail if CiviCRM not bootstrapped.
    
    Kevin Cristiano's avatar
    Kevin Cristiano committed
        if (!$this->civi->initialize()) {
          return FALSE;
        }
    
        // Get the setting.
    
        $setting = civicrm_api3('Setting', 'getvalue', [
    
    Kevin Cristiano's avatar
    Kevin Cristiano committed
          'name' => 'wpBasePage',
          'group' => 'CiviCRM Preferences',
        ]);
    
    
        return $setting;
    
      /**
       * Sets the current Base Page setting.
       *
       * @since 5.66
       *
       * @param string $slug The Base Page setting.
       */
      public function setting_set($slug) {
    
        // Bail if CiviCRM not bootstrapped.
        if (!$this->civi->initialize()) {
          return;
    
        // Set the setting.
        civicrm_api3('Setting', 'create', [
          'wpBasePage' => $slug,
        ]);
    
    Kevin Cristiano's avatar
    Kevin Cristiano committed
    }