'P24 Subskrypcje', 'post_name' => 'p24-subscription', 'post_type' => 'page', 'post_content' => '[p24_user_subscription]', 'post_status' => 'publish', ) ); self::set_page_id( $page_id ); } return $page_id; } /** * Update page. * * @param string $action Name of action. */ private static function update_page( $action ) { switch ( $action ) { case 'delete': self::set_page_id( null ); break; case 'force': self::set_page_id( null ); self::set_page(); break; case 'generate': self::set_page(); break; case 'nothing': default: break; } } /** * Update config. * * @param array $data Provided data. * @return array */ public static function update_config( $data ) { if ( array_key_exists( 'p24_subscriptions_active', $data ) ) { $active = (bool) $data['p24_subscriptions_active']; } else { $active = false; } if ( array_key_exists( 'p24_subscriptions_days', $data ) ) { $days = (int) $data['p24_subscriptions_days']; } if ( ! isset( $days ) || $days < 1 ) { $days = 1; } if ( array_key_exists( 'p24_subscription_page', $data ) ) { self::update_page( $data['p24_subscription_page'] ); } $ret = array( 'przelewy24_subscriptions_active' => $active ? 'yes' : 'no', 'przelewy24_subscriptions_days' => $days, ); return $ret; } }