| Server IP : 89.108.64.180 / Your IP : 216.73.217.92 Web Server : Apache/2.4.41 (Ubuntu) System : Linux 89-108-64-180.cloudvps.regruhosting.ru 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-root ( 1010) PHP Version : 8.0.30 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/fl-brief.agast.ru/wp-content/plugins/mailpoet/lib/Settings/ |
Upload File : |
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
namespace MailPoet\Settings;
if (!defined('ABSPATH')) exit;
use MailPoet\Subscription;
use MailPoet\WP\Functions as WPFunctions;
class Pages {
public function __construct() {
}
public function init() {
WPFunctions::get()->registerPostType('mailpoet_page', [
'labels' => [
'name' => __('MailPoet Page', 'mailpoet'),
'singular_name' => __('MailPoet Page', 'mailpoet'),
],
'public' => true,
'has_archive' => false,
'show_ui' => false,
'show_in_menu' => false,
'rewrite' => false,
'show_in_nav_menus' => false,
'can_export' => false,
'publicly_queryable' => true,
'exclude_from_search' => true,
]);
}
public static function createMailPoetPage() {
WPFunctions::get()->removeAllActions('pre_post_update');
WPFunctions::get()->removeAllActions('save_post');
WPFunctions::get()->removeAllActions('wp_insert_post');
$id = WPFunctions::get()->wpInsertPost([
'post_status' => 'publish',
'post_type' => 'mailpoet_page',
'post_author' => 1,
'post_content' => '[mailpoet_page]',
'post_title' => __('MailPoet Page', 'mailpoet'),
'post_name' => 'subscriptions',
]);
return ((int)$id > 0) ? (int)$id : false;
}
public static function getDefaultMailPoetPage() {
$wp = WPFunctions::get();
$pages = $wp->getPosts([
'posts_per_page' => 1,
'orderby' => 'date',
'order' => 'DESC',
'post_type' => 'mailpoet_page',
]);
$page = null;
if (!empty($pages)) {
$page = array_shift($pages);
if (strpos($page->post_content, '[mailpoet_page]') === false) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
$page = null;
}
}
return $page;
}
public static function getMailPoetPages() {
return WPFunctions::get()->getPosts([
'post_type' => 'mailpoet_page',
]);
}
/**
* @param int $id
*
* @return bool
*/
public static function isMailpoetPage($id) {
$mailpoetPages = static::getMailPoetPages();
foreach ($mailpoetPages as $mailpoetPage) {
if ($mailpoetPage->ID === $id) {
return true;
}
}
return false;
}
public static function getAll() {
$allPages = array_merge(
static::getMailPoetPages(),
WPFunctions::get()->getPages()
);
$pages = [];
foreach ($allPages as $page) {
$pages[] = static::getPageData($page);
}
return $pages;
}
public static function getPageData($page) {
$subscriptionUrlFactory = Subscription\SubscriptionUrlFactory::getInstance();
return [
'id' => $page->ID,
'title' => $page->post_title, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
'url' => [
'unsubscribe' => $subscriptionUrlFactory->getSubscriptionUrl($page, 'unsubscribe'),
'manage' => $subscriptionUrlFactory->getSubscriptionUrl($page, 'manage'),
'confirm' => $subscriptionUrlFactory->getSubscriptionUrl($page, 'confirm'),
'confirm_unsubscribe' => $subscriptionUrlFactory->getSubscriptionUrl($page, 'confirm_unsubscribe'),
're_engagement' => $subscriptionUrlFactory->getSubscriptionUrl($page, 're_engagement'),
],
];
}
}