ClassConfig = new Afd_Config(); $this->ClassData = new Afd_Data(); $this->ClassManager = new Afd_Manager(); $this->ClassInfo = new Afd_Plugin_Info(); add_action( 'plugins_loaded' , array( $this , 'init' ) , 100 ); } function init() { load_plugin_textdomain( $this->Plugin['ltd'] , false , $this->Plugin['plugin_slug'] . '/languages' ); add_action( 'load-index.php' , array( $this , 'FilterStart' ) ); } // SetList function fields_setting( $mode = 'add' , $field = false , $val = '' , $key = false ) { global $wp_locale; if( !empty( $mode ) && !empty( $field ) ) { $f_name = sprintf( 'data[%s]' , $mode ); if( $mode == 'update' ) $f_name = sprintf( 'data[%1$s][%2$s]' , $mode , $key ); $f_id = sprintf( '%s_' , $mode ); if( $mode == 'update' ) $f_id = sprintf( '%1$s_%2$s_' , $mode , $key ); if( $field == 'title' ) { $f_name .= '[title]'; $f_id .= 'title'; printf( '' , $f_id , $f_name , $val ); } elseif( $field == 'content' ) { $f_name .= '[content]'; $f_id .= 'content'; echo wp_editor( $val , $f_id , array( 'textarea_name' => $f_name , 'media_buttons' => false ) ); } elseif( $field == 'type' ) { $f_name .= '[type]'; $f_id .= 'type'; printf( ''; } elseif( $field == 'userrole' ) { $all_user_roles = $this->ClassConfig->get_all_user_roles(); $f_name .= '[role][]'; $f_id .= 'role'; printf( ''; printf( '

%s

' , __( 'Hold the CTRL key and click the items in a list to choose them.' , $this->Plugin['ltd'] ) ); } elseif( $field == 'date' ) { printf( '

%s

' , __( 'Please End date is later than the Start date.' , $this->Plugin['ltd'] ) ); $date_periods = $this->ClassConfig->get_date_periods(); foreach( $date_periods as $name => $label ) { echo '
'; echo '

'; printf( '%s ' , $label ); $range = 0; if( is_array( $val ) && !empty( $val['range'][$name] ) ) { $range = intval( $val['range'][$name] ); } $range_check_name = $f_name . '[range][' . $name . ']'; $range_check_id = $f_id . 'range_' . $name; printf( '' , $range_check_name , $range_check_id , checked( $range , 1 , false , false ) , __( 'Specify' , $this->Plugin['ltd'] ) ); echo '

'; printf( '
' , $name ); if( is_array( $val ) && !empty( $val['range'][$name] ) && $val['date'][$name] ) { $date[$name] = $val['date'][$name]; } else { $date[$name] = current_time( 'mysql' ); } $date_mm_name = $f_name . '[' . $name . '][date][mm]'; $f_month = sprintf( ''; $date_aa_name = $f_name . '[' . $name . '][date][aa]'; $f_year = sprintf( '' , $date_aa_name , mysql2date( 'Y', $date[$name], false ) ); $date_jj_name = $f_name . '[' . $name . '][date][jj]'; $f_day = sprintf( '' , $date_jj_name , mysql2date( 'd', $date[$name], false ) ); $date_hh_name = $f_name . '[' . $name . '][date][hh]'; $f_hour = sprintf( '' , $date_hh_name , mysql2date( 'H', $date[$name], false ) ); $date_mn_name = $f_name . '[' . $name . '][date][mn]'; $f_minute = sprintf( '' , $date_mn_name , mysql2date( 'i', $date[$name], false ) ); echo '

'; printf( __( '%1$s %2$s, %3$s @ %4$s : %5$s' ), $f_month, $f_day, $f_year, $f_hour, $f_minute ); echo '

'; printf( '

%1$s: %2$s

' , __( 'Now' , $this->Plugin['ltd'] ) , mysql2date( get_option( 'date_format' ) . get_option( 'time_format' ) , current_time( 'timestamp' ) ) ); echo '
'; echo '
'; } } elseif( $field == 'standard' ) { $standard_name = $f_name . '[standard]'; $standard_id = $f_id . 'standard'; echo '
'; printf( ''; printf( '

%s

' , __( 'Choose the site if you want to hide announce.' , $this->Plugin['ltd'] ) ); printf( '

%s

' , __( 'Choose the site if you want to show announce.' , $this->Plugin['ltd'] ) ); $susbiste_name = $f_name . '[subsites][]'; $susbiste_id = $f_id . 'subsites'; printf( ''; printf( '

%s

' , __( 'Hold the CTRL key and click the items in a list to choose them.' , $this->Plugin['ltd'] ) ); echo '
'; } } } // SetList function specify_date_check( $range_type , $data ) { $available = false; if( $range_type == 'start' && $data['date']['start'] ) { if( current_time( 'timestamp' ) > strtotime( $data['date']['start'] ) ) { $available = true; } } if( $range_type == 'end' && $data['date']['end'] ) { if( current_time( 'timestamp' ) < strtotime( $data['date']['end'] ) ) { $available = true; } } return $available; } // FilterStart function FilterStart() { if( !$this->Current['network_admin'] && $this->Current['admin'] && !$this->Current['ajax'] ) { $Data = $this->ClassData->get_user_data( $this->Current['user_role'] ); if( !empty( $Data ) ) { add_action( 'admin_print_scripts' , array( $this , 'admin_print_scripts' ) ); add_filter( 'admin_notices' , array( $this , 'admin_notices' ) , 99 ); add_action( 'wp_dashboard_setup' , array( $this , 'wp_dashboard_setup' ) ); // filter add add_filter( 'afd_apply_content', 'wptexturize' ); add_filter( 'afd_apply_content', 'convert_smilies' ); add_filter( 'afd_apply_content', 'convert_chars' ); add_filter( 'afd_apply_content', 'wpautop' ); add_filter( 'afd_apply_content', 'shortcode_unautop' ); add_filter( 'afd_apply_content', 'prepend_attachment' ); } } } // FilterStart function admin_print_scripts() { global $wp_version; wp_enqueue_style( $this->Plugin['ltd'] , $this->Plugin['dir_admin_assets'] . 'dashboard.css', array() , $this->Ver ); if( version_compare( $wp_version , '3.8' , '<' ) ) wp_enqueue_style( $this->Plugin['ltd'] . '-37' , $this->Plugin['dir_admin_assets'] . 'dashboard-3.7.css', array() , $this->Ver ); } // FilterStart function admin_notices() { $Data = $this->ClassData->get_user_data( $this->Current['user_role'] ); if( !empty( $Data ) ) { foreach( $Data as $key => $announce ) { $type = strip_tags( $announce['type'] ); if( !empty( $type ) && $type == 'updated' or $type == 'error' or $type == 'normal' or $type == 'nonstyle' ) { $class = 'announce updated ' . $type; echo sprintf( '

%2$s%3$s

' , $class , strip_tags( $announce['title'] ) , $this->afd_apply_content( $announce['content'] ) ); } } } } // FilterStart function wp_dashboard_setup() { $Data = $this->ClassData->get_user_data( $this->Current['user_role'] ); if( !empty( $Data ) ) { foreach( $Data as $key => $announce ) { $type = strip_tags( $announce['type'] ); if( !empty( $type ) && $type == 'metabox' ) { add_meta_box( $this->Plugin['page_slug'] . '-' . $key , strip_tags( $announce['title'] ) , array( $this , 'dashboard_do_metabox' ) , 'dashboard' , 'normal' , 'high' , array( 'announce' => $key ) ); } } } } // FilterStart function dashboard_do_metabox( $post , $metabox ) { if( isset( $metabox['args']['announce'] ) ) { $Data = $this->ClassData->get_user_data( $this->Current['user_role'] ); if( !empty( $Data[$metabox['args']['announce']] ) ) { echo $this->afd_apply_content( $Data[$metabox['args']['announce']]['content'] ); } } } // FilterStart function afd_apply_content( $Content ) { $Content = apply_filters( 'afd_apply_content' , stripslashes( $Content ) ); return $Content; } } $GLOBALS['Afd'] = new Afd(); endif; ?>