| 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_Pinterest_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 |
* Register admin page |
| 26 |
* |
| 27 |
* @since 1.0.0 |
| 28 |
*/ |
| 29 |
public function register_settings_section() { |
| 30 |
|
| 31 |
add_settings_section( 'powerkit_pinit_settings', sprintf( '<span id="%s">%s</span>', powerkit_get_page_slug( $this->slug ), esc_html__( 'Pin It Button', 'powerkit' ) ), array( $this, 'powerkit_pinit_settings_callback' ), 'media' ); |
| 32 |
|
| 33 |
add_settings_field( 'powerkit_pinit_image_selectors', esc_html__( 'Image selectors', 'powerkit' ), array( $this, 'powerkit_pinit_image_selectors_callback' ), 'media', 'powerkit_pinit_settings' ); |
| 34 |
add_settings_field( 'powerkit_pinit_exclude_selectors', esc_html__( 'Exclude selectors', 'powerkit' ), array( $this, 'powerkit_pinit_exclude_selectors_callback' ), 'media', 'powerkit_pinit_settings' ); |
| 35 |
add_settings_field( 'powerkit_pinit_only_hover', esc_html__( 'Display on mouse hover only', 'powerkit' ), array( $this, 'powerkit_pinit_only_hover_callback' ), 'media', 'powerkit_pinit_settings' ); |
| 36 |
|
| 37 |
register_setting( 'media', 'powerkit_pinit_image_selectors' ); |
| 38 |
register_setting( 'media', 'powerkit_pinit_exclude_selectors' ); |
| 39 |
register_setting( 'media', 'powerkit_pinit_only_hover' ); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Section Description. |
| 44 |
* |
| 45 |
* @since 1.0.0 |
| 46 |
*/ |
| 47 |
public function powerkit_pinit_settings_callback() { |
| 48 |
return null; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Field | Image selectors. |
| 53 |
* |
| 54 |
* @since 1.0.0 |
| 55 |
*/ |
| 56 |
public function powerkit_pinit_image_selectors_callback() { |
| 57 |
?> |
| 58 |
<textarea class="regular-text" id="powerkit_pinit_image_selectors" name="powerkit_pinit_image_selectors" rows="8"><?php echo esc_attr( get_option( 'powerkit_pinit_image_selectors', '.entry-content img' ) ); ?></textarea> |
| 59 |
<p class="description"><?php esc_html_e( 'Only images with these CSS classes will show the "Pin it" button. The new conditions add a new row.', 'powerkit' ); ?></p> |
| 60 |
<?php |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Field | Exclude selectors. |
| 65 |
* |
| 66 |
* @since 1.0.0 |
| 67 |
*/ |
| 68 |
public function powerkit_pinit_exclude_selectors_callback() { |
| 69 |
?> |
| 70 |
<textarea class="regular-text" id="powerkit_pinit_exclude_selectors" name="powerkit_pinit_exclude_selectors" rows="8"><?php echo esc_attr( get_option( 'powerkit_pinit_exclude_selectors', '' ) ); ?></textarea> |
| 71 |
<p class="description"><?php esc_html_e( 'Images with these CSS classes won\'t show the "Pin it" button. The new conditions add a new row.', 'powerkit' ); ?></p> |
| 72 |
<?php |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Field | Display on mouse hover only. |
| 77 |
* |
| 78 |
* @since 1.0.0 |
| 79 |
*/ |
| 80 |
public function powerkit_pinit_only_hover_callback() { |
| 81 |
?> |
| 82 |
<input class="regular-text" id="powerkit_pinit_only_hover" name="powerkit_pinit_only_hover" type="checkbox" value="true" <?php checked( (bool) get_option( 'powerkit_pinit_only_hover', true ) ); ?>> |
| 83 |
<?php |
| 84 |
} |
| 85 |
} |
| 86 |
|