SHARE
TWEET

Untitled

a guest Oct 21st, 2014 154 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. if ( ! defined( 'ABSPATH' ) ) exit;
  4.  
  5. class DPortfolio {
  6.  
  7.         private static $_instance = null;
  8.  
  9.         public $settings = null;
  10.         public $_version;
  11.         public $_token;
  12.         public $file;
  13.         public $dir;
  14.         public $assets_dir;
  15.         public $assets_url;
  16.  
  17.         public function __construct ( $file = '', $version = '1.0' ) {
  18.  
  19.                 $this->_version = $version;
  20.                 $this->_token = 'dportfolio';
  21.  
  22.                 $this->file = $file;
  23.                 $this->dir = dirname( $this->file );
  24.                 $this->assets_dir = trailingslashit( $this->dir ) . 'assets';
  25.                 $this->assets_url = esc_url( trailingslashit( plugins_url( '/assets/', $this->file ) ) );
  26.  
  27.                 register_activation_hook( $this->file, array( $this, 'install' ) );
  28.  
  29.                 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ));
  30.                 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ));
  31.  
  32.                 $this->load_plugin_textdomain();
  33.                 add_action( 'init', array( $this, 'load_localisation' ), 0 );
  34.  
  35.         }
  36.  
  37.         public function enqueue_styles () {
  38.                 wp_register_style( $this->_token . '-frontend', esc_url( $this->assets_url ) . 'css/frontend.css', array(), $this->_version );
  39.                 wp_enqueue_style( $this->_token . '-frontend' );
  40.         }
  41.  
  42.         public function enqueue_scripts () {
  43.  
  44.                 wp_register_script( $this->_token . '-imagesloaded', esc_url( $this->assets_url ) . 'js/imagesloaded.pkgd.min.js', array( 'jquery' ), $this->_version, true );
  45.                 wp_enqueue_script( $this->_token . '-imagesloaded' );
  46.  
  47.                 wp_enqueue_script('masonry');  
  48.  
  49.                 wp_register_script( $this->_token . '-multipleFilterMasonry', esc_url( $this->assets_url ) . 'js/multipleFilterMasonry.js', array( 'jquery' ), $this->_version, true );
  50.                 wp_enqueue_script( $this->_token . '-multipleFilterMasonry' );
  51.  
  52.                 wp_register_script( $this->_token . '-frontend', esc_url( $this->assets_url ) . 'js/frontend.js', array( 'jquery' ), $this->_version, true );
  53.                 wp_enqueue_script( $this->_token . '-frontend' );
  54.  
  55.         }
  56.  
  57.         public function load_localisation () {
  58.                 load_plugin_textdomain( 'dportfolio', false, dirname( plugin_basename( $this->file ) ) . '/languages/' );
  59.         }
  60.  
  61.         public function load_plugin_textdomain () {
  62.  
  63.             $domain = 'dportfolio';
  64.             $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
  65.  
  66.             load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' );
  67.             load_plugin_textdomain( $domain, false, dirname( plugin_basename( $this->file ) ) . '/languages/' );
  68.  
  69.         }
  70.  
  71.         public function dportfolio_get_category() {
  72.  
  73.         global $post;
  74.         echo "<pre>";
  75.         print_r($post);
  76.         echo "</pre>";
  77.         $terms = get_the_terms( $post->ID, 'dportfolio_categories' );
  78.         echo "<pre>";
  79.         print_r($terms);
  80.         echo "</pre>";
  81.         $content = '';
  82.  
  83.         foreach ($terms as $term) {
  84.  
  85.                 $content .= '<a href="'. $term->slug .'">'. $term->name .'</a>';
  86.  
  87.         }
  88.  
  89.         return $content;
  90.  
  91. }
  92.  
  93.         public static function instance ( $file = '', $version = '1.0.0' ) {
  94.  
  95.                 if ( is_null( self::$_instance ) ) {
  96.  
  97.                         self::$_instance = new self( $file, $version );
  98.  
  99.                 }
  100.  
  101.                 return self::$_instance;
  102.  
  103.         }
  104.  
  105.         public function __clone () {
  106.                 _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?' ), $this->_version );
  107.         }
  108.  
  109.         public function __wakeup () {
  110.                 _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?' ), $this->_version );
  111.         }
  112.  
  113.         public function install () {
  114.  
  115.                 $this->_log_version_number();
  116.  
  117.                 flush_rewrite_rules();
  118.  
  119.         }
  120.  
  121.         private function _log_version_number () {
  122.  
  123.                 update_option( $this->_token . '_version', $this->_version );
  124.  
  125.         }
  126.  
  127. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top