Advertisement
Guest User

Untitled

a guest
Sep 12th, 2015
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.56 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: PureTheme's Team Members
  4. Plugin URI: http://plugins.zinan.me/purethemes-team-members
  5. Description: Providing a convenient way to show your team members. Custom post types, drag and drop re-arrange system, shortcode activation, Easiest admin setting panel.
  6. Version: 1.1.1
  7. Author: Developer Zinan
  8. Author URI: http://www.zinan.me/
  9. License: GPLv2 or later
  10. */
  11.  
  12. /*
  13. This program is free software; you can redistribute it and/or
  14. modify it under the terms of the GNU General Public License
  15. as published by the Free Software Foundation; either version 2
  16. of the License, or (at your option) any later version.
  17.  
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program; if not, write to the Free Software
  25. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  26. */
  27.  
  28.  
  29. /* Adding Latest jQuery from Wordpress */
  30. function pure_members_latest_jquery() {
  31.     wp_enqueue_script('jquery');
  32. }
  33. add_action('init', 'pure_members_latest_jquery');
  34.  
  35. /* Main Setting Class */
  36. class PMSFTest {
  37.  
  38.     private $plugin_path;
  39.     private $plugin_url;
  40.     private $l10n;
  41.     private $PMSF;
  42.  
  43.     function __construct()
  44.     {  
  45.         $this->plugin_path = plugin_dir_path( __FILE__ );
  46.         $this->plugin_url = plugin_dir_url( __FILE__ );
  47.         $this->l10n = 'pure-themes-settings-framework';
  48.         add_action( 'admin_menu', array(&$this, 'admin_menu'), 99 );
  49.        
  50.         // Include and create a new Pure_Member_Settings_Framework
  51.         require_once( $this->plugin_path .'pure-themes-settings-framework.php' );
  52.        
  53.         /*Some Set-up*/
  54.  
  55.         define('PURE_MEMBERS_HOOK', WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/' );
  56.         wp_enqueue_style('pure_members-css-font-awesome', PURE_MEMBERS_HOOK.'css/font-awesome.min.css');
  57.         wp_enqueue_style('pure_members-css-main-css', PURE_MEMBERS_HOOK.'css/plugins-main.css');
  58.  
  59.         function pure_members_active_hook() {?>
  60.             <script type="text/javascript">
  61.  
  62.             function hex2rgba(hex, opacity)
  63.             {
  64.                 //extract the two hexadecimal digits for each color
  65.                 var patt = /^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/;
  66.                 var matches = patt.exec(hex);
  67.                
  68.                 //convert them to decimal
  69.                 var r = parseInt(matches[1], 16);
  70.                 var g = parseInt(matches[2], 16);
  71.                 var b = parseInt(matches[3], 16);
  72.                
  73.                 //create rgba string
  74.                 var rgba = "rgba(" + r + "," + g + "," + b + "," + opacity + ")";
  75.                
  76.                 //return rgba colour
  77.                 return rgba;
  78.             }
  79.             jQuery(document).ready(function() {
  80.              jQuery('.member_single,.pure_member_h').css("border-color", hex2rgba("<?php echo PMSF_get_setting( 'pure_plugin', 'general', 'border-color' ); ?>", 0.7));
  81.              jQuery('.member_single').find('.member_bottom').css("background-color", hex2rgba("<?php echo PMSF_get_setting( 'pure_plugin', 'general', 'color' ); ?>", 0.4));
  82.              jQuery('.member_single').hover(
  83.                  function () {
  84.                    jQuery(this).find('.member_bottom').css("background-color", hex2rgba("<?php echo PMSF_get_setting( 'pure_plugin', 'general', 'hover-color' ); ?>", 0.5));
  85.                  },
  86.                  function () {
  87.                    jQuery(this).find('.member_bottom').css("background-color", hex2rgba("<?php echo PMSF_get_setting( 'pure_plugin', 'general', 'color' ); ?>", 0.4));
  88.                  }
  89.              );
  90.  
  91.             });
  92.             </script>
  93.         <?php
  94.         }
  95.         add_action('wp_head', 'pure_members_active_hook');
  96.        
  97.        
  98.         function pure_members_custom_css() {?>
  99.             <style type="text/css">
  100.                 <?php echo PMSF_get_setting( 'pure_plugin', 'general', 'custom-css' ); ?>
  101.             </style>
  102.        
  103.         <?php
  104.         }
  105.         add_action('wp_head', 'pure_members_custom_css');
  106.        
  107.         $this->PMSF = new Pure_Member_Settings_Framework( $this->plugin_path .'settings/settings-general.php' );
  108.         // Add an optional settings validation filter (recommended)
  109.         add_filter( $this->PMSF->get_option_group() .'_settings_validate', array(&$this, 'validate_settings') );
  110.     }
  111.    
  112.     function admin_menu()
  113.     {
  114.         $page_hook = add_menu_page( __( 'Member Settings', $this->l10n ), __( 'Member Settings', $this->l10n ), 'update_core', 'Member Settings', array(&$this, 'settings_page') );
  115.         add_submenu_page( 'PMSF', __( 'Settings', $this->l10n ), __( 'Settings', $this->l10n ), 'update_core', 'PMSF', array(&$this, 'settings_page') );
  116.     }
  117.    
  118.     function settings_page()
  119.     {
  120.         // Your settings page
  121.         ?>
  122.         <div class="wrap">
  123.             <div id="icon-options-general" class="icon32"></div>
  124.             <h2>PureTheme's Team Member Settings</h2>
  125.             <?php
  126.             // Output your settings form
  127.             $this->PMSF->settings();
  128.             ?>
  129.         </div>
  130.         <?php
  131.        
  132.         // Get settings
  133.         //$settings = PMSF_get_settings( $this->plugin_path .'settings/settings-general.php' );
  134.         //echo '<pre>'.print_r($settings,true).'</pre>';
  135.        
  136.         // Get individual setting
  137.         //$setting = PMSF_get_setting( PMSF_get_option_group( $this->plugin_path .'settings/settings-general.php' ), 'general', 'text' );
  138.         //var_dump($setting);
  139.     }
  140.    
  141.     function validate_settings( $input )
  142.     {
  143.         // Do your settings validation here
  144.         // Same as $sanitize_callback from http://codex.wordpress.org/Function_Reference/register_setting
  145.         return $input;
  146.     }
  147.  
  148. }
  149.  
  150.  
  151. require_once( 'pure-themes-member-settings.php' );
  152. require_once( 'custom-post-types-order.php' );
  153.  
  154.  
  155.  
  156. /* PureMembers Loop */
  157. function pure_get_member(){
  158.     $sectiontitle = PMSF_get_setting( 'pure_plugin', 'general', 'title-text' );
  159.     $puremember = '<div class="pure_member_area">
  160.                     <div class="pure_container">
  161.                         <div class="pure_row">';
  162.     $efs_query = "post_type=pure-members&posts_per_page=4";
  163.     query_posts($efs_query);
  164.     if (have_posts()) : while (have_posts()) : the_post();
  165.         $img = get_the_post_thumbnail( $post->ID, 'pure-member-img' ); 
  166.         $membername = get_the_title();
  167.         $memberdes = get_post_meta( get_the_ID(), 'pure-member-designation', true);
  168.         $facebooklink = get_post_meta( get_the_ID(), 'pure-member-facebook-link', true);
  169.         $twitterlink = get_post_meta( get_the_ID(), 'pure-member-twitter-link', true);
  170.         $dribbblelink = get_post_meta( get_the_ID(), 'pure-member-dribbble-link', true);
  171.         $membercontent = get_the_content();
  172.         $puremember.='<div class="pure_col-lg-3 pure_col-md-3 pure_col-sm-6 pure_col-xs-12">
  173.                         <div class="member_single" id="grow">
  174.                             <div class="member_name">
  175.                                 <h2>'.$membername.'</h2>
  176.                             </div>
  177.                             <div class="member_photo">
  178.                                 '.$img.'
  179.                             </div>
  180.                             <div class="member_bottom">
  181.                                 <div class="member_des">
  182.                                     <h3>'.$memberdes.'</h3>
  183.                                 </div>
  184.                                 <div class="member_social">
  185.                                     <a class="facebook" href="'.$facebooklink.'" target="_blank"><i class="fa fa-facebook"></i></a>
  186.                                     <a class="twitter" href="'.$twitterlink.'" target="_blank"><i class="fa fa-twitter"></i></a>
  187.                                     <a class="dribbble" href="'.$dribbblelink.'" target="_blank"><i class="fa fa-dribbble"></i></a>
  188.                                 </div>
  189.                             </div>
  190.                         </div>
  191.                     </div>';       
  192.     endwhile; endif; wp_reset_query();
  193.     $puremember.= '</div></div></div>';
  194.     return $puremember;
  195. }
  196.  
  197. /**add the shortcode for the content- for use in editor**/
  198. function pure_insert_member($atts, $content=null){
  199.     $puremember= pure_get_member();
  200.     return $puremember;
  201. }
  202. add_shortcode('pure_all_members', 'pure_insert_member');
  203. add_filter('widget_text', 'do_shortcode');
  204.  
  205. /**add template tag- for use in themes**/
  206. function pure_member(){
  207.     print pure_get_member();
  208. }
  209.  
  210. new PMSFTest();
  211.  
  212. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement