Advertisement
rdusnr

Untitled

Jun 16th, 2017
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.32 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: SQ KLEO Monetizer
  4. Plugin URL: http://seventhqueen.com/
  5. Description: A plugin that gives you possibility to add banners to predefined zones in KLEO THEME.
  6. Version: 1.0.0
  7. Author: SeventhQueen
  8. Author URI: http://seventhqueen.com/
  9. Text Domain: sq-kleo-monetizer
  10. Domain Path: /languages
  11. */
  12.  
  13. /**
  14. * Class Kleo_Monetizer
  15. * Adds banner zones to certain Kleo theme locations
  16. */
  17. class Kleo_Monetizer {
  18.  
  19. /**
  20. * @var Kleo_Monetizer The single instance of the class
  21. * @since 1.0.0
  22. */
  23. protected static $_instance = null;
  24.  
  25. public function __construct() {
  26. if ( is_admin() ) {
  27. add_action( 'after_setup_theme', array( $this, 'register_options' ), 20 );
  28. }
  29. add_action( 'template_redirect', array( $this, 'register_render_actions' ) );
  30. }
  31.  
  32. /**
  33. * Main Instance
  34. *
  35. * Ensures only one instance is loaded or can be loaded.
  36. *
  37. * @since 1.0.0
  38. * @static
  39. * @see Kleo_Monetizer()
  40. * @return Kleo_Monetizer - Main instance
  41. */
  42. public static function instance( $args = array() ) {
  43. if ( is_null( self::$_instance ) ) {
  44. self::$_instance = new self( $args );
  45. }
  46.  
  47. return self::$_instance;
  48. }
  49.  
  50. public function register_options() {
  51. if ( ! class_exists( 'Kleo' ) || ! class_exists( 'Redux' ) ) {
  52. return;
  53. }
  54. $section = array(
  55. 'icon' => 'el-icon-eur',
  56. 'icon_class' => 'icon-large',
  57. 'title' => esc_html__( 'Kleo Monetizer', 'sq-kleo-monetizer' ),
  58. 'customizer' => false,
  59. 'desc' => '<p class="description">' . esc_html__( 'Monetize Kleo Plugin', 'sq-kleo-monetizer' ) . '</p>',
  60. 'fields' => array(
  61. array(
  62. 'id' => 'km_before_single_content',
  63. 'type' => 'textarea',
  64. 'title' => esc_html__( 'Banner Zone - General Before Content', 'sq-kleo-monetizer' ),
  65. 'subtitle' => esc_html__( 'Add your adsense code with script tags [ Will not be rendered in front-page and in buddypress]', 'sq-kleo-monetizer' ),
  66. 'default' => '',
  67. ),
  68. array(
  69. 'id' => 'km_after_single_content',
  70. 'type' => 'textarea',
  71. 'title' => esc_html__( 'Banner Zone - General After Content ', 'sq-kleo-monetizer' ),
  72. 'subtitle' => esc_html__( 'Add your adsense code with script tags [ Will not be rendered in front-page and in buddypress ]', 'sq-kleo-monetizer' ),
  73. 'default' => '',
  74. ),
  75. array(
  76. 'id' => 'km_before_single_inner_content',
  77. 'type' => 'textarea',
  78. 'title' => esc_html__( 'Banner Zone - Before Article Inner Content', 'sq-kleo-monetizer' ),
  79. 'subtitle' => esc_html__( 'Add your adsense code with script tags [ Will be rendered in single post page ]', 'sq-kleo-monetizer' ),
  80. 'default' => '',
  81. ),
  82. array(
  83. 'id' => 'km_after_single_inner_main_content',
  84. 'type' => 'textarea',
  85. 'title' => esc_html__( 'Banner Zone - After Article Inner Content', 'sq-kleo-monetizer' ),
  86. 'subtitle' => esc_html__( 'Add your adsense code with script tags [ Will be rendered in single post page ]', 'sq-kleo-monetizer' ),
  87. 'default' => '',
  88. ),
  89. array(
  90. 'id' => 'km_before_single_archive_content',
  91. 'type' => 'textarea',
  92. 'title' => esc_html__( 'Banner Zone - Before Archive Content', 'sq-kleo-monetizer' ),
  93. 'subtitle' => esc_html__( 'Add your adsense code with script tags [ Will be rendered in archive pages ]', 'sq-kleo-monetizer' ),
  94. 'default' => '',
  95. ),
  96. array(
  97. 'id' => 'km_after_single_archive_content',
  98. 'type' => 'textarea',
  99. 'title' => esc_html__( 'Banner Zone - After Archive Content', 'sq-kleo-monetizer' ),
  100. 'subtitle' => esc_html__( 'Add your adsense code with script tags [ Will be rendered in archive pages ]', 'sq-kleo-monetizer' ),
  101. 'default' => '',
  102. ),
  103. array(
  104. 'id' => 'km_before_blog_outer_content',
  105. 'type' => 'textarea',
  106. 'title' => esc_html__( 'Banner zone - Before Blog Content', 'sq-kleo-monetizer' ),
  107. 'subtitle' => esc_html__( 'Add your adsense code with script tags [ Will be rendered in main blog page ]', 'sq-kleo-monetizer' ),
  108. 'default' => '',
  109. ),
  110. array(
  111. 'id' => 'km_after_blog_outer_content',
  112. 'type' => 'textarea',
  113. 'title' => esc_html__( 'Banner zone - After Blog Content', 'sq-kleo-monetizer' ),
  114. 'subtitle' => esc_html__( 'Add your adsense code with script tags [ Will be rendered in main blog page ]', 'sq-kleo-monetizer' ),
  115. 'default' => '',
  116. ),
  117. ),
  118. );
  119.  
  120. Redux::setSection( 'kleo_' . KLEO_DOMAIN, $section );
  121. }
  122.  
  123. public function register_render_actions() {
  124. if ( ! class_exists( 'Kleo' ) ) {
  125. return;
  126. }
  127.  
  128. if ( sq_option( 'km_before_single_content' ) ) {
  129. add_action( 'kleo_before_content', array( $this, 'render_before_single_content' ) );
  130. }
  131.  
  132. if ( sq_option( 'km_after_single_content' ) ) {
  133. add_action( 'kleo_after_main_content', array( $this, 'render_after_main_content' ) );
  134. }
  135.  
  136. if ( sq_option( 'km_before_single_inner_content' ) ) {
  137. add_action( 'kleo_before_inner_article_loop', array( $this, 'render_before_single_inner_content' ) );
  138. }
  139.  
  140. if ( sq_option( 'km_after_single_inner_main_content' ) ) {
  141. add_action( 'kleo_after_inner_article_loop', array( $this, 'render_after_single_inner_main_content' ) );
  142. }
  143.  
  144. if ( sq_option( 'km_before_single_archive_content' ) ) {
  145. add_action( 'kleo_before_archive_content', array( $this, 'render_before_single_archive_content' ) );
  146. }
  147.  
  148. if ( sq_option( 'km_after_single_archive_content' ) ) {
  149. add_action( 'kleo_after_archive_content', array( $this, 'render_after_single_archive_content' ) );
  150. }
  151.  
  152. if ( sq_option( 'km_before_blog_outer_content' ) ) {
  153. add_action( 'kleo_before_blog_outer_content', array( $this, 'render_before_blog_outer_content' ) );
  154. }
  155.  
  156. if ( sq_option( 'km_after_blog_outer_content' ) ) {
  157. add_action( 'kleo_after_blog_outer_content', array( $this, 'render_after_blog_outer_content' ) );
  158. }
  159. }
  160.  
  161.  
  162. public function render_before_single_content() {
  163. if (!is_front_page() && !is_archive() && !is_home() && is_singular('post')) {
  164. echo '<div style="margin: 10px auto;text-align:center;">' . do_shortcode(sq_option('km_before_single_content')) . '</div>';
  165. }
  166. }
  167. public function render_after_main_content() {
  168. if (!is_front_page() && !is_archive() && !is_home() && is_singular('post')) {
  169. $output = '';
  170. $output .= '<div style="margin: 10px auto;text-align:center;">' . sq_option('km_after_single_content') . '</div>';
  171. echo do_shortcode($output);
  172. }
  173. }
  174. public function render_before_single_inner_content() {
  175. if (is_single() && !is_front_page() && is_singular('post')) {
  176. $output = '';
  177. $output .= '<div style="margin: 10px auto;text-align:center;">' . sq_option('km_before_single_inner_content') . '</div>';
  178. echo do_shortcode($output);
  179. }
  180. }
  181. public function render_after_single_inner_main_content() {
  182. if ( is_single() && ! is_front_page() && is_singular( 'post' ) ) {
  183. $output = '';
  184. $output .= '<div style="margin: 10px auto;text-align:center;">' . sq_option( 'km_after_single_inner_main_content' ) . '</div>';
  185. echo do_shortcode($output);
  186. }
  187. }
  188. public function render_before_single_archive_content() {
  189. if ( is_archive() ) {
  190. $output = '';
  191. $output .= '<div style="margin: 10px auto;text-align:center;">' . sq_option( 'km_before_single_archive_content' ) . '</div>';
  192. echo do_shortcode($output);
  193. }
  194. }
  195. public function render_after_single_archive_content() {
  196. if ( is_archive() ) {
  197. $output = '';
  198. $output .= '<div style="margin: 10px auto;text-align:center;">' . sq_option( 'km_after_single_archive_content' ) . '</div>';
  199. echo do_shortcode($output);
  200. }
  201. }
  202. public function render_before_blog_outer_content() {
  203. if ( is_home() ) {
  204. $output = '';
  205. $output .= '<div style="margin: 10px auto;text-align:center;">' . sq_option( 'km_before_blog_outer_content' ) . '</div>';
  206. echo do_shortcode($output);
  207. }
  208. }
  209. public function render_after_blog_outer_content() {
  210. if ( is_home() ) {
  211. $output = '';
  212. $output .= '<div style="margin: 10px auto;text-align:center;">' . sq_option( 'km_after_blog_outer_content' ) . '</div>';
  213. echo do_shortcode($output);
  214. }
  215. }
  216. }
  217.  
  218. /* Initialize our class */
  219. Kleo_Monetizer::instance();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement