Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting('E_ALL');
- /**
- * Created by PhpStorm.
- * User: User
- * Date: 12/4/13
- * Time: 5:08 PM
- */
- // Creating the widget
- class wplinkedinFullProfileResumeWidget extends WP_Widget {
- public function __construct() {
- add_action( 'widgets_init', array($this,'wplnFullResume_load_widget' ));
- parent::__construct(
- // Base ID of your widget
- 'wplinkedinFullProfileResumeWidget',
- // Widget name will appear in UI
- __('Linkedin Full Profile Info Display', 'wplnFullResume_widget_domain'),
- // Widget description
- array( 'description' => __( 'Linkedin Full Profile Info Display in Widget', 'wplnFullResume_widget_domain' ), )
- );
- }
- // Register and load the widget
- public function wplnFullResume_load_widget() {
- register_widget( 'wplinkedinFullProfileResumeWidget' );
- }
- // Creating widget front-end
- //This is where the action happens
- public function widget( $args, $instance ) {
- $title = apply_filters( 'widget_title', $instance['title'] );
- $infotype = $instance['checktype'];
- var_dump($infotype);
- // before and after widget arguments are defined by themes
- echo $args['before_widget'];
- if ( ! empty( $title ) )
- echo $args['before_title'] . $title . $args['after_title'];
- // This is where you run the code and display the output
- $className = 'linkedinUserDataRendersimple';
- $render_str = 'render_'.$infotype;
- require_once(plugin_dir_path(__DIR__).'/templates/simple.php');
- $wplinkedinUserDataRender = new $className();
- $html = '<div class="cblinkedinwrapper simple">';
- if (method_exists($wplinkedinUserDataRender, $render_str)){
- $rendered_data = call_user_func(array($wplinkedinUserDataRender, $render_str));
- $html .= $rendered_data;
- $html .= '<div class="clear"></div>';
- }
- $html .= '</div>';
- echo $rendered_data;
- echo $args['after_widget'];
- }
- // Widget Backend
- function form($instance) {
- $wplinkedinSortableItem = (array)get_option('wplinkedinresume');
- //var_dump($wplinkedinSortableItem['linkedinSortableItem']);
- $sortable_item = array(
- 'about' => 'About Me',
- 'summary' => 'Summary',
- 'experience' => 'Experience',
- 'education' => 'Education',
- 'skills' => 'Skills',
- 'publications' => 'Publications',
- 'volunteer' => 'Volunteer & Causes',
- 'recommendations' => 'Recommendations',
- 'language' => 'Languages',
- 'certifications' => 'Certifications',
- 'linkedinStatus' => 'Publish Recent Status'
- );
- $defaults = array( 'title' => 'Linkedin Profile', 'checktype' => array() );
- $instance = wp_parse_args( (array) $instance, $defaults );
- $title = $instance['title'];
- $checktype = $instance['checktype'];
- var_dump($checktype);
- $output = '<p>Title: <input class="widefat" name="'.$this->get_field_name( 'title' ).'" type="text" value="'.esc_attr( $title ).'"/>';
- $output .= '<p class="paragraph_div">';
- foreach($wplinkedinSortableItem['linkedinSortableItem'] as $sortKey => $sortVal){
- $output .= '<label for="'. $this->get_field_id('checktype').$sortKey .'"> '. $sortable_item[$sortKey] .' </label>';
- $output .= '<input class="checktype_checkbox" type="checkbox" id="'.$this->get_field_id('checktype').$sortKey .'" name="checktype['.$sortKey.']" value="1"';
- $output .= checked(1, $checktype[$sortKey]);var_dump($checktype[$sortKey]);
- //$output .= ($checktype[$sortKey] == 1) ? 'checked="checked"' : '';
- $output .= ' /><br>';
- }
- $output .= '</ul>';
- $output .= '</p>';
- echo $output;
- echo '<style type="text/css">.checktype_checkbox{float:right;} .paragraph_div{width:150px;}</style>';
- }
- // Updating widget replacing old instances with new
- public function update($new_instance, $old_instance) {
- //var_dump($new_instance);
- $instance = $old_instance;
- $instance['title'] = strip_tags( $new_instance['title'] );
- $instance['checktype'] = $new_instance['checktype'] ;
- // for($i=0; $i<sizeof($instance['checktype']); $i++) {
- // $instance['checktype'][$i]['selected'] = (int)$new_instance['checktype'][$i]['selected'];
- // }
- return $instance;
- }
- } // Class wpb_widget ends here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement