PluginProbe
Powerkit – Supercharge your WordPress Site / 2.3.3
Powerkit – Supercharge your WordPress Site v2.3.3
3.1.1 3.1.0 3.0.9 3.0.8 trunk 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 87 releases
powerkit / modules / widget-about / public / class-powerkit-widget-about-init.php

class-powerkit-widget-about-init.php in Powerkit – Supercharge your WordPress Site 2.3.3, at modules/widget-about/public/class-powerkit-widget-about-init.php

139 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Widget About
4 *
5 * @link https://codesupply.co
6 * @since 1.0.0
7 *
8 * @package Powerkit
9 * @subpackage Powerkit/widgets
10 */
11
12 /**
13 * Widget About
14 */
15 class Powerkit_Widget_About_Init extends WP_Widget {
16
17 /**
18 * Sets up a new widget instance.
19 */
20 public function __construct() {
21
22 $this->default_settings = apply_filters( 'powerkit_widget_about_settings', array(
23 'title' => esc_html__( 'About', 'powerkit' ),
24 'subtitle' => '',
25 'image' => false,
26 'text' => '',
27 'button_url' => '',
28 'button_text' => '',
29 'social_links' => true,
30 ) );
31
32 $widget_details = array(
33 'classname' => 'powerkit_widget_about',
34 'description' => '',
35 );
36
37 parent::__construct( 'powerkit_widget_about', esc_html__( 'About', 'powerkit' ), $widget_details );
38 }
39
40 /**
41 * Outputs the content for the current widget instance.
42 *
43 * @param array $args Display arguments including 'before_title', 'after_title',
44 * 'before_widget', and 'after_widget'.
45 * @param array $instance Settings for the current widget instance.
46 */
47 public function widget( $args, $instance ) {
48 $params = array_merge( $this->default_settings, $instance );
49
50 // Title.
51 if ( $params['title'] ) {
52 $params['widget_title'] = $args['before_title'] . apply_filters( 'widget_title', $params['title'], $instance, $this->id_base ) . $args['after_title'];
53 }
54
55 // Before Widget.
56 echo $args['before_widget']; // XSS.
57
58 ?>
59 <div class="widget-body pk-widget-about">
60 <?php
61 powerkit_about_get_html( $params );
62 ?>
63 </div>
64 <?php
65 // After Widget.
66 echo $args['after_widget']; // XSS.
67 }
68
69 /**
70 * Handles updating settings for the current widget instance.
71 *
72 * @param array $new_instance New settings for this instance as input by the user via
73 * WP_Widget::form().
74 * @param array $old_instance Old settings for this instance.
75 * @return array Settings to save or bool false to cancel saving.
76 */
77 public function update( $new_instance, $old_instance ) {
78 $instance = $new_instance;
79
80 // Display social links.
81 if ( ! isset( $instance['social_links'] ) ) {
82 $instance['social_links'] = false;
83 }
84
85 return $instance;
86 }
87
88 /**
89 * Outputs the widget settings form.
90 *
91 * @param array $instance Current settings.
92 */
93 public function form( $instance ) {
94 $params = array_merge( $this->default_settings, $instance );
95
96 $bg_image_url = $params['image'] ? wp_get_attachment_image_url( intval( $params['image'] ), 'large' ) : '';
97 ?>
98 <!-- Title -->
99 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'powerkit' ); ?></label>
100 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $params['title'] ); ?>" /></p>
101
102 <!-- Subtitle -->
103 <p><label for="<?php echo esc_attr( $this->get_field_id( 'subtitle' ) ); ?>"><?php esc_html_e( 'Subtitle', 'powerkit' ); ?></label>
104 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'subtitle' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'subtitle' ) ); ?>" type="text" value="<?php echo esc_attr( $params['subtitle'] ); ?>" /></p>
105
106 <!-- Image URL -->
107 <p><label for="<?php echo esc_attr( $this->get_field_id( 'image' ) ); ?>"><?php esc_html_e( 'Image URL', 'powerkit' ); ?></label>
108 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'image' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'image' ) ); ?>" type="text" value="<?php echo esc_attr( $params['image'] ); ?>" /></p>
109
110 <!-- Text -->
111 <p><label for="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>"><?php esc_html_e( 'Text', 'powerkit' ); ?></label>
112 <textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" rows="10"><?php echo esc_textarea( $params['text'] ); ?></textarea></p>
113
114 <!-- Button URL -->
115 <p><label for="<?php echo esc_attr( $this->get_field_id( 'button_url' ) ); ?>"><?php esc_html_e( 'Button URL', 'powerkit' ); ?></label>
116 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'button_url' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'button_url' ) ); ?>" type="text" value="<?php echo esc_attr( $params['button_url'] ); ?>" /></p>
117
118 <!-- Button Text -->
119 <p><label for="<?php echo esc_attr( $this->get_field_id( 'button_text' ) ); ?>"><?php esc_html_e( 'Button Text', 'powerkit' ); ?></label>
120 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'button_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'button_text' ) ); ?>" type="text" value="<?php echo esc_attr( $params['button_text'] ); ?>" /></p>
121
122 <!-- Display social accounts -->
123 <?php if ( powerkit_module_enabled( 'social_links' ) ) : ?>
124 <p><input id="<?php echo esc_attr( $this->get_field_id( 'social_links' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'social_links' ) ); ?>" type="checkbox" <?php checked( (bool) $params['social_links'] ); ?> />
125 <label for="<?php echo esc_attr( $this->get_field_id( 'social_links' ) ); ?>"><?php esc_html_e( 'Display social links', 'powerkit' ); ?></label></p>
126 <?php endif; ?>
127 <?php
128 }
129
130 }
131
132 /**
133 * Register Widget
134 */
135 function powerkit_widget_about_init() {
136 register_widget( 'Powerkit_Widget_About_Init' );
137 }
138 add_action( 'widgets_init', 'powerkit_widget_about_init' );
139