Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
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.
if (!$this->civi->initialize()) {
return FALSE;
}
// Get the setting.
$setting = civicrm_api3('Setting', 'getvalue', [
'name' => 'wpBasePage',
'group' => 'CiviCRM Preferences',
]);
/**
* 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,
]);