PluginProbe
Powerkit – Supercharge your WordPress Site / 2.9.0
Powerkit – Supercharge your WordPress Site v2.9.0
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.9.0, at modules/widget-about/public/class-powerkit-widget-about-init.php

146 lines 5.6 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 * The default settings.
19 *
20 * @var array $default_settings The default settings.
21 */
22 public $default_settings = array();
23
24 /**
25 * Sets up a new widget instance.
26 */
27 public function __construct() {
28
29 $this->default_settings = apply_filters( 'powerkit_widget_about_settings', array(
30 'title' => esc_html__( 'About', 'powerkit' ),
31 'subtitle' => '',
32 'image' => false,
33 'text' => '',
34 'button_url' => '',
35 'button_text' => '',
36 'social_links' => true,
37 ) );
38
39 $widget_details = array(
40 'classname' => 'powerkit_widget_about',
41 'description' => '',
42 );
43
44 parent::__construct( 'powerkit_widget_about', esc_html__( 'About', 'powerkit' ), $widget_details );
45 }
46
47 /**
48 * Outputs the content for the current widget instance.
49 *
50 * @param array $args Display arguments including 'before_title', 'after_title',
51 * 'before_widget', and 'after_widget'.
52 * @param array $instance Settings for the current widget instance.
53 */
54 public function widget( $args, $instance ) {
55 $params = array_merge( $this->default_settings, $instance );
56
57 // Title.
58 if ( $params['title'] ) {
59 $params['widget_title'] = $args['before_title'] . apply_filters( 'widget_title', wp_kses( $params['title'], 'pk-title' ), $instance, $this->id_base ) . $args['after_title'];
60 }
61
62 // Before Widget.
63 echo $args['before_widget']; // XSS.
64
65 ?>
66 <div class="widget-body pk-widget-about">
67 <?php
68 powerkit_about_get_html( $params );
69 ?>
70 </div>
71 <?php
72 // After Widget.
73 echo $args['after_widget']; // XSS.
74 }
75
76 /**
77 * Handles updating settings for the current widget instance.
78 *
79 * @param array $new_instance New settings for this instance as input by the user via
80 * WP_Widget::form().
81 * @param array $old_instance Old settings for this instance.
82 * @return array Settings to save or bool false to cancel saving.
83 */
84 public function update( $new_instance, $old_instance ) {
85 $instance = $new_instance;
86
87 // Display social links.
88 if ( ! isset( $instance['social_links'] ) ) {
89 $instance['social_links'] = false;
90 }
91
92 return $instance;
93 }
94
95 /**
96 * Outputs the widget settings form.
97 *
98 * @param array $instance Current settings.
99 */
100 public function form( $instance ) {
101 $params = array_merge( $this->default_settings, $instance );
102
103 $bg_image_url = $params['image'] ? wp_get_attachment_image_url( intval( $params['image'] ), 'large' ) : '';
104 ?>
105 <!-- Title -->
106 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'powerkit' ); ?></label>
107 <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>
108
109 <!-- Subtitle -->
110 <p><label for="<?php echo esc_attr( $this->get_field_id( 'subtitle' ) ); ?>"><?php esc_html_e( 'Subtitle', 'powerkit' ); ?></label>
111 <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>
112
113 <!-- Image URL -->
114 <p><label for="<?php echo esc_attr( $this->get_field_id( 'image' ) ); ?>"><?php esc_html_e( 'Image URL', 'powerkit' ); ?></label>
115 <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>
116
117 <!-- Text -->
118 <p><label for="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>"><?php esc_html_e( 'Text', 'powerkit' ); ?></label>
119 <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>
120
121 <!-- Button URL -->
122 <p><label for="<?php echo esc_attr( $this->get_field_id( 'button_url' ) ); ?>"><?php esc_html_e( 'Button URL', 'powerkit' ); ?></label>
123 <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>
124
125 <!-- Button Text -->
126 <p><label for="<?php echo esc_attr( $this->get_field_id( 'button_text' ) ); ?>"><?php esc_html_e( 'Button Text', 'powerkit' ); ?></label>
127 <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>
128
129 <!-- Display social accounts -->
130 <?php if ( powerkit_module_enabled( 'social_links' ) ) : ?>
131 <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'] ); ?> />
132 <label for="<?php echo esc_attr( $this->get_field_id( 'social_links' ) ); ?>"><?php esc_html_e( 'Display social links', 'powerkit' ); ?></label></p>
133 <?php endif; ?>
134 <?php
135 }
136
137 }
138
139 /**
140 * Register Widget
141 */
142 function powerkit_widget_about_init() {
143 register_widget( 'Powerkit_Widget_About_Init' );
144 }
145 add_action( 'widgets_init', 'powerkit_widget_about_init' );
146