/
home
/
techb158
/
public_html
/
wp-content
/
plugins
/
optinmonster
/
OMAPI
/
/home/techb158/public_html/wp-content/plugins/optinmonster/OMAPI
mkdir
upload
Name
Size
Mode
Actions
EasyDigitalDownloads/
-
0755
rm
Elementor/
-
0755
rm
Integrations/
-
0755
rm
MemberPress/
-
0755
rm
Plugins/
-
0755
rm
Promos/
-
0755
rm
Rules/
-
0755
rm
Shortcodes/
-
0755
rm
WooCommerce/
-
0755
rm
WPForms/
-
0755
rm
Actions.php
7970
0666
edit
dl
rm
Ajax.php
1494
0666
edit
dl
rm
Api.php
14507
0666
edit
dl
rm
ApiAuth.php
2463
0666
edit
dl
rm
ApiKey.php
5203
0666
edit
dl
rm
AssetLoader.php
5489
0666
edit
dl
rm
BaseRestApi.php
6889
0666
edit
dl
rm
Blocks.php
13105
0666
edit
dl
rm
ClassicEditor.php
7084
0666
edit
dl
rm
ConstantContact.php
7591
0666
edit
dl
rm
Debug.php
4592
0666
edit
dl
rm
EasyDigitalDownloads.php
9553
0666
edit
dl
rm
Elementor.php
5493
0666
edit
dl
rm
Inserter.php
11571
0666
edit
dl
rm
InstallSkin.php
1386
0666
edit
dl
rm
InstallSkinCompat.php
1395
0666
edit
dl
rm
MailPoet.php
13974
0666
edit
dl
rm
MemberPress.php
4216
0666
edit
dl
rm
Menu.php
17301
0666
edit
dl
rm
Notifications.php
18910
0666
edit
dl
rm
OmuApi.php
4122
0666
edit
dl
rm
Output.php
25848
0666
edit
dl
rm
Pages.php
18019
0666
edit
dl
rm
Partners.php
5557
0666
edit
dl
rm
Plugins.php
24923
0666
edit
dl
rm
Promos.php
1131
0666
edit
dl
rm
Refresh.php
6553
0666
edit
dl
rm
RestApi.php
44190
0666
edit
dl
rm
RevenueAttribution.php
3037
0666
edit
dl
rm
Review.php
1482
0666
edit
dl
rm
Rules.php
24000
0666
edit
dl
rm
Save.php
11999
0666
edit
dl
rm
Shortcode.php
3667
0666
edit
dl
rm
Sites.php
8553
0666
edit
dl
rm
Support.php
9192
0666
edit
dl
rm
Type.php
3722
0666
edit
dl
rm
Urls.php
8951
0666
edit
dl
rm
Utils.php
7589
0666
edit
dl
rm
Validate.php
9266
0666
edit
dl
rm
Welcome.php
4929
0666
edit
dl
rm
Widget.php
6662
0666
edit
dl
rm
WooCommerce.php
20045
0666
edit
dl
rm
WpErrorException.php
714
0666
edit
dl
rm
WPForms.php
2665
0666
edit
dl
rm
Edit:
/home/techb158/public_html/wp-content/plugins/optinmonster/OMAPI/Save.php
(11999B)
<?php /** * Save class. * * @since 1.0.0 * * @package OMAPI * @author Thomas Griffin */ // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Save class. * * @since 1.0.0 */ class OMAPI_Save { /** * Holds the class object. * * @since 1.0.0 * * @var object */ public static $instance; /** * Path to the file. * * @since 1.0.0 * * @var string */ public $file = __FILE__; /** * Holds save error. * * @since 1.0.0 * * @var mixed */ public $error = null; /** * Holds the base class object. * * @since 1.0.0 * * @var object */ public $base; /** * Primary class constructor. * * @since 1.0.0 */ public function __construct() { // Set our object. $this->set(); } /** * Sets our object instance and base class instance. * * @since 1.0.0 */ public function set() { self::$instance = $this; $this->base = OMAPI::get_instance(); } /** * Store the optin data locally on the site. * * @since 1.0.0 * * @param array $optins Array of optin objects to store. * @param bool $enabled Whether newly-added campaigns are auto-enabled. Default is true. */ public function store_optins( $optins, $enabled = true ) { /** * Allows the filtering of what campaigns are stored locally. * * @since 1.6.3 * * @param array $optins An array of `WP_Post` objects. * @param object $this The OMAPI object. * * @return array The filtered `WP_Post` objects array. */ $optins = apply_filters( 'optin_monster_pre_store_options', $optins, $this ); // Do nothing if this is just a success message. if ( isset( $optins->success ) ) { return; } // Loop through all of the local optins so we can try to match and update. $local_optins = $this->base->get_optins( array( 'post_status' => 'any' ) ); if ( ! empty( $local_optins ) ) { $this->sync_optins( $local_optins, $optins, $enabled ); } else { $this->add_optins( $optins, $enabled ); } } /** * Add the retrieved optins as new optin post objects in the DB. * * @since 1.3.5 * * @param array $optins Array of optin objects to store. * @param bool $enabled Whether newly-added campaigns are auto-enabled. Default is true. */ public function add_optins( $optins, $enabled = true ) { foreach ( (array) $optins as $slug => $optin ) { // Maybe update an optin rather than add a new one. $local = $this->base->get_optin_by_slug( $slug ); if ( $local ) { $this->update_optin( $local, $optin ); } else { $this->new_optin( $slug, $optin, $enabled ); } } } /** * Sync the retrieved optins with our stored optins. * * @since 1.3.5 * * @param array $local_optins Array of local optin objects to sync. * @param array $remote_optins Array of optin objects to store. * @param bool $enabled Whether newly-added campaigns are auto-enabled. Default is true. */ public function sync_optins( $local_optins, $remote_optins, $enabled = true ) { foreach ( $local_optins as $local ) { if ( isset( $remote_optins[ $local->post_name ] ) ) { $this->update_optin( $local, $remote_optins[ $local->post_name ] ); unset( $remote_optins[ $local->post_name ] ); } else { // Delete the local optin. It does not exist remotely. $this->delete_optin( $local ); unset( $remote_optins[ $local->post_name ] ); } } // If we still have optins, they are new and we need to add them. if ( ! empty( $remote_optins ) ) { foreach ( (array) $remote_optins as $slug => $optin ) { $local = $this->base->get_optin_by_slug( $slug ); if ( $local ) { $this->update_optin( $local, $optin ); } else { $this->new_optin( $slug, $optin, $enabled ); } } } } /** * Update an existing optin post object in the DB with the one fetched from the API. * * @since 1.3.5 * * @param object $local The local optin post object. * @param object $optin The optin object. * * @return void */ public function update_optin( $local, $optin ) { $status = 'publish'; if ( ! empty( $optin->status ) && 'active' !== $optin->status ) { $status = 'draft'; } if ( $optin->title !== $local->post_title || $optin->output !== $local->post_content || $status !== $local->post_status ) { $this->optin_to_db( array( 'ID' => $local->ID, // Existing ID. 'post_title' => $optin->title, 'post_content' => $optin->output, 'post_status' => $status, ) ); } $this->update_optin_meta( $local->ID, $optin ); } /** * Generate a new optin post object in the DB. * * @since 1.3.5 * * @param string $slug The campaign slug. * @param object $optin The optin object. * @param bool $enabled Whether the new campaigns are auto-enabled. Default is true. * * @return void */ public function new_optin( $slug, $optin, $enabled = true ) { $status = 'publish'; if ( ! empty( $optin->status ) && 'active' !== $optin->status ) { $status = 'draft'; } $post_id = $this->optin_to_db( array( 'post_name' => $slug, 'post_title' => $optin->title, 'post_excerpt' => $optin->id, 'post_content' => $optin->output, 'post_status' => $status, 'post_type' => OMAPI_Type::SLUG, ) ); if ( 'post' === $optin->type ) { update_post_meta( $post_id, '_omapi_automatic', 1 ); } $this->update_optin_meta( $post_id, $optin ); } /** * Adds/updates the optin post-object in the DB. * * @since 1.9.10 * * @param array $args Array of args for post object. * * @return mixed Result */ protected function optin_to_db( $args ) { $priority = has_filter( 'content_save_pre', 'wp_filter_post_kses' ); if ( false !== $priority ) { remove_filter( 'content_save_pre', 'wp_filter_post_kses', $priority ); } if ( ! empty( $args['ID'] ) ) { $result = wp_update_post( $args ); } else { $result = wp_insert_post( $args ); } if ( false !== $priority ) { add_filter( 'content_save_pre', 'wp_filter_post_kses', $priority ); } return $result; } /** * Deletes the optin post-type object from the DB. * * @since 1.9.10 * * @param mixed $id WP_Post object, or post ID, or campaign slug (post_name). * @param boolean $by_slug Whether id passed in was the campaign slug. * * @return mixed Result of wp_delete_post. */ public function delete_optin( $id, $by_slug = false ) { if ( $by_slug ) { $id = $this->base->get_optin_by_slug( $id ); } return wp_delete_post( absint( ! empty( $id->ID ) ? $id->ID : $id ), true ); } /** * Update the optin post object's post-meta with an API object's values. * * @since 1.3.5 * * @param int $post_id The post (optin) ID. * @param object $optin The optin object. * * @return void */ public function update_optin_meta( $post_id, $optin ) { update_post_meta( $post_id, '_omapi_type', $optin->type ); update_post_meta( $post_id, '_omapi_ids', $optin->ids ); // Sync _omapi_enabled with campaign status from API (only when status is provided). if ( ! empty( $optin->status ) ) { if ( 'active' === $optin->status ) { update_post_meta( $post_id, '_omapi_enabled', true ); } else { delete_post_meta( $post_id, '_omapi_enabled' ); } } $shortcodes = ! empty( $optin->shortcodes ) ? $optin->shortcodes : null; $this->update_shortcodes_meta( $post_id, $shortcodes ); } /** * Store the raw shortcodes to the optin's meta for later retrieval/parsing. * * @since 1.3.5 * * @param int $post_id The post (optin) ID. * @param string|array|null $shortcodes The shortcodes to store to meta, or delete from meta if null. * * @return void */ protected function update_shortcodes_meta( $post_id, $shortcodes = null ) { if ( ! empty( $shortcodes ) ) { update_post_meta( $post_id, '_omapi_shortcode_output', self::get_shortcodes_string( $shortcodes ) ); update_post_meta( $post_id, '_omapi_shortcode', true ); } else { delete_post_meta( $post_id, '_omapi_shortcode_output' ); delete_post_meta( $post_id, '_omapi_shortcode' ); } } /** * Updated the `optin_monster_api` option in the database. * * @since 1.9.8 * * @param array $option The full `optin_monster_api` option array. * @param array $data Optional. The parameters passed in via POST request. * * @return mixed The results of update_option. */ public function update_option( $option, $data = array() ) { // Allow storing the timestamp of when the API is connected for "first time". // We are not changing it if the user disconnects and reconnects. $connected = $this->base->get_option( 'connected' ); if ( ! empty( $connected ) ) { unset( $option['connected'] ); } /** * Filters the `optin_monster_api` option before being saved to the database. * * @since 1.0.0 * * @param array $option The full `optin_monster_api` option array. * @param array $data The parameters passed in via POST request. */ $option = apply_filters( 'optin_monster_api_save', $option, $data ); // Save the option. return update_option( 'optin_monster_api', $option ); } /** * Handles auto-generating WooCommerce API keys for use with OM. * * @since 1.7.0 * @since 2.8.0 All the logic was moved to OMAPI_WooCommerce_Save class. * * @deprecated 2.8.0 Use `OMAPI_WooCommerce_Save->autogenerate()` instead. * * @return array */ public function woocommerce_autogenerate() { _deprecated_function( __FUNCTION__, '2.8.0', 'OMAPI_WooCommerce_Save->autogenerate()' ); return $this->base->woocommerce->save->autogenerate(); } /** * Handles connecting WooCommerce when the connect button is clicked. * * @since 1.7.0 * @since 2.8.0 All the logic was moved to OMAPI_WooCommerce_Save class. * * @deprecated 2.8.0 Use `OMAPI_WooCommerce_Save->connect()` instead. * * @param array $data The data passed in via POST request. * * @return mixed */ public function woocommerce_connect( $data ) { _deprecated_function( __FUNCTION__, '2.8.0', 'OMAPI_WooCommerce_Save->connect()' ); return $this->base->woocommerce->save->connect( $data ); } /** * Handles disconnecting WooCommerce when the disconnect button is clicked. * * @since 1.7.0 * @since 2.8.0 All the logic was moved to OMAPI_WooCommerce_Save class. * * @deprecated 2.8.0 Use `OMAPI_WooCommerce_Save->disconnect()` instead. * * @param array $data The data passed in via POST request. * * @return mixed */ public function woocommerce_disconnect( $data ) { _deprecated_function( __FUNCTION__, '2.8.0', 'OMAPI_WooCommerce_Save->disconnect()' ); return $this->base->woocommerce->save->disconnect( $data ); } /** * Parse shortcodes into a string. * * @since 2.2.0 * * @param mixed $shortcodes Convert shortcodes array to a concatenated string. * * @return string */ public static function get_shortcodes_string( $shortcodes ) { if ( is_array( $shortcodes ) ) { $encoded = array_map( static function ( $shortcode ) { return htmlentities( $shortcode ?? '', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8' ); }, $shortcodes ); return '|||' . implode( '|||', $encoded ); } return '|||' . htmlentities( $shortcodes ?? '', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8' ); } /** * Reverse the encoding applied by get_shortcodes_string(). * * Every reader of `_omapi_shortcode_output` must go through here. Both sides * previously stated their flags independently, and they drifted: PHP 8.1 * changed the htmlentities() default so the encoder began emitting `'` * while the readers still decoded with ENT_COMPAT, which leaves it alone. * * @since 2.17.0 * * @param string $shortcode An encoded shortcode string. * * @return string */ public static function decode_shortcode( $shortcode ) { return html_entity_decode( $shortcode ?? '', ENT_QUOTES, 'UTF-8' ); } }
Save
cmd:
run