File manager - Edit - /home/premiey/www/wp-includes/images/media/models.tar
Back
class-box.php 0000666 00000003662 15166274120 0007167 0 ustar 00 <?php namespace QuadLayers\QLWAPP\Models; use QuadLayers\QLWAPP\Entities\Box as Box_Entity; use QuadLayers\WP_Orm\Builder\SingleRepositoryBuilder; class Box { protected static $instance; protected $repository; public function __construct() { add_filter( 'sanitize_option_qlwapp_box', 'wp_unslash' ); $builder = ( new SingleRepositoryBuilder() ) ->setTable( 'qlwapp_box' ) ->setEntity( Box_Entity::class ); $this->repository = $builder->getRepository(); } public function get_table() { return $this->repository->getTable(); } public function get() { $entity = $this->repository->find(); $result = null; if ( $entity ) { $result = $entity->getProperties(); } else { $admin = new Box_Entity(); $result = $admin->getProperties(); } if ( ! is_admin() ) { $result['header'] = qlwapp_replacements_vars( $result['header'] ); $result['footer'] = qlwapp_replacements_vars( $result['footer'] ); } return $result; } public function delete_all() { return $this->repository->delete(); } public function save( $data ) { $entity = $this->repository->create( $this->sanitize( $data ) ); if ( $entity ) { return true; } } public function sanitize( $settings ) { if ( isset( $settings['header'] ) ) { $settings['header'] = wp_kses_post( $settings['header'] ); } if ( isset( $settings['auto_open'] ) ) { $settings['auto_open'] = wp_kses_post( $settings['auto_open'] ); } if ( isset( $settings['lazy_load'] ) ) { $settings['lazy_load'] = wp_kses_post( $settings['lazy_load'] ); } if ( isset( $settings['auto_delay_open'] ) ) { $settings['auto_delay_open'] = wp_kses_post( $settings['auto_delay_open'] ); } if ( isset( $settings['footer'] ) ) { $settings['footer'] = wp_kses_post( $settings['footer'] ); } return $settings; } public static function instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } } class-woocommerce.php 0000666 00000002527 15166274120 0010715 0 ustar 00 <?php namespace QuadLayers\QLWAPP\Models; use QuadLayers\QLWAPP\Entities\WooCommerce as WooCommerce_Entity; use QuadLayers\WP_Orm\Builder\SingleRepositoryBuilder; class WooCommerce { protected static $instance; protected $repository; public function __construct() { add_filter( 'sanitize_option_qlwapp_woocommerce', 'wp_unslash' ); $builder = ( new SingleRepositoryBuilder() ) ->setTable( 'qlwapp_woocommerce' ) ->setEntity( WooCommerce_Entity::class ); $this->repository = $builder->getRepository(); } public function get_table() { return $this->repository->getTable(); } public function get() { $entity = $this->repository->find(); $result = null; if ( $entity ) { $result = $entity->getProperties(); } else { $admin = new WooCommerce_Entity(); $result = $admin->getProperties(); } if ( ! is_admin() ) { $result['text'] = qlwapp_replacements_vars( $result['text'] ); $result['message'] = qlwapp_replacements_vars( $result['message'] ); } return $result; } public function delete_all() { return $this->repository->delete(); } public function save( $data ) { $entity = $this->repository->create( $data ); if ( $entity ) { return true; } } public static function instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } } class-scheme.php 0000666 00000002136 15166274120 0007636 0 ustar 00 <?php namespace QuadLayers\QLWAPP\Models; use QuadLayers\QLWAPP\Entities\Scheme as Scheme_Entity; use QuadLayers\WP_Orm\Builder\SingleRepositoryBuilder; class Scheme { protected static $instance; protected $repository; public function __construct() { add_filter( 'sanitize_option_qlwapp_scheme', 'wp_unslash' ); $builder = ( new SingleRepositoryBuilder() ) ->setTable( 'qlwapp_scheme' ) ->setEntity( Scheme_Entity::class ); $this->repository = $builder->getRepository(); } public function get_table() { return $this->repository->getTable(); } public function get() { $entity = $this->repository->find(); if ( $entity ) { return $entity->getProperties(); } else { $admin = new Scheme_Entity(); return $admin->getProperties(); } } public function delete_all() { return $this->repository->delete(); } public function save( $data ) { $entity = $this->repository->create( $data ); if ( $entity ) { return true; } } public static function instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } } class-settings.php 0000666 00000002154 15166274120 0010232 0 ustar 00 <?php namespace QuadLayers\QLWAPP\Models; use QuadLayers\QLWAPP\Entities\Settings as Settings_Entity; use QuadLayers\WP_Orm\Builder\SingleRepositoryBuilder; class Settings { protected static $instance; protected $repository; public function __construct() { add_filter( 'sanitize_option_qlwapp_settings', 'wp_unslash' ); $builder = ( new SingleRepositoryBuilder() ) ->setTable( 'qlwapp_settings' ) ->setEntity( Settings_Entity::class ); $this->repository = $builder->getRepository(); } public function get_table() { return $this->repository->getTable(); } public function get() { $entity = $this->repository->find(); if ( $entity ) { return $entity->getProperties(); } else { $admin = new Settings_Entity(); return $admin->getProperties(); } } public function delete_all() { return $this->repository->delete(); } public function save( $data ) { $entity = $this->repository->create( $data ); if ( $entity ) { return true; } } public static function instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } } class-display.php 0000666 00000002145 15166274120 0010037 0 ustar 00 <?php namespace QuadLayers\QLWAPP\Models; use QuadLayers\QLWAPP\Entities\Display as Display_Entity; use QuadLayers\WP_Orm\Builder\SingleRepositoryBuilder; class Display { protected static $instance; protected $repository; public function __construct() { add_filter( 'sanitize_option_qlwapp_display', 'wp_unslash' ); $builder = ( new SingleRepositoryBuilder() ) ->setTable( 'qlwapp_display' ) ->setEntity( Display_Entity::class ); $this->repository = $builder->getRepository(); } public function get_table() { return $this->repository->getTable(); } public function get() { $entity = $this->repository->find(); if ( $entity ) { return $entity->getProperties(); } else { $admin = new Display_Entity(); return $admin->getProperties(); } } public function delete_all() { return $this->repository->delete(); } public function save( $data ) { $entity = $this->repository->create( $data ); if ( $entity ) { return true; } } public static function instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } } class-button.php 0000666 00000004224 15166274120 0007705 0 ustar 00 <?php namespace QuadLayers\QLWAPP\Models; use QuadLayers\QLWAPP\Entities\Button as Button_Entity; use QuadLayers\WP_Orm\Builder\SingleRepositoryBuilder; class Button { protected static $instance; protected $repository; public function __construct() { add_filter( 'sanitize_option_qlwapp_button', 'wp_unslash' ); $builder = ( new SingleRepositoryBuilder() ) ->setTable( 'qlwapp_button' ) ->setEntity( Button_Entity::class ); $this->repository = $builder->getRepository(); } public function get_table() { return $this->repository->getTable(); } public function get() { $entity = $this->repository->find(); $result = null; if ( $entity ) { $result = $entity->getProperties(); } else { $admin = new Button_Entity(); $result = $admin->getProperties(); } if ( ! is_admin() ) { $result['text'] = qlwapp_replacements_vars( $result['text'] ); $result['message'] = qlwapp_replacements_vars( $result['message'] ); } return $result; } public function delete_all() { return $this->repository->delete(); } public function save( $data ) { $entity = $this->repository->create( $this->sanitize( $data ) ); if ( $entity ) { return true; } } public function sanitize( $settings ) { if ( isset( $settings['layout'] ) ) { $settings['layout'] = sanitize_html_class( $settings['layout'] ); } if ( isset( $settings['position'] ) ) { $settings['position'] = sanitize_html_class( $settings['position'] ); } if ( isset( $settings['text'] ) ) { $settings['text'] = sanitize_text_field( $settings['text'] ); } if ( isset( $settings['message'] ) ) { $settings['message'] = sanitize_textarea_field( $settings['message'] ); } if ( isset( $settings['icon'] ) ) { $settings['icon'] = sanitize_html_class( $settings['icon'] ); } if ( isset( $settings['phone'] ) ) { $settings['phone'] = qlwapp_format_phone( $settings['phone'] ); } if ( isset( $settings['group'] ) ) { $settings['group'] = sanitize_url( $settings['group'] ); } return $settings; } public static function instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } } class-contacts.php 0000666 00000011331 15166274120 0010205 0 ustar 00 <?php namespace QuadLayers\QLWAPP\Models; use QuadLayers\QLWAPP\Entities\Contact as Contact_Entity; use QuadLayers\WP_Orm\Builder\CollectionRepositoryBuilder; /** * Models_Contacts Class */ class Contacts { protected static $instance; protected $repository; public function __construct() { add_filter( 'sanitize_option_qlwapp_contacts', 'wp_unslash' ); $models_button = Button::instance(); $button = $models_button->get(); $builder = ( new CollectionRepositoryBuilder() ) ->setTable( 'qlwapp_contacts' ) ->setEntity( Contact_Entity::class ) ->setDefaultEntities( array( array( 'allowDelete' => false, 'phone' => qlwapp_format_phone( $button['phone'] ), 'message' => qlwapp_replacements_vars( $button['message'] ), ), ) ) ->setAutoIncrement( true ); $this->repository = $builder->getRepository(); } public function get_table() { return $this->repository->getTable(); } public function get_args() { $entity = new Contact_Entity(); $defaults = $entity->getDefaults(); return $defaults; } public function get( int $id ) { $entity = $this->repository->find( $id ); if ( $entity ) { return $entity->getProperties(); } } public function delete( int $id ) { return $this->repository->delete( $id ); } public function update_all( array $contacts ) { foreach ( $contacts as $contact ) { if ( isset( $contact['id'] ) ) { $this->update( $contact['id'], $contact ); } } return true; } public function update( int $id, array $contact ) { $entity = $this->repository->update( $id, $this->sanitize_value_data( $contact ) ); if ( $entity ) { return $entity->getProperties(); } } public function create( array $contact ) { if ( isset( $contact['id'] ) ) { unset( $contact['id'] ); } $entity = $this->repository->create( $this->sanitize_value_data( $contact ) ); if ( $entity ) { return $entity->getProperties(); } } public function order_contact( $a, $b ) { if ( ! isset( $a['order'] ) || ! isset( $b['order'] ) ) { return 0; } if ( $a['order'] == $b['order'] ) { return 0; } return ( $a['order'] < $b['order'] ) ? -1 : 1; } // TODO: Delete after frontend refactor public function get_contacts_reorder() { $contacts = $this->get_contacts(); uasort( $contacts, array( $this, 'order_contact' ) ); return $contacts; } public function get_contacts() { return $this->get_all(); } public function get_all() { $models_button = Button::instance(); $button = $models_button->get(); $entities = $this->repository->findAll(); if ( ! $entities ) { return array(); } // TODO: Replace with a default contact from ORM // if ( ! $entities ) { // $defaults_contacts = array(); // $defaults_contacts[0] = $this->get_args(); // $defaults_contacts[0]['order'] = 1; // $defaults_contacts[0]['message'] = $button['message']; // $defaults_contacts[0]['phone'] = qlwapp_format_phone( $button['phone'] ); // $entity = $this->create( $defaults_contacts[0] ); // $defaults_contacts[0]['id'] = $entity['id']; // if ( ! is_admin() ) { // $defaults_contacts[0]['message'] = qlwapp_replacements_vars( $defaults_contacts[0]['message'] ); // } // return $defaults_contacts; // } // error_log( 'entities: ' . json_encode( $entities, JSON_PRETTY_PRINT ) ); $contacts = array(); foreach ( $entities as $entity ) { $contact = $entity->getProperties(); if ( ! $contact['phone'] ) { $contact['phone'] = qlwapp_format_phone( $button['phone'] ); } if ( ! is_admin() ) { $contact['message'] = qlwapp_replacements_vars( $contact['message'] ); } // Add the contact to the array without specifying a key. $contacts[] = $contact; } return $contacts; } public function delete_all() { return $this->repository->deleteAll(); } public function sanitize_value_data( $value_data ) { $args = $this->get_args(); foreach ( $value_data as $key => $value ) { if ( array_key_exists( $key, $args ) ) { $type = $args[ $key ]; if ( is_null( $type ) && ! is_numeric( $value ) ) { $value_data[ $key ] = intval( $value ); } elseif ( is_bool( $type ) && ! is_bool( $value ) ) { $value_data[ $key ] = ( $value === 'true' || $value === '1' || $value === 1 ); } elseif ( is_string( $type ) && ! is_string( $value ) ) { $value_data[ $key ] = strval( $value ); } elseif ( is_array( $type ) && ! is_array( $value ) ) { $value_data[ $key ] = (array) $type; } } else { unset( $value_data[ $key ] ); } } return $value_data; } public static function instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } }
| ver. 1.4 |
Github
|
.
| PHP 5.4.45 | Generation time: 0 |
proxy
|
phpinfo
|
Settings