Advertisement
chez_ua

jnews-instagram.php

Mar 22nd, 2018
1,576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.12 KB | None | 0 0
  1. <?php
  2. /*
  3.     Plugin Name: JNews - Instagram Feed
  4.     Plugin URI: http://jegtheme.com/
  5.     Description: Put your instagram feed on the header and footer of your website
  6.     Version: 1.0.0
  7.     Author: Jegtheme
  8.     Author URI: http://jegtheme.com
  9.     License: GPL2
  10. */
  11.  
  12.  
  13. defined( 'JNEWS_INSTAGRAM' )                or define( 'JNEWS_INSTAGRAM', 'jnews-instagram');
  14. defined( 'JNEWS_INSTAGRAM_URL' )            or define( 'JNEWS_INSTAGRAM_URL', plugins_url(JNEWS_INSTAGRAM));
  15. defined( 'JNEWS_INSTAGRAM_FILE' )           or define( 'JNEWS_INSTAGRAM_FILE',  __FILE__ );
  16. defined( 'JNEWS_INSTAGRAM_DIR' )            or define( 'JNEWS_INSTAGRAM_DIR', plugin_dir_path( __FILE__ ) );
  17.  
  18. /**
  19.  * Get jnews option
  20.  *
  21.  * @param $setting
  22.  * @param $default
  23.  * @return mixed
  24.  */
  25. if(!function_exists('jnews_get_option'))
  26. {
  27.     function jnews_get_option($setting, $default = null)
  28.     {
  29.         $options = get_option( 'jnews_option', array() );
  30.         $value = $default;
  31.         if ( isset( $options[ $setting ] ) ) {
  32.             $value = $options[ $setting ];
  33.         }
  34.         return $value;
  35.     }
  36. }
  37.  
  38. /**
  39.  * Instagram Feed Option
  40.  */
  41. add_action( 'jnews_register_customizer_option', 'jnews_instagram_customizer_option');
  42.  
  43. if(!function_exists('jnews_instagram_customizer_option'))
  44. {
  45.     function jnews_instagram_customizer_option()
  46.     {
  47.         require_once 'class.jnews-instagram-option.php';
  48.         JNews_Instagram_Option::getInstance();
  49.     }
  50. }
  51.  
  52. /**
  53.  * Render Instagram Feed - Header
  54.  */
  55. add_action( 'jnews_render_instagram_feed_header', 'jnews_instagram_feed_header' );
  56.  
  57. if ( ! function_exists('jnews_instagram_feed_header') )
  58. {
  59.     function jnews_instagram_feed_header()
  60.     {
  61.         require_once 'class.jnews-instagram.php';
  62.  
  63.         $option = jnews_get_option('instagram_feed_enable', 'hide');
  64.  
  65.         if ( $option === 'only_header' || $option === 'both' )
  66.         {
  67.             $param = array(
  68.                 'row' => jnews_get_option('footer_instagram_row', 1),
  69.                 'column' => jnews_get_option('footer_instagram_column', 8),
  70.                 'username' => jnews_get_option('footer_instagram_username', ''),
  71.                 'sort' => jnews_get_option('footer_instagram_sort_type', 'most_recent'),
  72.                 'hover' => jnews_get_option('footer_instagram_hover_style', 'zoom'),
  73.                 'newtab' => jnews_get_option('footer_instagram_newtab', null) ? 'target=\'_blank\'' : '',
  74.                 'follow' => jnews_get_option('footer_instagram_follow_button', null),
  75.             );
  76.  
  77.             $instagram = new JNews_Instagram( $param );
  78.             $instagram->generate_element();
  79.         }
  80.     }
  81. }
  82.  
  83. /**
  84.  * Render Instagram Feed - Footer
  85.  */
  86. add_action( 'jnews_render_instagram_feed_footer', 'jnews_instagram_feed_footer' );
  87.  
  88. if ( ! function_exists('jnews_instagram_feed_footer') )
  89. {
  90.     function jnews_instagram_feed_footer()
  91.     {
  92.         require_once 'class.jnews-instagram.php';
  93.  
  94.         $option = jnews_get_option('instagram_feed_enable', 'hide');
  95.  
  96.         if ( $option === 'only_footer' || $option === 'both' )
  97.         {
  98.             $param = array(
  99.                 'row' => jnews_get_option('footer_instagram_row', 1),
  100.                 'column' => jnews_get_option('footer_instagram_column', 8),
  101.                 'username' => jnews_get_option('footer_instagram_username', ''),
  102.                 'sort' => jnews_get_option('footer_instagram_sort_type', 'most_recent'),
  103.                 'hover' => jnews_get_option('footer_instagram_hover_style', 'zoom'),
  104.                 'newtab' => jnews_get_option('footer_instagram_newtab', null) ? 'target=\'_blank\'' : '',
  105.                 'follow' => jnews_get_option('footer_instagram_follow_button', null),
  106.             );
  107.  
  108.             $instagram = new JNews_Instagram( $param );
  109.             $instagram->generate_element();
  110.         }
  111.     }
  112. }
  113.  
  114. /**
  115.  * Load Text Domain
  116.  */
  117. function jnews_instagram_load_textdomain()
  118. {
  119.     load_plugin_textdomain( JNEWS_INSTAGRAM, false, basename(__DIR__) . '/languages/' );
  120. }
  121.  
  122. jnews_instagram_load_textdomain();
  123.  
  124. /** Module Element for Footer */
  125.  
  126. /**
  127.  * New Element
  128.  */
  129. add_filter('jnews_module_list', 'jnews_instagram_module_element');
  130.  
  131. if ( !function_exists('jnews_instagram_module_element') )
  132. {
  133.     function jnews_instagram_module_element($module)
  134.     {
  135.         array_push($module, array(
  136.             'name'      => 'JNews_Footer_Instagram',
  137.             'type'      => 'footer',
  138.             'widget'    => false
  139.         ));
  140.         return $module;
  141.     }
  142. }
  143.  
  144.  
  145. add_filter('jnews_get_option_class_from_shortcode', 'jnews_get_option_class_from_shortcode_instagram', null, 2);
  146.  
  147. if ( !function_exists('jnews_get_option_class_from_shortcode_instagram') )
  148. {
  149.     function jnews_get_option_class_from_shortcode_instagram($class, $module)
  150.     {
  151.         if($module === 'JNews_Footer_Instagram')
  152.         {
  153.             return 'JNews_Footer_Instagram_Option';
  154.         }
  155.  
  156.         return $class;
  157.     }
  158. }
  159.  
  160.  
  161. add_filter('jnews_get_view_class_from_shortcode', 'jnews_get_view_class_from_shortcode_instagram', null, 2);
  162.  
  163. if ( !function_exists('jnews_get_view_class_from_shortcode_instagram') )
  164. {
  165.     function jnews_get_view_class_from_shortcode_instagram($class, $module)
  166.     {
  167.         if($module === 'JNews_Footer_Instagram')
  168.         {
  169.             return 'JNews_Footer_Instagram_View';
  170.         }
  171.  
  172.         return $class;
  173.     }
  174. }
  175.  
  176. add_filter('jnews_get_shortcode_name_from_option', 'jnews_get_shortcode_name_from_option_instagram', null, 2);
  177.  
  178. function jnews_get_shortcode_name_from_option_instagram($module, $class)
  179. {
  180.     if($class === 'JNews_Footer_Instagram_Option')
  181.     {
  182.         return 'jnews_footer_instagram';
  183.     }
  184.  
  185.     return $module;
  186. }
  187.  
  188.  
  189. add_action( 'jnews_build_shortcode_jnews_footer_instagram_view', 'jnews_instagram_load_module_view');
  190.  
  191. if(!function_exists('jnews_instagram_load_module_view'))
  192. {
  193.     function jnews_instagram_load_module_view()
  194.     {
  195.         jnews_instagram_load_module_option();
  196.         require_once 'class.jnews-instagram.php';
  197.     }
  198. }
  199.  
  200.  
  201. add_action( 'jnews_load_all_module_option', 'jnews_instagram_load_module_option' );
  202.  
  203. if(!function_exists('jnews_instagram_load_module_option'))
  204. {
  205.     function jnews_instagram_load_module_option()
  206.     {
  207.         require_once 'class.jnews-instagram-option.php';
  208.     }
  209. }
  210.  
  211.  
  212. if ( ! function_exists('jnews_module_elementor_get_option_class_instagram') )
  213. {
  214.     add_filter( 'jnews_module_elementor_get_option_class', 'jnews_module_elementor_get_option_class_instagram' );
  215.  
  216.     function jnews_module_elementor_get_option_class_instagram( $option_class )
  217.     {
  218.         if ( $option_class === '\JNews\Module\Footer\Footer_Instagram_Option' )
  219.         {
  220.             require_once 'class.jnews-instagram-option.php';
  221.             return 'JNews_Footer_Instagram_Option';
  222.         }
  223.  
  224.         return $option_class;
  225.     }
  226. }
  227.  
  228.  
  229. if ( ! function_exists('jnews_module_elementor_get_view_class_instagram') )
  230. {
  231.     add_filter( 'jnews_module_elementor_get_view_class', 'jnews_module_elementor_get_view_class_instagram' );
  232.  
  233.     function jnews_module_elementor_get_view_class_instagram( $view_class )
  234.     {
  235.         if ( $view_class === '\JNews\Module\Footer\Footer_Instagram_View' )
  236.         {
  237.             require_once 'class.jnews-instagram.php';
  238.             return 'JNews_Footer_Instagram_View';
  239.         }
  240.  
  241.         return $view_class;
  242.     }
  243. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement