PluginProbe
Powerkit – Supercharge your WordPress Site / 2.4.4
Powerkit – Supercharge your WordPress Site v2.4.4
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 / facebook / admin / class-powerkit-facebook-admin.php

class-powerkit-facebook-admin.php in Powerkit – Supercharge your WordPress Site 2.4.4, at modules/facebook/admin/class-powerkit-facebook-admin.php

102 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The admin-specific functionality of the module.
4 *
5 * @link https://codesupply.co
6 * @since 1.0.0
7 *
8 * @package Powerkit
9 * @subpackage Modules/Admin
10 */
11
12 /**
13 * The admin-specific functionality of the module.
14 */
15 class Powerkit_Facebook_Admin extends Powerkit_Module_Admin {
16
17 /**
18 * Initialize
19 */
20 public function initialize() {
21 add_action( 'admin_init', array( $this, 'register_settings_section' ) );
22 }
23
24
25 /**
26 * Register admin page
27 *
28 * @since 1.0.0
29 */
30 public function register_settings_section() {
31
32 add_settings_section( 'powerkit_facebook_settings', sprintf( '<span id="%s">%s</span>', powerkit_get_page_slug( $this->slug ), esc_html__( 'Facebook Comments', 'powerkit' ) ), array( $this, 'powerkit_facebook_settings_callback' ), 'discussion' );
33
34 add_settings_field( 'powerkit_facebook_enable_comments', esc_html__( 'Enable Facebook Comments', 'powerkit' ), array( $this, 'powerkit_facebook_enable_comments_callback' ), 'discussion', 'powerkit_facebook_settings' );
35 add_settings_field( 'powerkit_facebook_number_comments', esc_html__( 'Number of Comments', 'powerkit' ), array( $this, 'powerkit_facebook_number_comments_callback' ), 'discussion', 'powerkit_facebook_settings' );
36
37 register_setting( 'discussion', 'powerkit_facebook_enable_comments' );
38 register_setting( 'discussion', 'powerkit_facebook_number_comments_callback' );
39
40 $locations = apply_filters( 'powerkit_facebook_comments_location', array() );
41
42 // If locations > 1.
43 if ( count( (array) $locations ) > 1 ) {
44 add_settings_field( 'powerkit_facebook_location', esc_html__( 'Location', 'powerkit' ), array( $this, 'powerkit_facebook_location_callback' ), 'discussion', 'powerkit_facebook_settings' );
45 register_setting( 'discussion', 'powerkit_facebook_location' );
46 }
47 }
48
49 /**
50 * Section Description.
51 *
52 * @since 1.0.0
53 */
54 public function powerkit_facebook_settings_callback() {
55 return null;
56 }
57
58 /**
59 * Field | Enable Facebook Comments.
60 *
61 * @since 1.0.0
62 */
63 public function powerkit_facebook_enable_comments_callback() {
64 ?>
65 <input class="regular-text" id="powerkit_facebook_enable_comments" name="powerkit_facebook_enable_comments" type="checkbox" value="true" <?php checked( (bool) get_option( 'powerkit_facebook_enable_comments', false ) ); ?>>
66 <?php
67 }
68
69 /**
70 * Field | Number of Comments.
71 *
72 * @since 1.0.0
73 */
74 public function powerkit_facebook_number_comments_callback() {
75 ?>
76 <input class="small-text" id="powerkit_facebook_number_comments" name="powerkit_facebook_number_comments" type="number" value="<?php echo esc_attr( get_option( 'powerkit_facebook_number_comments', 10 ) ); ?>" /> <?php esc_html_e( 'items', 'powerkit' ); ?>
77 <?php
78 }
79
80 /**
81 * Field | Location.
82 *
83 * @since 1.0.0
84 */
85 public function powerkit_facebook_location_callback() {
86 $locations = apply_filters( 'powerkit_facebook_comments_location', array() );
87 ?>
88 <select class="regular-text" name="powerkit_facebook_location" id="powerkit_facebook_location">
89 <?php
90 if ( $locations ) {
91 foreach ( $locations as $key => $item ) {
92 ?>
93 <option value="<?php echo esc_attr( $key ); ?>" <?php selected( get_option( 'powerkit_facebook_location' ), $key ); ?>><?php echo esc_attr( $item['name'] ); ?></option>
94 <?php
95 }
96 }
97 ?>
98 </select>
99 <?php
100 }
101 }
102