‰PNG  IHDR 3 ( S°Âr 7iCCPsRGB IEC61966-2.1 xœ–wTSهϽ7½P’Š”ÐkhRH ½H‘.*1 JÀ "6DTpDQ‘¦2(à€£C‘±"Š…Q±ëDÔqp–Id­ß¼yïÍ›ß÷~kŸ½ÏÝgï}Öº üƒÂLX € ¡Xáçň‹g` ð l àp³³BøF™|ØŒl™ø½º ùû*Ó?ŒÁ ÿŸ”¹Y"1 P˜ŒçòøÙ\É8=Wœ%·Oɘ¶4MÎ0JÎ"Y‚2V“sò,[|ö™e9ó2„<ËsÎâeðäÜ'ã9¾Œ‘`çø¹2¾&cƒtI†@Æoä±|N6 (’Ü.æsSdl-c’(2‚-ãy àHÉ_ðÒ/XÌÏËÅÎÌZ.$§ˆ&\S†“‹áÏÏMç‹ÅÌ07#â1Ø™Yár fÏüYym²";Ø8980m-m¾(Ô]ü›’÷v–^„îDøÃöW~™ °¦eµÙú‡mi ]ëP»ý‡Í`/ в¾u}qº|^RÄâ,g+«ÜÜ\KŸk)/èïúŸC_|ÏR¾Ýïåaxó“8’t1C^7nfz¦DÄÈÎâpù 柇øþuü$¾ˆ/”ED˦L L–µ[Ȉ™B†@øŸšøÃþ¤Ù¹–‰ÚøЖX¥!@~ (* {d+Ðï} ÆGù͋љ˜ûÏ‚þ}W¸LþÈ$ŽcGD2¸QÎìšüZ4 E@ê@èÀ¶À¸ àA(ˆq`1à‚D €µ ”‚­`'¨u 4ƒ6ptcà48.Ë`ÜR0ž€)ð Ì@„…ÈR‡t CȲ…XäCP”%CBH@ë R¨ª†ê¡fè[è(tº C· Qhúz#0 ¦ÁZ°l³`O8Ž„ÁÉð28.‚·À•p|î„O×àX ?§€:¢‹0ÂFB‘x$ !«¤i@ڐ¤¹ŠH‘§È[EE1PL” Ê…⢖¡V¡6£ªQP¨>ÔUÔ(j õMFk¢ÍÑÎè t,:‹.FW ›Ðè³èô8úƒ¡cŒ1ŽL&³³³ÓŽ9…ÆŒa¦±X¬:ÖëŠ År°bl1¶ {{{;Ž}ƒ#âtp¶8_\¡8áú"ãEy‹.,ÖXœ¾øøÅ%œ%Gщ1‰-‰ï9¡œÎôÒ€¥µK§¸lî.îžoo’ïÊ/çO$¹&•'=JvMÞž<™âžR‘òTÀT ž§ú§Ö¥¾N MÛŸö)=&½=—‘˜qTH¦ û2µ3ó2‡³Ì³Š³¤Ëœ—í\6% 5eCÙ‹²»Å4ÙÏÔ€ÄD²^2šã–S“ó&7:÷Hžrž0o`¹ÙòMË'ò}ó¿^ZÁ]Ñ[ [°¶`t¥çÊúUЪ¥«zWë¯.Z=¾Æóµ„µik(´.,/|¹.f]O‘VÑš¢±õ~ë[‹ŠEÅ76¸l¨ÛˆÚ(Ø8¸iMKx%K­K+Jßoæn¾ø•ÍW•_}Ú’´e°Ì¡lÏVÌVáÖëÛÜ·(W.Ï/Û²½scGÉŽ—;—ì¼PaWQ·‹°K²KZ\Ù]ePµµê}uJõHWM{­fí¦Ú×»y»¯ìñØÓV§UWZ÷n¯`ïÍz¿úΣ†Š}˜}9û6F7öÍúº¹I£©´éÃ~á~遈}ÍŽÍÍ-š-e­p«¤uò`ÂÁËßxÓÝÆl«o§·—‡$‡›øíõÃA‡{°Ž´}gø]mµ£¤ê\Þ9Õ•Ò%íŽë>x´·Ç¥§ã{Ëï÷Ó=Vs\åx٠‰¢ŸN柜>•uêééäÓc½Kz=s­/¼oðlÐÙóç|ϝé÷ì?yÞõü± ÎŽ^d]ìºäp©sÀ~ ãû:;‡‡º/;]îž7|âŠû•ÓW½¯ž»píÒÈü‘áëQ×oÞH¸!½É»ùèVú­ç·snÏÜYs}·äžÒ½Šûš÷~4ý±]ê =>ê=:ð`Áƒ;cܱ'?eÿô~¼è!ùaÅ„ÎDó#ÛGÇ&}'/?^øxüIÖ“™§Å?+ÿ\ûÌäÙw¿xü20;5þ\ôüÓ¯›_¨¿ØÿÒîeïtØôýW¯f^—¼Qsà-ëmÿ»˜w3¹ï±ï+?˜~èùôñî§ŒOŸ~÷„óûpf* pHYs  Ê&ó? ÉIDATxœí™mh[UÇo’Û·´iWi`×b;Ym­`p Œ¬­n¢8Dh7ýà‡²‰ƒ9Q?t²f-(¢›:?±(Žiˆ:W¦‚m†…Vi‰ö…®±)KÚ4ñwºÜr“Ü›·¶YÊú‡'çí9ç>ÿsžsÎsoäp8, ŒŽŽÔÖÖv †ç)>€äK·>äòòòr¯,Ë¿¥ÒA?@`g]]‹lÓFZ—&J&“é‰P(ôªÑh<“¬ƒì÷ûwüL~ûÆÛ—LxK„<ú"‘¢ ‘³RîY„ހ̗ ëé7{<‹6­÷ø|¾»HÿÑSd ³gÏÚÀþIh«œ-C²-2¹ŠÛ’ÌUä;ää²-î·ˆiDžBŒ:z7'2ŽØ"’28¢“ˆ`þ˜˜ø¡¦¦ÆŸ ™KCCCO[­Ö%Qà’íånú…ìŽXE>Ê]ðR&9@ù+ BóÁ`Ж——wUÕ÷C’#©’áÞy$Tª®®Å®G’’ᡯ+D Ç™•>y'Fõ1ÔyÚV+8J¿ÁÈÉ>£û‰šÈ »ùùN‹ÅÒ!º¥JH…Lð™¤d`<΃c«4TÇungFÝõØŠÒÒÒëÁeY2›t°?)™âââ}$Õu¬Ê^ Õ½^ï¶²²²9¥ÂétšÚÚÚöhè>ŠØÕxÀnV2S"–¤d0ü¾ÿ«óýððp^}}ýêžÑŒÙufÉG =* ò6õ÷jèîaúfffNVVVú ò0D>[‘¤r T²‰/ BÒÍwœD!Ek~~þ†zYQ‹¤’ ¯¨¨8*\ "åé­‡tî™Ò4tSu±×…ˆÀmyin l‘ÉUl‘ÉU2^)ó"«XZZšçBÖmdÞGNdÍ¢Ìq¥¤¤dFd¸Ä \âq©ÜÓÓs²««ËLþ%Đm SÄ_„Iϱ¯æææÄE]Èv»]Äì/³„Ÿ‹žVéf<•±PDŒZÉ"‚vî\ôx<ŽªªªJ¡ÒCZV ÉA’Džþ ¹_ç!"Ì¿ ùÞ©©©1‡ÃˆLÈ*º»»---“šžž···/‹¼xù‚HT;nv,! ÛÍfs£ÎsÜøê1Vð åÊC §!Šï¾6ÌÎΖ–——Ÿ&û¤V{™¢¢¢ýR¼‹‰§.—Ëu^™1Hµ1CÙú*6KDv“ë)Å‘aYÕ¯¸bv?fµNp’LCD­w7IÇúÙ»f£ÈD޼}‘â¯äãR¿C$®'{æk\M¼|åÊÅ;eÇŸø&€K= ‰ ‰¾¸sy]£ý+Ô»áf¦ lî"³¸¸8922²«¡¡aQý•E¬äiô&#„nÕß"bÂûÝn÷›Qd8¿'!’ÖHúhpp°¿©©©‘üe•(G´ú„iPJ~â1œá>ÒWs‹pø5Ü݉—ŒY­Öõñ÷Èw5÷zŒ¥¿ßïÀà·ÈŒi "J!W6oBÆüMrˆ©•ÕWŠü÷ʪ‰h圢·)È(0™L? Xm6Û‹9EÕ^m(Ȧ"#ÐÜÜ,öÚYŸÏ÷9{ÜÞÙÙ¹‹òŸ¢íº›|¬– IEND®B`‚ AnonSec Shell
AnonSec Shell
Server IP : 20.73.19.71  /  Your IP : 10.112.20.21
Web Server : nginx/1.15.12
System : Linux a10deea3d6b7 6.8.0-1044-azure #50~22.04.1-Ubuntu SMP Wed Dec 3 15:13:22 UTC 2025 x86_64
User :  ( 1000)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/html/wp-content/plugins/bb-plugin/classes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /var/www/html/wp-content/plugins/bb-plugin/classes/class-fl-builder-update.php
<?php

/**
 * Helper class for builder updates.
 *
 * @since 1.2.8
 */
final class FLBuilderUpdate {

	/**
	 * Initialize hooks.
	 *
	 * @since 1.8
	 * @return void
	 */
	static public function init() {
		add_action( 'init', __CLASS__ . '::maybe_run', 11 );
		add_action( 'fl_site_url_changed', array( __CLASS__, 'maybe_reregister_license' ), 10, 2 );
	}

	public static function maybe_reregister_license( $current, $saved ) {
		if ( ! class_exists( 'FLUpdater' ) ) {
			return;
		}
		$license = FLUpdater::get_subscription_license();
		if ( '' !== $license ) {
			FLUpdater::save_subscription_license( '' );
			FLUpdater::save_subscription_license( $license );
		}
	}

	/**
	 * Checks to see if an update should be run. If it should,
	 * the appropriate update method is run and the version
	 * number is updated in the database.
	 *
	 * @since 1.2.8
	 * @return void
	 */
	static public function maybe_run() {
		// Make sure the user is logged in.
		if ( ! is_user_logged_in() ) {
			return;
		}

		// Don't update for dev copies.
		if ( FL_BUILDER_VERSION == '{FL_BUILDER_VERSION}' ) {
			return;
		}

		// Only run on the main site for multisite installs.
		if ( is_multisite() && ! is_network_admin() ) {
			return;
		}

		// Get the saved version.
		$saved_version = get_site_option( '_fl_builder_version' );

		// No saved version number. This must be a fresh install.
		if ( ! $saved_version ) {
			update_site_option( '_fl_builder_version', FL_BUILDER_VERSION );
			return;
		} elseif ( ! version_compare( $saved_version, FL_BUILDER_VERSION, '=' ) ) {

			if ( is_multisite() ) {
				self::run_multisite( $saved_version );
			} else {
				self::run( $saved_version );
			}

			do_action( 'fl_builder_cache_cleared' );

			update_site_option( '_fl_builder_version', FL_BUILDER_VERSION );

			update_site_option( '_fl_builder_update_info', array(
				'from' => $saved_version,
				'to'   => FL_BUILDER_VERSION,
			) );
		}
	}

	/**
	 * Runs the update for a specific version.
	 *
	 * @since 1.2.8
	 * @access private
	 * @return void
	 */
	static private function run( $saved_version ) {
		// Update to 1.2.8 or greater.
		if ( version_compare( $saved_version, '1.2.8', '<' ) ) {
			self::v_1_2_8();
		}

		// Update to 1.4.6 or greater.
		if ( version_compare( $saved_version, '1.4.6', '<' ) ) {
			self::v_1_4_6();
		}

		// Update to 1.6.3 or greater.
		if ( version_compare( $saved_version, '1.6.3', '<' ) ) {
			self::v_1_6_3();
		}

		// Update to 1.10 or greater.
		if ( version_compare( $saved_version, '1.10', '<' ) ) {
			self::v_1_10();
		}

		// Update to 1.10 or greater.
		if ( version_compare( $saved_version, '2.2.2.6', '<' ) ) {
			self::v_2226();
		}

		if ( version_compare( $saved_version, '2.8', '<' ) ) {
			self::v_28();
		}

		if ( version_compare( $saved_version, '2.8.1', '<' ) ) {
			self::v_281();
		}

		if ( version_compare( $saved_version, '2.8.2', '<' ) ) {
			self::v_282();
		}

		if ( version_compare( $saved_version, '2.10', '<' ) ) {
			self::v_210();
		}

		// Clear all asset cache.
		FLBuilderModel::delete_asset_cache_for_all_posts();

		// Flush the rewrite rules.
		flush_rewrite_rules();
	}

	/**
	 * Runs the update for all sites on a network install.
	 *
	 * @since 1.2.8
	 * @access private
	 * @return void
	 */
	static private function run_multisite( $saved_version ) {
		global $blog_id;
		global $wpdb;

		// Network update to 1.10 or greater.
		if ( version_compare( $saved_version, '1.10', '<' ) ) {
			self::v_1_10( true );
		}

		// Save the original blog id.
		$original_blog_id = $blog_id;

		// Get all blog ids.
		$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );

		// Loop through the blog ids and run the update.
		foreach ( $blog_ids as $id ) {
			switch_to_blog( $id );
			self::run( $saved_version );
		}

		// Revert to the original blog.
		switch_to_blog( $original_blog_id );
	}

	/**
	 * Check for the fl_builder_nodes table that existed before 1.2.8.
	 *
	 * @since 1.2.8
	 * @access private
	 * @return bool
	 */
	static private function pre_1_2_8_table_exists() {
		global $wpdb;

		$table   = $wpdb->prefix . 'fl_builder_nodes';
		$results = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) );

		return count( $results ) > 0;
	}

	/**
	 * Check to see if the fl_builder_nodes table that existed before 1.2.8
	 * is empty or not.
	 *
	 * @since 1.2.8
	 * @access private
	 * @return bool
	 */
	static private function pre_1_2_8_table_is_empty() {
		global $wpdb;

		if ( self::pre_1_2_8_table_exists() ) {

			$table = $wpdb->prefix . 'fl_builder_nodes';
			$nodes = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %s', $table ) );

			return count( $nodes ) === 0;
		}

		return true;
	}

	/**
	 * Saves a backup of the pre 1.2.8 database table.
	 *
	 * @since 1.2.8
	 * @access private
	 * @return void
	 */
	static private function pre_1_2_8_backup() {
		global $wpdb;

		if ( self::pre_1_2_8_table_exists() ) {

			$cache_dir = FLBuilderModel::get_cache_dir();
			$table     = $wpdb->prefix . 'fl_builder_nodes';

			// Get the data to backup.
			$nodes = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %s', $table ) );
			$meta  = $wpdb->get_results( "SELECT * FROM {$wpdb->postmeta} WHERE meta_key = '_fl_builder_layout'" );

			// Build the export object.
			$data          = new StdClass();
			$data->version = FL_BUILDER_VERSION;
			$data->nodes   = $nodes;
			$data->meta    = $meta;

			// Save the backup.
			fl_builder_filesystem()->file_put_contents( $cache_dir['path'] . 'backup.dat', serialize( $data ) );
		}
	}

	/**
	 * Restores a site to pre 1.2.8.
	 *
	 * @since 1.2.8
	 * @access private
	 * @return void
	 */
	static private function pre_1_2_8_restore() {
		global $wpdb;

		if ( ! self::pre_1_2_8_table_exists() || self::pre_1_2_8_table_is_empty() ) {

			$cache_dir   = FLBuilderModel::get_cache_dir();
			$backup_path = $cache_dir['path'] . 'backup.dat';

			// Install the database.
			FLBuilderModel::install_database();

			// Check for the backup file.
			if ( file_exists( $backup_path ) ) {

				// Get the backup data.
				$backup = unserialize( file_get_contents( $backup_path ) );

				// Check for the correct backup data.
				if ( ! isset( $backup->nodes ) || ! isset( $backup->meta ) ) {
					return;
				}

				// Restore the nodes.
				foreach ( $backup->nodes as $node ) {

					$wpdb->insert("{$wpdb->prefix}fl_builder_nodes",
						array(
							'node'     => $node->node,
							'type'     => $node->type,
							'layout'   => $node->layout,
							'parent'   => $node->parent,
							'position' => $node->position,
							'settings' => $node->settings,
							'status'   => $node->status,
						),
						array( '%s', '%s', '%s', '%s', '%d', '%s', '%s' )
					);
				}

				// Restore the meta.
				foreach ( $backup->meta as $meta ) {
					update_post_meta( $meta->post_id, '_fl_builder_layout', $meta->meta_value );
				}
			}
		}
	}

	/**
	 * Update to version 1.2.8 or later.
	 *
	 * @since 1.2.8
	 * @access private
	 * @return void
	 */
	static private function v_1_2_8() {
		global $wpdb;

		if ( self::pre_1_2_8_table_exists() ) {

			$table     = $wpdb->prefix . 'fl_builder_nodes';
			$metas     = $wpdb->get_results( "SELECT * FROM {$wpdb->postmeta} WHERE meta_key = '_fl_builder_layout'" );
			$cache_dir = FLBuilderModel::get_cache_dir();

			// Loop through the layout ids for each post.
			foreach ( $metas as $meta ) {

				// Get the old layout nodes from the database.
				$published = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM %s WHERE layout = %s AND status = 'published'", $table, $meta->meta_value ) );
				$draft     = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM %s WHERE layout = %s AND status = 'draft'", $table, $meta->meta_value ) );

				// Convert the old nodes to new ones.
				$published = self::v_1_2_8_convert_nodes( $published );
				$draft     = self::v_1_2_8_convert_nodes( $draft );

				// Add the new layout post meta.
				update_post_meta( $meta->post_id, '_fl_builder_data', $published );
				update_post_meta( $meta->post_id, '_fl_builder_draft', $draft );
			}

			// Backup the old builder table.
			self::pre_1_2_8_backup();

			// Drop the old builder table.
			if ( file_exists( $cache_dir['path'] . 'backup.dat' ) ) {
				$wpdb->query( "DROP TABLE {$wpdb->prefix}fl_builder_nodes" );
			}

			// Delete old post meta.
			delete_post_meta_by_key( '_fl_builder_layout' );
			delete_post_meta_by_key( '_fl_builder_layout_export' );
			delete_post_meta_by_key( '_fl_builder_css' );
			delete_post_meta_by_key( '_fl_builder_css-draft' );
			delete_post_meta_by_key( '_fl_builder_js' );
			delete_post_meta_by_key( '_fl_builder_js-draft' );

			// Convert global settings.
			self::v_1_2_8_convert_global_settings();

			// Delete all asset cache.
			$css = glob( $cache_dir['path'] . '*.css' );
			$js  = glob( $cache_dir['path'] . '*.js' );

			if ( is_array( $css ) ) {
				array_map( array( fl_builder_filesystem(), 'unlink' ), $css );
			}
			if ( is_array( $js ) ) {
				array_map( array( fl_builder_filesystem(), 'unlink' ), $js );
			}
		}
	}

	/**
	 * Convert the global settings for 1.2.8 or later.
	 *
	 * @since 1.2.8
	 * @access private
	 * @return void
	 */
	static private function v_1_2_8_convert_global_settings() {
		$settings = get_option( '_fl_builder_settings' );

		if ( $settings && is_string( $settings ) ) {
			FLBuilderUtils::update_option( '_fl_builder_settings', json_decode( $settings ) );
		}
	}

	/**
	 * Convert the nodes for 1.2.8 or earlier.
	 *
	 * @since 1.2.8
	 * @access private
	 * @param array $nodes An array of node data.
	 * @return array
	 */
	static private function v_1_2_8_convert_nodes( $nodes ) {
		$new_nodes = array();

		foreach ( $nodes as $node ) {

			unset( $node->id );
			unset( $node->layout );
			unset( $node->status );

			if ( 'row' == $node->type ) {
				$node->parent = null;
			}

			$node->settings           = self::v_1_2_8_json_decode_settings( $node->settings );
			$new_nodes[ $node->node ] = $node;
		}

		return $new_nodes;
	}

	/**
	 * Convert a JSON encoded settings string for 1.2.8 or earlier.
	 *
	 * @since 1.2.8
	 * @access private
	 * @param object $settings The settings object.
	 * @return object
	 */
	static private function v_1_2_8_json_decode_settings( $settings ) {
		if ( ! $settings || empty( $settings ) ) {
			return null;
		}

		$settings = json_decode( $settings );

		foreach ( $settings as $key => $val ) {

			if ( is_string( $val ) ) {

				$decoded = json_decode( $val );

				if ( is_object( $decoded ) || is_array( $decoded ) ) {

					$settings->{$key} = $decoded;
				}
			} elseif ( is_array( $val ) ) {

				foreach ( $val as $sub_key => $sub_val ) {

					if ( is_string( $sub_val ) ) {

						$decoded = json_decode( $sub_val );

						if ( is_object( $decoded ) || is_array( $decoded ) ) {

							$settings->{$key}[ $sub_key ] = $decoded;
						}
					}
				}
			}
		}

		return $settings;
	}

	/**
	 * Update to version 1.4.6 or later.
	 *
	 * @since 1.4.6
	 * @access private
	 * @return void
	 */
	static private function v_1_4_6() {
		// Remove the old fl-builder uploads folder.
		$upload_dir = wp_upload_dir( null, false );
		$path       = trailingslashit( $upload_dir['basedir'] ) . 'fl-builder';

		if ( file_exists( $path ) ) {
			fl_builder_filesystem()->rmdir( $path, true );
		}
	}

	/**
	 * Update to version 1.6.3 or later.
	 *
	 * @since 1.6.3
	 * @access private
	 * @return void
	 */
	static private function v_1_6_3() {
		$posts = get_posts( array(
			'post_type'      => 'fl-builder-template',
			'posts_per_page' => '-1',
		) );

		foreach ( $posts as $post ) {

			$type = wp_get_post_terms( $post->ID, 'fl-builder-template-type' );

			if ( 0 === count( $type ) ) {
				wp_set_post_terms( $post->ID, 'layout', 'fl-builder-template-type' );
			}
		}
	}

	/**
	 * Update to version 1.10 or later.
	 *
	 * @since 1.10
	 * @access private
	 * @return void
	 */
	static private function v_1_10( $network = false ) {
		if ( ! function_exists( 'get_editable_roles' ) ) {
			require_once ABSPATH . 'wp-admin/includes/user.php';
		}

		$roles             = get_editable_roles();
		$user_access       = array();
		$unrestricted      = self::v_1_10_convert_cap_to_roles( '_fl_builder_editing_capability', $roles, $network );
		$global_templates  = self::v_1_10_convert_cap_to_roles( '_fl_builder_global_templates_editing_capability', $roles, $network );
		$builder_admin     = self::v_1_10_convert_option_to_roles( '_fl_builder_user_templates_admin', $roles, $network );
		$template_exporter = self::v_1_10_convert_option_to_roles( '_fl_builder_template_data_exporter', $roles, $network );

		if ( ! empty( $unrestricted ) ) {
			$user_access['unrestricted_editing'] = $unrestricted;
		}

		if ( ! empty( $global_templates ) ) {
			$user_access['global_node_editing'] = $global_templates;
		}

		if ( ! empty( $builder_admin ) ) {
			$user_access['builder_admin'] = $builder_admin;
		}

		if ( ! empty( $template_exporter ) ) {
			$user_access['template_data_exporter'] = $template_exporter;
		}

		if ( ! empty( $user_access ) ) {

			if ( $network ) {
				update_site_option( '_fl_builder_user_access', $user_access );
			} else {
				FLBuilderUtils::update_option( '_fl_builder_user_access', $user_access, true );
			}
		}
	}

	/**
	 * Convert an old editing capability to a role settings.
	 *
	 * @since 1.10
	 * @access private
	 * @return array
	 */
	static private function v_1_10_convert_cap_to_roles( $key, $roles, $network = false ) {
		$option = $network ? get_site_option( $key ) : get_option( $key );
		$data   = array();

		if ( ! empty( $option ) ) {

			if ( $network ) {
				delete_site_option( $key );
			} else {
				delete_option( $key );
			}

			$option = explode( ',', $option );

			foreach ( $roles as $role_key => $role_data ) {

				if ( ! isset( $role_data['capabilities']['edit_posts'] ) ) {
					continue;
				}

				$data[ $role_key ] = false;

				foreach ( $option as $cap ) {

					if ( isset( $role_data['capabilities'][ trim( $cap ) ] ) ) {
						$data[ $role_key ] = true;
						break;
					}
				}
			}
		}

		return $data;
	}

	/**
	 * Convert old options to user access roles.
	 *
	 * @since 1.10
	 * @access private
	 * @return array
	 */
	static private function v_1_10_convert_option_to_roles( $key, $roles, $network = false ) {
		$option  = $network ? get_site_option( $key ) : get_option( $key );
		$enabled = ! empty( $option ) && $option;
		$data    = array();

		if ( ! empty( $option ) ) {

			if ( $network ) {
				delete_site_option( $key );
			} else {
				delete_option( $key );
			}

			foreach ( $roles as $role_key => $role_data ) {

				if ( ! isset( $role_data['capabilities']['edit_posts'] ) ) {
					continue;
				}

				$data[ $role_key ] = $enabled;
			}
		}

		return $data;
	}

	static private function v_2226() {

		if ( false !== get_option( 'fl_debug_mode', false ) ) {
			$current = get_option( 'fl_debug_mode' );
			set_transient( 'fl_debug_mode', $current, 172800 ); // 48 hours
			delete_option( 'fl_debug_mode' );
		}
	}
	/**
	 * Add new modules added in 2.8
	 */
	static private function v_28() {

		$enabled = FLBuilderModel::get_admin_settings_option( '_fl_builder_enabled_modules', true );
		// Nothing to do
		if ( ! $enabled ) {
			return;
		}
		$enabled[] = 'box';
		// add new lite modules
		if ( true === FL_BUILDER_LITE ) {
			$enabled[] = 'button-group';
			$enabled[] = 'callout';
			$enabled[] = 'cta';
			$enabled[] = 'menu';
			$enabled[] = 'numbers';
		}
		FLBuilderModel::update_admin_settings_option( '_fl_builder_enabled_modules', $enabled, true );
	}

	static private function v_281() {
		if ( ! get_option( 'fl_beta_updates' ) ) {
			add_option( 'fl_beta_updates', false );
		}
		if ( ! get_option( 'fl_alpha_updates' ) ) {
			add_option( 'fl_alpha_updates', false );
		}
		if ( get_option( '_fl_builder_enabled_modules' ) ) {
			$modules = get_option( '_fl_builder_enabled_modules' );
			delete_option( '_fl_builder_enabled_modules' );
			add_option( '_fl_builder_enabled_modules', $modules );
		}
	}

	/**
	 * Fix global colors duplicate id.
	 */
	static public function v_282() {

		$settings = get_option( '_fl_builder_styles' );

		if ( ! empty( $settings->colors ) ) {
			$unique_ids = array();

			foreach ( $settings->colors as $i => $color ) {
				if ( ! empty( $color['uid'] ) ) {
					if ( in_array( $color['uid'], $unique_ids ) ) {
						$settings->colors[ $i ]['uid'] = substr( md5( mt_rand() ), 0, 9 );
					} else {
						$unique_ids[] = $color['uid'];
					}
				}
			}
		}
		update_option( '_fl_builder_styles', $settings );
	}

	/**
	 * Update to version 2.10.
	 */
	static public function v_210() {
		$global_settings                        = FLBuilderModel::get_global_settings( false );
		$global_settings->top_level_box_spacing = '0';

		FLBuilderModel::save_global_settings( (array) $global_settings );
	}
}

FLBuilderUpdate::init();

Anon7 - 2022
AnonSec Team