????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 18.217.200.151 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 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 : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/www.astacus.se/wp-content/plugins/cornerstone/includes/classes/footers/ |
Upload File : |
<?php class Cornerstone_Footer { protected $id = null; protected $title; protected $content = array(); protected $new; protected $dirty; public function __construct( $post ) { if ( is_array( $post ) ) { if ( isset( $post['id'] ) ) { $post = $post['id']; } else { $this->create_new( $post ); } } else { $this->load_from_post( $post ); } } protected function create_new( $data ) { $this->set_title( isset( $data['title'] ) ? $data['title'] : false ); // TODO: Populate from incoming data. $this->set_content( array( 'regions' => isset( $data['regions'] ) ? $data['regions'] : array(), 'settings' => isset( $data['settings'] ) ? $data['settings'] : array() ) ); } protected function load_from_post( $post ) { if ( is_int( $post ) ) { $post = get_post( $post ); } if ( ! is_a( $post, 'WP_POST' ) ) { throw new Exception( 'Unable to load footer from post.' ); } if ( 'cs_footer' !== $post->post_type ) { throw new Exception( 'Attempted to load footer from incorrect post_type.' ); } $this->id = $post->ID; $this->set_title( $post->post_title ? $post->post_title : '' ); $this->set_content( cs_maybe_json_decode( $post->post_content ) ); } protected function set_content( $content ) { $content = wp_parse_args( is_array( $content ) ? $content : array(), array( 'regions' => array(), 'settings' => array(), ) ); $this->set_regions( $content['regions'] ); $this->set_settings( $content['settings'] ); } public function save() { $args = array( 'post_title' => $this->get_title(), 'post_type' => 'cs_footer', 'post_status' => 'tco-data', 'post_content' => wp_slash( json_encode( array( 'regions' => $this->get_regions(), 'settings' => $this->get_settings() ) ) ) ); if ( is_int( $this->id ) ) { $args['ID'] = $this->id; } $id = wp_insert_post( $args ); if ( 0 === $id || is_wp_error( $id ) ) { throw new Exception( "Unable to update footer: $id" ); } $this->load_from_post( (int) $id ); return $this->serialize(); } public function get_id() { return $this->id; } public function get_title() { return $this->title; } public function get_regions() { if ( ! isset( $this->content['regions'] ) ) { $this->content['regions'] = array(); } return $this->content['regions']; } public function get_settings() { if ( ! isset( $this->content['settings'] ) ) { $this->content['settings'] = array(); } return $this->content['settings']; } public function get_assignments() { $assignments = isset( $this->content['settings']['assignments'] ) ? $this->content['settings']['assignments'] : array(); return array_map( array( $this, 'decorate_assignments' ), $assignments ); } public function decorate_assignments( $assignment ) { $parts = explode( ':', $assignment ); $key = $parts[0]; $id = ( isset( $parts[1] ) ) ? $id : null; $label = ''; return array( 'type' => $key, 'label' => $label ); } public function serialize() { return array( 'id' => $this->id, 'title' => $this->get_title(), 'regions' => $this->get_regions(), 'settings' => $this->get_settings(), 'assignments' => $this->get_assignments(), ); } public function set_title( $title ) { return $this->title = sanitize_text_field( $title, sprintf( csi18n('common.untitled-entity'), csi18n('common.entity-footer') ) ); } public function set_settings( $settings ) { $this->content['settings'] = $settings; } public function set_regions( $regions ) { $this->content['regions'] = $regions; } public function delete() { do_action('cornerstone_delete_footer', $this->id ); return wp_delete_post( $this->id, true ); } }