فهرست منبع

URL Yar V1.1.0

Sasan Salamzadeh 2 سال پیش
کامیت
55f3104848

BIN
assets/css/cross.png


+ 168 - 0
assets/css/options_page.css

@@ -0,0 +1,168 @@
+/*Misc*/
+#shorturl_options {
+    padding: 0 2em;
+}
+
+#shorturl_options .fs-opt {
+    margin: 1em 0 4em 0;
+}
+
+.urlyarplugin-logo {
+    float: right;
+    margin: 1em;
+    border: 1px #ccc solid;
+    padding: 0.5em;
+    background: #fff;
+    display: block;
+}
+
+.clear {
+    clear: both;
+}
+
+.divider {
+    border-top: 2px #bbb solid;
+    padding-top: 2em;
+}
+
+.checkit, .detail .ssl label {
+    background: url(tick.png) center left no-repeat;
+    padding-left: 20px;
+}
+
+/*Selection Table*/
+.fixed #col1 {
+    width: 10%;
+}
+
+.fixed #col2 {
+    width: 25%;
+}
+
+.sname label {
+    margin-left: 0.5em;
+}
+
+.show_detail {
+    background: #FFFFDF;
+}
+
+.detail {
+    background: #E8FFCF !important;
+}
+
+.ssl label {
+    padding-left: 20px;
+}
+
+th, td, table, tr, input {
+    vertical-align: middle !important;
+}
+
+th, td, tr, input {
+    margin: 5px !important;
+}
+
+.APIConfig label {
+    font-weight: bold;
+    padding-left: 5em;
+}
+
+.APIConfig input {
+    border: 1px #999 solid !important;
+}
+
+.APIConfig label span, span.red {
+    color: #c00;
+}
+
+.APIConfig .nc, .col3c {
+    padding-left: 5em;
+}
+
+.APIConfig .slabel,
+.APIConfig .contentblock {
+    padding-left: 5em;
+}
+
+.APIConfig .contentblock {
+    margin-top: 5px;
+}
+
+.APIConfig .contentblock label {
+    padding-left: 0;
+}
+
+.val_interdose {
+    margin: 0 1em;
+}
+
+/*Submission*/
+.reqfielderror {
+    border: 1px #FFAFAF solid;
+    background: #FFEFEF;
+    padding: 1em;
+    margin: 1em;
+    display: none;
+    width: 50%;
+}
+
+/*Tab Selector*/
+.j-show {
+    display: none;
+}
+
+#tab-select {
+    margin: 2em 0;
+    border: 1px #ddd solid;
+    padding: 1em;
+    background: #eee;
+}
+
+#tab-select ul {
+    display: inline;
+    margin-left: 1em;
+}
+
+#tab-select li {
+    display: inline;
+    margin-right: 0.5em;
+    border-right: 1px #aaa solid;
+    padding-right: 1em;
+}
+
+#tab-select a {
+    font-size: 1.2em;
+    padding: 0.5em;
+    text-decoration: none;
+}
+
+.tab-now {
+    background: #ccc;
+    color: #000;
+    font-weight: bold;
+}
+
+#tab-select, #tab-select a {
+    -moz-border-radius: 10px;
+    -border-radius: 10px;
+    -webkit-border-radius: 10px;
+}
+
+/*component list table*/
+#component_list .name {
+    margin: 0.5em 0;
+}
+
+#component_list .name strong {
+    font-size: 1.2em;
+}
+
+#component_list .name span {
+    display: block;
+    padding-left: 20px;
+}
+
+.fixed .colsmall {
+    width: 15%;
+}

BIN
assets/css/tick.png


+ 60 - 0
assets/js/jquery.ajaxq.js

@@ -0,0 +1,60 @@
+/*
+ * jQuery AjaxQ - AJAX request queueing for jQuery
+ *
+ * Version: 0.0.1
+ * Date: July 22, 2008
+ *
+ * Copyright (c) 2008 Oleg Podolsky (oleg.podolsky@gmail.com)
+ * Licensed under the MIT (MIT-LICENSE.txt) license.
+ *
+ * http://plugins.jquery.com/project/ajaxq
+ * http://code.google.com/p/jquery-ajaxq/
+ */
+
+jQuery.ajaxq = function (queue, options) {
+    // Initialize storage for request queues if it's not initialized yet
+    if (typeof document.ajaxq == "undefined") document.ajaxq = {q: {}, r: null};
+
+    // Initialize current queue if it's not initialized yet
+    if (typeof document.ajaxq.q[queue] == "undefined") document.ajaxq.q[queue] = [];
+
+    if (typeof options != "undefined") // Request settings are given, enqueue the new request
+    {
+        // Copy the original options, because options.complete is going to be overridden
+
+        var optionsCopy = {};
+        for (var o in options) optionsCopy[o] = options[o];
+        options = optionsCopy;
+
+        // Override the original callback
+
+        var originalCompleteCallback = options.complete;
+
+        options.complete = function (request, status) {
+            // Dequeue the current request
+            document.ajaxq.q[queue].shift();
+            document.ajaxq.r = null;
+
+            // Run the original callback
+            if (originalCompleteCallback) originalCompleteCallback(request, status);
+
+            // Run the next request from the queue
+            if (document.ajaxq.q[queue].length > 0) document.ajaxq.r = jQuery.ajax(document.ajaxq.q[queue][0]);
+        };
+
+        // Enqueue the request
+        document.ajaxq.q[queue].push(options);
+
+        // Also, if no request is currently running, start it
+        if (document.ajaxq.q[queue].length == 1) document.ajaxq.r = jQuery.ajax(options);
+    }
+    else // No request settings are given, stop current request and clear the queue
+    {
+        if (document.ajaxq.r) {
+            document.ajaxq.r.abort();
+            document.ajaxq.r = null;
+        }
+
+        document.ajaxq.q[queue] = [];
+    }
+}

+ 53 - 0
assets/js/tablecol.js

@@ -0,0 +1,53 @@
+jQuery(document).ready(function ($) {
+    $('select[name=action]').append('<option value="delshort">Remove Shortlink</option>');
+    $('select[name=action2]').append('<option value="delshort">Remove Shortlink</option>');
+
+
+    function do_ajaxshort(pid) {
+        var post = {};
+        post['action'] = 'urlshortener_act';
+        post['pid'] = pid;
+        post['_ajax_nonce'] = nonce;
+        $.ajaxq('urlyarshortenurl', {
+            type: 'POST',
+            url: aaurl,
+            data: post,
+            success: function (data) {
+                if (data == '-1') {
+                } else {
+                    $('#post-' + pid).find('span.shortlink').hide();
+                    $('#page-' + pid).find('span.shortlink').hide();
+                }
+            },
+            error: function (data) {
+            }
+        });
+    }
+
+    function do_delshort() {
+        $('table input:checkbox').each(function () {
+            if ($(this).is(':checked')) {
+                var sid = $(this).val();
+                do_ajaxshort(sid);
+            }
+        });
+    }
+
+
+    $('#doaction').click(function () {
+        var actval = $('select[name=action]').val();
+        if (actval == 'delshort') {
+            do_delshort();
+            return false;
+        }
+    });
+    $('#doaction2').click(function () {
+        var actval = $('select[name=action2]').val();
+        if (actval == 'delshort') {
+            do_delshort();
+            return false;
+        }
+    });
+
+
+});

+ 457 - 0
include/class.ss_options.php

@@ -0,0 +1,457 @@
+<?php
+/*
+ * WordPress Plugin Development Helpers - Options
+ * @link: http://salamzadeh.net/plugins/urlyar
+ * @author Sasan Salamzadeh
+ * @version 1.0
+ */
+
+/*
+    Class Description
+        This is a helper class for WordPress options database.
+        Minimizes polling to the WP Database
+        Meant to be used in WordPress plugin Development.
+*/
+
+if (!class_exists('ss_options')) :
+    class ss_options
+    {
+
+        /*
+         *****************************************
+         *
+         *	Class Variables
+         *
+         *****************************************
+         */
+
+
+        private $default_details = array(), //version and status
+            $plugin_details = array('version' => NULL),
+
+            $option_name = '', //database option name
+
+            $options = array(), //working options / saved options
+            $default_options = array(), //author defaults
+
+            $master_list = array();
+
+
+        /*
+         *****************************************
+         *
+         *	Constructors
+         *
+         *****************************************
+         */
+
+        //php 5.3.3
+        public function __construct($name, $version, $status = 'stable')
+        {
+            $this->ss_options($name, $version, $status);
+        }
+
+        //backward compatibility
+        public function ss_options($name, $version, $status = 'stable')
+        {
+            $this->default_details['version'] = $version;
+            $this->default_details['status'] = $status;
+            $this->option_name = $name;
+        }
+
+
+
+        /*
+         *****************************************
+         *
+         *	Initialization
+         *
+         *****************************************
+         */
+
+        /*
+         *****************************************
+         * Create Master List
+		 * (Before Saving)
+         *****************************************
+         */
+
+        private function init_master()
+        {
+            $this->master_list = $this->default_details;
+            $this->master_list['options'] = $this->options;
+        }
+
+        /*
+         *****************************************
+         *
+         *	Helpers
+         *
+         *****************************************
+         */
+
+
+        /*
+         *****************************************
+         * Refresh List from Database
+         *****************************************
+         */
+        private function refresh_vars()
+        {
+            $saved = get_option($this->option_name);
+
+            if ($saved) {
+                $this->options = $saved['options'];
+                $this->plugin_details['version'] = $saved['version'];
+                $this->plugin_details['status'] = $saved['status'];
+            }
+
+        }
+
+
+        /*
+         *****************************************
+         * Saving List to Database
+         *****************************************
+         */
+
+        private function save_options()
+        {
+            //create save array
+            $this->init_master();
+
+            //Update WordPress DB
+            update_option($this->option_name, $this->master_list);
+
+            //update global variable
+            $this->refresh_vars();
+        }
+
+        /*
+         *****************************************
+         *
+         *	Set and Retrival
+         *
+         *****************************************
+         */
+
+
+        /*
+         *****************************************
+         * Refresh and Return Saved options
+         *****************************************
+         */
+
+        public function saved_options()
+        {
+            $this->refresh_vars();
+            return $this->options;
+        }
+
+
+        /*
+         *****************************************
+         * Public refresh 
+		 * Use this instead of refresh_vars.
+		 * This is done for possible future ext.
+         *****************************************
+         */
+
+        public function refresh()
+        {
+            $this->refresh_vars();
+        }
+
+
+        /*
+         *****************************************
+         * Save to DB
+         *****************************************
+         */
+
+        public function save()
+        {
+            $this->save_options();
+        }
+
+
+        /*
+         *****************************************
+         * Return a key value
+		 * 
+		 * Option to refresh from db
+		 * Only supports first level keys
+         *****************************************
+         */
+
+        public function get($key, $refresh = true)
+        {
+            if ($refresh) {
+                $this->refresh_vars();
+            }
+
+            $value = $this->options[$key]??"";
+            return ($value) ? $value : '';
+        }
+
+
+        /*
+         *****************************************
+         * Set a key value
+		 * 
+		 * Option to save to / refresh from db
+		 * Only supports first level keys
+         *****************************************
+         */
+
+        public function set($key, $value, $save = false, $refresh = false)
+        {
+
+            if ($refresh) {
+                //update global variable
+                $this->refresh_vars();
+            }
+
+            $this->options[$key] = $value;
+
+            if ($save) {
+                $this->save_options();
+            }
+
+            return true;
+        }
+
+        /*
+         *****************************************
+         *
+         *	Installation and Migration
+         *
+         *****************************************
+         */
+
+
+        /*
+         *****************************************
+         * Merging Two Array of Options
+		 * Check for changes and 
+		 * determine of save needed 
+		 *
+		 * 2nd Array defaulted to "default_options
+         *****************************************
+         */
+
+        private function options_merge($compare, $base = NULL, $override = false)
+        {
+            //returns true when both sides are different and a merge is done
+            //returns false otherwise..
+            //allows overrides
+
+            if (empty($base)) {
+                $base = $this->default_options;
+            }
+
+            //Override defaults with saved
+            if (!empty($compare)) {
+                foreach ($compare as $key => $option) {
+                    $base[$key] = $option;
+                }
+            }
+
+            //Check for changes
+            if ($compare != $base || $override == true) {
+                $this->options = $base;
+                return true;
+            }
+
+            return false;
+        }
+
+
+        /*
+         *****************************************
+         * Setting Default Array of Options
+		 * 
+		 * If item is an array, import array
+		 * else just set an item value
+         *****************************************
+         */
+
+        public function set_default($item, $value = '')
+        {
+
+            //reset default
+            $this->default_options = array();
+
+            //check if first item array
+            if (is_array($item)) {
+                foreach ($item as $key => $value) {
+                    $this->default_options[$key] = $value;
+                }
+
+                //setting of individual items
+            } else {
+                $this->default_options[$item] = $value;
+            }
+
+        }
+
+
+        /*
+         *****************************************
+         * Install Options
+         *****************************************
+         */
+
+        public function install_options()
+        {
+
+            //ensure variables are updated
+            $this->refresh_vars();
+
+            if ($this->options_merge($this->options)) {
+                $this->save_options();
+            }
+
+        }
+
+
+        /*
+         *****************************************
+         * Option Migration
+         *****************************************
+         */
+
+        public function migrate_options($remove_key = NULL)
+        {
+
+            //ensure variables are updated
+            $this->refresh_vars();
+
+            if (empty($this->plugin_details['version']) ||
+                ($this->plugin_details['version'] < $this->default_details['version'])
+            ) {
+                $this->options = get_option($this->option_name);
+
+                if ($remove_key) {
+                    unset($this->options[$remove_key]);
+                }
+
+                if ($this->options_merge($this->options)) {
+                    $this->save_options();
+                }
+
+            }
+
+        }
+
+
+
+
+
+
+
+
+
+
+        /*
+         *****************************************
+         *
+         *	Misc
+         *
+         *****************************************
+         */
+
+
+        /*
+         *****************************************
+         * Get Version
+		 * Either Saved DB or Plugin Default
+         *****************************************
+         */
+
+        public function get_version($default = false)
+        {
+            if ($default) {
+                return $this->default_details['version'];
+            } else {
+                return $this->plugin_details['version'];
+            }
+        }
+
+
+        /*
+         *****************************************
+         * Reset Options to plugin defaults
+		 *
+		 * Option not to save first
+		 * Allows for modification after reset
+         *****************************************
+         */
+
+        public function reset_default($save = true)
+        {
+            $this->options = $this->default_options;
+
+            if ($save) {
+                $this->save_options();
+
+                //update global variable
+                $this->refresh_vars();
+            }
+
+        }
+
+
+        /*
+         *****************************************
+         * Value comparators
+		 * plugin detail or option
+         *****************************************
+         */
+
+        public function option_comparator($name, $value, $default = false)
+        {
+            if ($default) {
+                return ($this->default_options[$name] == $value) ? true : false;
+            } else {
+                return ($this->options[$name] == $value) ? true : false;
+            }
+        }
+
+
+        public function detail_comparator($name, $value, $default = false)
+        {
+            if ($default) {
+                return ($this->default_details[$name] == $value) ? true : false;
+            } else {
+                return ($this->plugin_details[$name] == $value) ? true : false;
+            }
+        }
+
+
+        /*
+         *****************************************
+         * Bulk saving all options 
+		 *
+		 * Not Recommended
+		 * (Not Complete yet)
+         *****************************************
+         */
+
+        public function bulk_save($item)
+        {
+            if ($this->options_merge($item)) {
+                $this->save_options();
+                return true;
+
+            } else {
+                return false;
+            }
+        }
+
+
+//end class
+    }
+endif;
+
+?>

+ 429 - 0
include/class.ss_shortener.php

@@ -0,0 +1,429 @@
+<?php
+/*
+ * class.ss_shortener - URL Shortener Plugin Component
+ * @link: http://salamzadeh.net/plugins/urlyar
+ * @author Sasan Salamzadeh
+ * @version 1.0
+ */
+
+
+/*
+    Class Description
+		This is the main shortener driver for the URL Shortener plugin
+        It dictates the supported services and functions of the URL shortener WordPress Plugin
+        For usage, please refer to http://salamzadeh.net/plugins/urlyar/
+        
+*/
+
+
+/*
+ *****************************************
+ *
+ *	Dependencies
+ *
+ *****************************************
+ */
+
+/*
+
+if ( !class_exists('urlyar_urlyar') ) :
+	include( dirname(__FILE__) . '/ss_shortener/urlyar.urlyar.php' );
+endif;
+
+*/
+
+
+/*
+ *****************************************
+ *
+ *	Main Class Declaration
+ *
+ *****************************************
+ */
+
+if (!class_exists('ss_shortener')) :
+    class ss_shortener
+    {
+
+
+        /*
+         *****************************************
+         *
+         *	Class Variables
+         *
+         *****************************************
+         */
+
+
+        private $service_keys = array();
+        private $service_details = array();
+
+        private $supported,                    //combined services
+            $status,                    //class status (beta, stable, dev)
+            $service = '',                //service name
+            $key = '',                    //keys
+            $user = '',                    //user / identity
+            $generic = '',                //generic field to pass
+            $shortener = '';            //shortener class
+
+        private $shortener_modules = array();    //shortener modules
+
+
+        /*
+         *****************************************
+         *
+         *	Constructors
+         *
+         *****************************************
+         */
+
+        //php 5.3.3
+        public function __construct($status = 'dev')
+        {
+            $this->ss_shortener($status);
+        }
+
+        //backward compatibility
+        public function ss_shortener($status = 'dev')
+        {
+            $this->status = $status;
+            $this->init_modules();
+            $this->supported = array_combine($this->service_keys, $this->service_details);
+        }
+
+
+
+        /*
+         *****************************************
+         *
+         *	Initialization
+         *
+         *****************************************
+         */
+
+
+        /*
+         *****************************************
+		 * Load and Init modules
+         *****************************************
+         */
+        private function init_modules()
+        {
+            $dirpath = dirname(__FILE__) . '/ss_shortener';
+            $this->load_modules($dirpath);
+
+            foreach ($this->shortener_modules as $module) {
+                include($module);
+                $mod = $this->is_module($module, true);
+                $this->add_support($mod['classname']);
+            }
+        }
+
+
+        /*
+         *****************************************
+		 * Check if PHP file is a module.
+		 * Option to return $module information.
+         *****************************************
+         */
+        public function is_module($module, $info = false)
+        {
+            $headers = array(
+                'name' => 'URLYar Name',
+                'description' => 'URLYar Description',
+                'version' => 'version',
+                'classname' => 'classname',
+            );
+
+            $mod = get_file_data($module, $headers);
+
+            if (empty($mod['name']))
+                return false;
+
+            return ($info) ? $mod : true;
+
+        }
+
+
+        /*
+         *****************************************
+		 * Scan a list of component classes
+		 * Put list into array
+		 * component classes
+         *****************************************
+         */
+        private function load_modules($filepath)
+        {
+            $filepath = untrailingslashit($filepath);
+
+            if (!$dir = opendir($filepath)) {
+                return $files;
+            }
+
+            while (false !== ($file = readdir($dir))) {
+                if ('.' == substr($file, 0, 1) || '.php' != substr($file, -4)) {
+                    continue;
+                }
+
+                $full_file = $filepath . '/' . $file;
+
+                if (!is_file($full_file) || !$this->is_module($full_file)) {
+                    continue;
+                }
+
+                array_push($this->shortener_modules, $full_file);
+            }
+            closedir($dir);
+        }
+
+
+        /*
+         *****************************************
+		 * Load a list of supported services from
+		 * component classes
+         *****************************************
+         */
+        private function add_support($classname)
+        {
+            $list = new $classname();
+
+            foreach ($list->api_list() as $keys => $values) {
+
+                //name, type, sticky.
+                //name, class, type
+                $detail = array($values[0], $classname, $values[1]);
+
+                if (empty($values[2])) {
+                    array_push($this->service_keys, $keys);
+                    array_push($this->service_details, $detail);
+                } else {
+                    array_unshift($this->service_keys, $keys);
+                    array_unshift($this->service_details, $detail);
+                }
+            }
+
+        }
+
+
+        /*
+         *****************************************
+		 * Component method... for use in another function
+		 * This loads the correct class or file into the common shortener variable.
+		 * Methods in different classes are the same.
+         *****************************************
+         */
+        private function load_shortener()
+        {
+
+            $data = 'OK';
+            $this->shortener = '';
+
+            if (!empty($this->service) && in_array($this->service, $this->service_keys)) {
+
+                $opt = $this->supported[$this->service];
+
+                switch ($opt[2]) {
+                    case '5':
+                        if (empty($this->key)) {
+                            $data = 'Error in Generating Shortlink (Invalid or No Key)';
+                        }
+                        break;
+                    case '6':
+                        if (empty($this->key) || empty($this->user)) {
+                            $data = 'Error in Generating Shortlink (Invalid or No Username/Key)';
+                        }
+                        break;
+                    default:
+                        break;
+                }
+
+                if ($data == 'OK') {
+
+                    //assign shortener
+                    $this->shortener = new $opt[1]($this->service, $this->status);
+
+                    //set configurations for object
+                    $this->shortener->config($this->key, $this->user, $this->generic);
+                }
+
+            } else { //end if in_array
+                $data = 'Service not specified or not supported';
+            }
+
+            return $data;
+        }//end load adapter
+
+
+        /*
+         *****************************************
+		 * Public initialization call
+         *****************************************
+         */
+        public function init_shortener()
+        {
+            return $this->load_shortener();
+        }
+
+
+        /*
+         *****************************************
+		 * Public link generation call
+         *****************************************
+         */
+        public function generate($url)
+        {
+
+            $data = NULL;
+
+            if (!empty($this->shortener)) {
+
+                if (!empty($url)) {
+                    //check for empty request
+                    $data = $this->shortener->generate($url);
+
+                } else {
+                    $data = ''; //'No URL specified';
+                }
+
+            } else {
+                $data = ''; //'Shortener not initialized';
+            }
+
+            return $data;
+        }
+
+
+        /*
+         *****************************************
+         *
+         *	Configurations
+         *
+         *****************************************
+         */
+
+
+        public function config($service = '', $key = '', $user = '', $generic = '')
+        {
+            $this->service = $service;
+            $this->key = $key;
+            $this->user = $user;
+            $this->generic = $generic;
+        }
+
+        public function set_user($value)
+        {
+            $this->user = $value;
+        }
+
+        public function set_key($value)
+        {
+            $this->key = $value;
+        }
+
+        public function set_service($value)
+        {
+            $this->service = $value;
+        }
+
+        public function set_generic($value)
+        {
+            $this->generic = $value;
+        }
+
+
+
+        /*
+         *****************************************
+         *
+         *	Misc
+         *
+         *****************************************
+         */
+
+        /*
+         *****************************************
+		 * Public listing of services, users, and keys.
+         *****************************************
+         */
+        public function service_list($format = 'keys')
+        {
+
+            $data = array();
+
+            switch ($format) {
+
+                case 'authuser':
+                    foreach ($this->supported as $keys => $values) {
+                        if ($values[2] == 1 || $values[2] == 3 || $values[2] == 4 || $values[2] == 6) {
+                            array_push($data, $keys);
+                        }
+                    }
+                    break;
+                case 'requser':
+                    foreach ($this->supported as $keys => $values) {
+                        if ($values[2] == 4 || $values[2] == 6) {
+                            array_push($data, $keys);
+                        }
+                    }
+                    break;
+                case 'authkey':
+                    foreach ($this->supported as $keys => $values) {
+                        if ($values[2] == 2 || $values[2] == 3 || $values[2] == 5 || $values[2] == 6) {
+                            array_push($data, $keys);
+                        }
+                    }
+                    break;
+                case 'reqkey':
+                    foreach ($this->supported as $keys => $values) {
+                        if ($values[2] == 5 || $values[2] == 6) {
+                            array_push($data, $keys);
+                        }
+                    }
+                    break;
+                case 'detailed':
+                    $data = $this->supported;
+                    break;
+                case 'keys':
+                default:
+                    $data = $this->service_keys;
+                    break;
+            }
+            return $data;
+        }
+
+
+        /*
+         *****************************************
+		 * Public check status of shortener
+         *****************************************
+         */
+        public function load_status()
+        {
+            return (empty($this->shortener)) ? false : true;
+        }
+
+
+        /*
+         *****************************************
+		 * Public list modules
+         *****************************************
+         */
+        public function get_modules()
+        {
+            $list = array();
+
+            foreach ($this->shortener_modules as $module) {
+                $mod = $this->is_module($module, true);
+                $mod['path'] = $module;
+                array_push($list, $mod);
+            }
+
+            return $list;
+        }
+
+
+//end class  
+    }
+endif;
+
+?>

+ 584 - 0
include/options_page.php

@@ -0,0 +1,584 @@
+<?php
+if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+
+$options = $this->plugin_option;
+
+
+$options->refresh();
+
+
+/*
+*****************************************
+*
+* Option page saving
+*
+*****************************************
+*/
+
+if (isset($_POST['submitted'])) {
+    check_admin_referer('urlyar-urlshortener');
+
+    //Shortener
+    $options->set('urlserviceenable',sanitize_text_field( $_POST['urlserviceenable']));
+    $options->set('useslug', sanitize_text_field($_POST['useslug']));
+    $options->set('appendurl', array('home' =>sanitize_text_field( $_POST['appendurl_home']),
+            'single' => sanitize_text_field($_POST['appendurl_single']),
+            'page' => sanitize_text_field($_POST['appendurl_page']),
+            'product' => sanitize_text_field($_POST['appendurl_product']),
+            'text' => strip_tags(sanitize_text_field($_POST['appendurl_text'])),
+        )
+    );
+
+    $options->set('appendqr', array('home' => sanitize_text_field($_POST['appendqr_home']),
+            'single' => sanitize_text_field($_POST['appendqr_single']),
+            'page' => sanitize_text_field($_POST['appendqr_page']),
+            'product' => sanitize_text_field($_POST['appendqr_product']),
+            'text' => strip_tags(sanitize_text_field($_POST['appendqr_text'])),
+            'provider' => sanitize_text_field($_POST['appendqr_provider']),
+        )
+    );
+
+    //Nice ID
+    $options->set('niceid', sanitize_text_field($_POST['niceid']));
+    $options->set('niceid_prefix', esc_url_raw($_POST['niceid_prefix']));
+
+    //Shortcode
+    $options->set('url_shortcode', sanitize_text_field($_POST['url_shortcode']));
+
+    //Services
+    $service_list = $this->shortener->service_list('detailed');
+
+    foreach ($service_list as $keys => $values) {
+
+        switch ($values[2]) {
+            case 1:
+            case 4:
+                $options->set('apiuser_' . $keys, sanitize_text_field($_POST['apiuser_' . $keys]));
+                break;
+            case 2:
+            case 5:
+                $options->set('apikey_' . $keys, sanitize_text_field($_POST['apikey_' . $keys]));
+                break;
+            case 3:
+            case 6:
+            case 101:
+                $options->set('apiuser_' . $keys, sanitize_text_field($_POST['apiuser_' . $keys]));
+                $options->set('apikey_' . $keys, sanitize_text_field($_POST['apikey_' . $keys]));
+                break;
+
+            default:
+                break;
+        }
+    }
+
+    $options->set('generic_yourls', array('endpoint' => sanitize_text_field($_POST['generic_yourls_endpoint'])
+        )
+    );
+
+
+    $options->set('generic_interdose', array('service' => sanitize_text_field($_POST['generic_interdose_service'])
+        )
+    );
+
+
+    //last command includes save.
+    $options->set('urlservice', sanitize_text_field($_POST['urlservice']));
+    $options->save();
+
+
+    echo '<div class="updated fade"><p>Plugin settings saved.</p></div>';
+}
+
+
+/*
+*****************************************
+*
+* Setup option page display
+*
+*****************************************
+*/
+
+
+$options->refresh();
+
+$urlserviceenable = $options->get('urlserviceenable');
+$urlservice = $options->get('urlservice');
+$useslug = $options->get('useslug');
+$appendurl = $options->get('appendurl');
+$appendqr = $options->get('appendqr');
+$niceid = $options->get('niceid');
+$niceid_prefix = $options->get('niceid_prefix');
+$url_shortcode = $options->get('url_shortcode');
+
+//$sfx = new FTShared();
+
+$supported = $this->shortener->service_list('detailed');
+$authkey = $this->shortener->service_list('authkey');
+$authuser = $this->shortener->service_list('authuser');
+$reqkey = $this->shortener->service_list('reqkey');
+$requser = $this->shortener->service_list('requser');
+
+
+/*
+*****************************************
+*
+* Start of the form
+*
+*****************************************
+*/
+?>
+<div class="wrap">
+    <h2><?php _e('URLYar URL Shortener', 'url-shortener');
+        echo ' ' . $this->plugin_version ?></h2>
+
+    <div class="j-show" id="tab-select">
+        <?php _e('Options', 'url-shortener')?>:
+        <ul>
+            <li><a rel="opt-gen" href="#opt-general"><?php _e('General', 'url-shortener')?></a></li>
+            <li><a rel="opt-add" href="#opt-additional"><?php _e('Additional Features', 'url-shortener')?></a></li>
+            <!--<li><a rel="opt-mod" href="#opt-modules">Modules</a></li>-->
+        </ul>
+    </div>
+
+
+    <form method="post" action="<?php echo $action_url ?>" id="shorturl_options">
+        <?php wp_nonce_field('urlyar-urlshortener'); ?>
+        <input type="hidden" name="submitted" value="1"/>
+
+
+        <?php /*
+		*****************************************
+		*
+		* General Options
+		*
+		*****************************************
+		*/ ?>
+        <fieldset id="opt-general" title="General Options for Plugin" class="fs-opt opt-gen j-hide">
+            <h3 class="divider"><?php _e('Main Settings', 'url-shortener'); ?></h3>
+            <table class="form-table">
+                <tr>
+                    <th scope="row"><label
+                                for="urlserviceenable"><?php _e('URL Shortener Integration', 'url-shortener'); ?></label>
+                    </th>
+                    <td>
+                        <input name="urlserviceenable" id="urlserviceenable" type="checkbox"
+                               value="yes" <?php checked('yes', $urlserviceenable) ?> />
+                        <span class="description"><?php _e('Enable Short URL generation using your <a href="#shorturl_selector">configured service<a/>.', 'url-shortener'); ?></span>
+                    </td>
+                </tr>
+                <tr>
+                    <th scope="row"><label
+                                for="useslug"><?php _e('Use Permalinks for Short URLs', 'url-shortener'); ?></label>
+                    </th>
+                    <td>
+                        <input name="useslug" id="useslug" type="checkbox"
+                               value="yes" <?php checked('yes', $useslug) ?> />
+                        <span class="description"><?php sprintf(_e('Use your <a href="%s/wp-admin/options-permalink.php">permalinks</a> to generate the Short URL.'), get_option('siteurl')); ?>
+                            <br/><?php _e('(Default: "http://yoursite/?p=123" or "http://yoursite/?page_id=123")', 'url-shortener'); ?></span>
+                    </td>
+                </tr>
+                <tr>
+                    <th scope="row"><label><?php _e('Append Short URL to: ', 'url-shortener'); ?></label></th>
+                    <td>
+                        <input name="appendurl_home" id="appendurl_home" type="checkbox"
+                               value="yes" <?php checked('yes', $appendurl['home']) ?> />
+                        <label for="appendurl_home"><?php _e('Posts (Homepage)', 'url-shortener'); ?></label>
+                        <br/>
+                        <input name="appendurl_single" id="appendurl_single" type="checkbox"
+                               value="yes" <?php checked('yes', $appendurl['single']) ?> />
+                        <label for="appendurl_single"><?php _e('Posts (Individual)', 'url-shortener'); ?></label>
+                        <br/>
+                        <input name="appendurl_page" id="appendurl_page" type="checkbox"
+                               value="yes" <?php checked('yes', $appendurl['page']) ?> />
+                        <label for="appendurl_page"><?php _e('Pages', 'url-shortener'); ?></label>
+                        <br/>
+                        <input name="appendurl_product" id="appendurl_product" type="checkbox"
+                               value="yes" <?php checked('yes', $appendurl['product']) ?> />
+                        <label for="appendurl_product"><?php _e('Products', 'url-shortener'); ?></label>
+                    </td>
+                </tr>
+                <tr>
+                    <th><label for="appendurl_text"><?php _e('Text before Short URL link ', 'url-shortener'); ?></label>
+                    </th>
+                    <td>
+                        <input name="appendurl_text" type="text" id="appendurl_text"
+                               value="<?php echo $appendurl['text']; ?>" class="regular-text code"/>
+                    </td>
+                </tr>
+            </table>
+        </fieldset>
+
+
+        <?php /*
+		*****************************************
+		*
+		* Additional options
+		*
+		*****************************************
+		*/ ?>
+        <fieldset id="opt-additional" title="Additional Features" class="fs-opt opt-add j-hide">
+            <h3 class="divider"><?php _e('Nice ID', 'url-shortener'); ?></h3>
+            <table class="form-table">
+                <tr>
+                    <th scope="row">
+                        <label for="niceid"><?php _e('Nice ID URLs', 'url-shortener'); ?></label><br/>
+                        <span class="description"><?php _e('(Formally named template_redirection)', 'url-shortener'); ?></span>
+                    </th>
+                    <td>
+                        <input name="niceid" id="niceid" type="checkbox" value="yes" <?php checked('yes', $niceid) ?> />
+                        <span class="description"><?php _e('Allows usage of "http://yoursite/123" instead of "http://yoursite/?p=123"', 'url-shortener'); ?></span>
+                    </td>
+                    </td>
+                </tr>
+                <tr>
+                    <th scope="row"><label for="niceid"><?php _e('Nice ID URL Prefix', 'url-shortener'); ?></label></th>
+                    <td>
+                        <input name="niceid_prefix" type="text" id="niceidprefix" value="<?php echo $niceid_prefix; ?>"
+                               class="regular-text code"/>
+                        <span class="description"><?php _e('default: "/"  (http://yoursite/123)</span>
+                        <p>Examples:
+                            <br />"<span class="red">prefix/</span>" = http://yoursite/<span class="red">prefix/</span>123
+                            <br />"<span class="red">prefix-</span>" = http://yoursite/<span class="red">prefix-</span>123
+                        </p>', 'url-shortener'); ?>
+                    </td>
+                    </td>
+                </tr>
+            </table>
+            <h3 class="divider"><?php _e('Shortcode', 'url-shortener'); ?></h3>
+            <table class="form-table">
+                <tr>
+                    <th scope="row"><label
+                                for="url_shortcode"><?php _e('Disable Shortcode [urlyar_shortlink]', 'url-shortener'); ?></label>
+                    </th>
+                    <td>
+                        <input name="url_shortcode" id="url_shortcode" type="checkbox"
+                               value="disable" <?php checked('disable', $url_shortcode) ?> />
+                        <span class="description"><?php _e('Disables the usage of URL Shortener shortcode [urlyar_shortlink]', 'url-shortener'); ?></span>
+                    </td>
+                    </td>
+                </tr>
+            </table>
+            <h3 class="divider"><?php _e('QR Code', 'url-shortener'); ?></h3>
+            <table class="form-table">
+                <tr>
+                    <th scope="row"><label><?php _e('Append QR Code to: ', 'url-shortener'); ?></label></th>
+                    <td>
+                        <input name="appendqr_home" id="appendqr_home" type="checkbox"
+                               value="yes" <?php checked('yes', $appendqr['home']) ?> />
+                        <label for="appendqr_home"><?php _e('Posts (Homepage)', 'url-shortener'); ?></label>
+                        <br/>
+                        <input name="appendqr_single" id="appendqr_single" type="checkbox"
+                               value="yes" <?php checked('yes', $appendqr['single']) ?> />
+                        <label for="appendqr_single"><?php _e('Posts (Individual)', 'url-shortener'); ?></label>
+                        <br/>
+                        <input name="appendqr_page" id="appendqr_page" type="checkbox"
+                               value="yes" <?php checked('yes', $appendqr['page']) ?> />
+                        <label for="appendqr_page"><?php _e('Pages', 'url-shortener'); ?></label>
+                        <br/>
+                        <input name="appendqr_product" id="appendqr_product" type="checkbox"
+                               value="yes" <?php checked('yes', $appendqr['page']) ?> />
+                        <label for="appendqr_product"><?php _e('Products', 'url-shortener'); ?></label>
+                    </td>
+                </tr>
+                <tr>
+                    <th><label for="appendqr_provider"><?php _e('QR Code Provider ', 'url-shortener'); ?></label></th>
+                    <td>
+                        <div><input name="appendqr_provider" type="radio" id="appendqr_provider"
+                                    value="urlyar" <?php echo ($appendqr['provider'] == "urlyar") ? "checked" : ""; ?>
+                                    class="regular-radio code"/>
+                            <label for="appendqr_urlyar"><?php _e('URLYar', 'url-shortener'); ?></label>
+                        </div>
+                        <div><input name="appendqr_provider" type="radio" id="appendqr_provider"
+                                    value="google" <?php echo ($appendqr['provider'] == "google") ? "checked" : ""; ?>
+                                    class="regular-radio code"/>
+                            <label for="appendqr_google"><?php _e('Google', 'url-shortener'); ?></label>
+                        </div>
+                    </td>
+                </tr>
+                <tr>
+                    <th><label for="appendqr_text"><?php _e('Text before QR Code ', 'url-shortener'); ?></label></th>
+                    <td>
+                        <input name="appendqr_text" type="text" id="appendqr_text"
+                               value="<?php echo $appendqr['text']; ?>" class="regular-text code"/>
+                    </td>
+                </tr>
+            </table>
+        </fieldset>
+
+        <?php /*
+		*****************************************
+		*
+		* Modules
+		*
+		*****************************************
+        <fieldset id="opt-modules" title="List of Modules" class="fs-opt opt-mod j-hide">
+			<h3 class="divider"><?php _e('Shortener Modules', 'url-shortener'); ?></h3> 
+			<table id="component_list" class="widefat post fixed" cellspacing="0">
+            	<thead>
+                    <tr>
+                        <th scope="col" class="manage-column"><?php _e('Name', 'url-shortener'); ?></th>
+						<th scope="col" class="manage-column"><?php _e('Description', 'url-shortener'); ?></th>
+						<th scope="col" class="manage-column colsmall"><?php _e('ID', 'url-shortener'); ?></th>
+                    </tr>
+                </thead>
+            	<tfoot>
+                    <tr>
+                        <th scope="col" class="manage-column"><?php _e('Name', 'url-shortener'); ?></th>
+						<th scope="col" class="manage-column"><?php _e('Description', 'url-shortener'); ?></th>
+						<th scope="col" class="manage-column colsmall"><?php _e('ID', 'url-shortener'); ?></th>
+                    </tr>
+                </tfoot>
+				<tbody>
+				<?php foreach ($this->shortener_modules as $modules){ ?>
+					<tr>
+						<td class="name">
+							<strong class="checkit"><?php echo $modules['name']; ?></strong>
+							<span>Version: <?php echo $modules['version']; ?></span>
+						</td>
+						<td>
+
+							<?php echo $modules['description']; ?>
+						</td>
+						<td><?php echo $modules['classname']; ?></td>
+					</tr>
+				<?php } ?>
+				</tbody>
+			</table>
+        </fieldset>
+		*/ ?>
+
+        <?php /*
+		*****************************************
+		*
+		* Shortlink Service Table
+		*
+		*****************************************
+		*/ ?>
+        <fieldset title="URL Shortening Services" id="shorturl_selector" class="opt-gen j-hide">
+            <h3 class="divider"><?php _e('URL Service Configuration', 'url-shortener'); ?></h3>
+            <p><?php _e('Select and configure your desired Short URL service.', 'url-shortener'); ?></p>
+            <p><?php _e('<span class="red">*</span> are required configurations for that service.', 'url-shortener'); ?></p>
+            <div class="reqfielderror"></div>
+            <table id="shorturl_table" class="widefat post fixed" cellspacing="0">
+                <thead>
+                <tr>
+                    <th scope="col" id="col1" class="manage-column"><?php _e('Select', 'url-shortener'); ?></th>
+                    <th scope="col" id="col2" class="manage-column"><?php _e('Services', 'url-shortener'); ?></th>
+                    <th scope="col" class="manage-column"><span
+                                class="col3c"><?php _e('Configuration', 'url-shortener'); ?></span></th>
+                </tr>
+                </thead>
+                <tfoot>
+                <tr>
+                    <th scope="col" class="manage-column"><?php _e('Select', 'url-shortener'); ?></th>
+                    <th scope="col" class="manage-column"><?php _e('Services', 'url-shortener'); ?></th>
+                    <th scope="col" class="manage-column"><span
+                                class="col3c"><?php _e('Configuration', 'url-shortener'); ?></span></th>
+                </tr>
+                </tfoot>
+                <tbody>
+                <?php
+
+                /*
+                 *****************************************
+                 *
+                 * Individual configuration fields
+                 *
+                 *****************************************
+                 */
+
+                foreach ($supported as $key => $value) {
+
+                    if ($urlservice == $key) {
+                        $sh = 'show';
+                        $rh = 'class="detail"';
+                    } else {
+                        $sh = 'hide';
+						$rh='';
+                    }
+                    $apirow = '<tr id="row_' . $key . '"' . $rh . '>';
+                    $apirow .= '<th class="ssr" scope="row"><input name="urlservice" id="' . $key . '" type="radio" value="' . $key . '"' . checked($key, $urlservice, false) . '/></th>';
+                    $apirow .= '<td class="ssl"><label for="' . $key . '">' . $value[0] . '</label></td><td>';
+
+                    $apirow .= '<div id="userkey_' . $key . '" class="APIConfig ' . $sh . '">';
+                    $apireq = '';
+
+
+                    /*
+                     *****************************************
+                     * User Authentication
+                     *****************************************
+                     */
+                    if (in_array($key, $authuser)) {
+                        $apireq .= '<label for="apiuser_' . $key . '">';
+                        in_array($key, $requser) ? $apireq .= '<span>*</span>' : $apireq .= '';
+                        $apireq .= __('User/ID', 'url-shortener') . ': </label><input type="text" name="apiuser_' . $key . '" id="apiuser_' . $key . '" value="' . $options->get('apiuser_' . $key) . '" />';
+                    }
+
+
+                    /*
+                     *****************************************
+                     * Key Authentication
+                     *****************************************
+                     */
+                    if (in_array($key, $authkey)) {
+                        $apireq .= '<label for="apikey_' . $key . '">';
+                        in_array($key, $reqkey) ? $apireq .= ' <span>*</span>' : $apireq .= '';
+                        $apireq .= __('Key/API', 'url-shortener') . ': </label><input type="text" name="apikey_' . $key . '" id="apikey_' . $key . '" value="' . $options->get('apikey_' . $key) . '" />';
+
+                    }
+
+                    /*
+                     *****************************************
+                     * Misc Authentication Fields..
+                     * Case by Case Basis
+                     *****************************************
+                     */
+
+                    switch ($key) {
+                        case 'yourls':
+                            $apireq .= '<label for="apiuser_' . $key . '">';
+                            $apireq .= __('User/ID', 'url-shortener') . ': </label><input type="text" name="apiuser_' . $key . '" id="apiuser_' . $key . '" value="' . $options->get('apiuser_' . $key) . '" />';
+
+                            $apireq .= '<label for="apikey_' . $key . '">';
+                            $apireq .= __('Password', 'url-shortener') . ': </label><input type="password" name="apikey_' . $key . '" id="apikey_' . $key . '" value="' . $options->get('apikey_' . $key) . '" />';
+
+                            $apireq .= '<div class="contentblock"><label for="generic_' . $key . '_endpoint">';
+                            $generic = $options->get('generic_' . $key);
+                            $apireq .= __('URL to the YOURLS API', 'url-shortener') . ': </label><input style="display: block; width: 80%;" type="text" name="generic_' . $key . '_endpoint" id="generic_' . $key . '_endpoint" value="' . $generic['endpoint'] . '" />';
+                            $apireq .= 'Example: http://site.com/yourls-api.php';
+                            $apireq .= '<br /><strong>Note:</strong> Please check out <a href="http://salamzadeh.net/plugins/urlyar/docs/url-shortener-wordpress-plugin/known-issues">Known issues</a> before activiting yourls support</strong>';
+                            $apireq .= '</div>';
+
+                            break;
+                        case 'interdose':
+                            $apireq .= '<div class="contentblock"><label for="generic_' . $key . '_service">';
+                            $generic = $options->get('generic_' . $key);
+                            $apireq .= '<span>*</span>' . __('Service/Domain', 'url-shortener') . ': </label><input style="display: block; width: 80%;" type="text" name="generic_' . $key . '_service" id="generic_' . $key . '_service" value="' . $generic['service'] . '" />';
+                            $apireq .= 'Example: piep.net, xlnk.cc';
+                            $apireq .= '</div>';
+
+                            break;
+
+                        default:
+                            break;
+                    }
+
+
+                    /*if (in_array($key, $this->generic)){
+                        $apireq .= '<br /><label for="generic_'.$key.'">';
+
+                        //Cases
+                        switch ($key){
+                            case 'interdose':
+                                $apireq .= __('Service', 'url-shortener') . ': </label><input type="text" name="generic_'.$key.'" id="generic_'.$key.'" value="'.$options->get('generic_'.$key].'" />';
+                                $data = $sfx->openurl('http://api.interdose.com/api/shorturl/v1/services.json');
+                                $data = $sfx->processjson($data);
+                                $count = count($data);
+                                if ($count){
+                                    $apireq .= '<br /><span class="slabel">Public Services: </span>';
+                                    for ($i = 0; $i < $count; $i++){
+                                        $apireq .= '<a class="val_'.$key.'" href="#generic_'.$key.'">'.$data[$i]->service.'</a>';
+                                    }
+                                }
+                                break;
+                            default:
+                                break;
+                        }
+                    } */
+
+                    if ($apireq == '') {
+                        $apireq = '<span class="nc">' . __('No Configuration Needed', 'url-shortener') . '</span>';
+                    }
+
+                    $apirow .= $apireq;
+                    $apirow .= '</div></td></tr>';
+                    $rh = '';
+                    echo $apirow;
+                }
+                ?>
+                </tbody>
+            </table>
+
+            <div class="clear"></div>
+        </fieldset>
+
+
+        <div class="reqfielderror"></div>
+        <script type="text/javascript">
+            jQuery(document).ready(function ($) {
+
+                //display modification
+                $('.hide, .col3c, .reqfielderror, .j-hide').hide();
+                $('#tab-select li:first a').addClass('tab-now');
+                $('.j-show').show();
+
+                var tabnow = '.' + $('.tab-now').attr('rel');
+                $(tabnow).show();
+
+                $('#tab-select a').click(function () {
+                    $('.j-hide').hide();
+                    $('.tab-now').removeClass('tab-now');
+                    $(this).addClass('tab-now');
+
+                    var tabnow = '.' + $('.tab-now').attr('rel');
+                    $(tabnow).fadeIn();
+                    return false;
+                })
+
+                //Service Selection Table
+                $('.ssr input[type="radio"]').change(function () {
+                    $('.showdetail .APIConfig, .detail .APIConfig').hide();
+                    $('.showdetail').removeClass('showdetail');
+                    var pc = '';
+                    pc = $(this).parent().parent();
+                    if (($(this).is(':checked'))) {// && !(pc.hasClass('rh'))){
+                        pc.addClass('showdetail');
+                        $('.showdetail .APIConfig').show();
+                    }
+                });
+
+                $('.val_interdose').click(function () {
+                    linkval = $(this).html()
+                    $('#generic_interdose').val(linkval);
+                })
+
+                //Submission Functions
+                var requser = ['snipurl', 'snurl', 'snipr', 'snim', 'cllk'];
+                var reqkey = ['snipurl', 'snurl', 'snipr', 'snim', 'cllk', 'awesm', 'pingfm'];
+                $('#shorturl_options').submit(function () {
+                    $('.reqfielderror').html('');
+                    var errorcount = false;
+                    var checkopt = $('input:radio[name=urlservice]:checked').val();
+                    if ($.inArray(checkopt, requser) == -1) {
+                    } else {
+                        var suser = jQuery.trim($('#apiuser_' + checkopt).val());
+                        if (suser == '') {
+                            $('.reqfielderror').append('<?php _e('<strong>Service Configuration: </strong>Please fill the required User/ID', 'url-shortener'); ?><br />');
+                            errorcount = true;
+                        }
+                    }
+                    if ($.inArray(checkopt, reqkey) == -1) {
+                    } else {
+                        var spass = jQuery.trim($('#apikey_' + checkopt).val());
+                        if (spass == '') {
+                            $('.reqfielderror').append('<?php _e('<strong>Service Configuration: </strong>Please fill in the required API/Key', 'url-shortener'); ?><br />');
+                            errorcount = true;
+                        }
+                    }
+                    if (errorcount) {
+                        $('.reqfielderror').fadeIn(400);
+                        return false;
+                    } else {
+                        $('.reqfielderror').hide();
+                        //return false;
+                    }
+                });//end submission
+
+            });//end js    
+        </script>
+
+        <p class="submit"><input type="submit" id="submit-button" class="button-primary"
+                                 value="<?php _e('Save Changes') ?>"/></p>
+    </form>
+</div>

+ 53 - 0
include/options_page_help.php

@@ -0,0 +1,53 @@
+<?php
+if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+
+$help_text = '<div id="urlyar_help"><img class="urlyarplugin-logo" src="'.$this->plugin_url.'/urlyar-logo.jpg" alt="" />';
+
+	$help_text .= '<h3>'. __('More Information', 'url-shortener') . '</h3>';
+	$help_text .= '<p>'.__('Additional information and upgrade notes are available via the plugin\'s <a href="http://salamzadeh.net/plugins/urlyar/docs/url-shortener-wordpress-plugin">Wiki Page</a>', 'url-shortener').'</p>';
+	
+	$help_text .= '<p>'. __('Do check out the <a href="http://salamzadeh.net/plugins/urlyar/docs/url-shortener-wordpress-plugin/faq">FAQ</a> and <a href="http://salamzadeh.net/plugins/urlyar/docs/url-shortener-wordpress-plugin/known-issues">Known Issues</a> as well').'</p>';
+
+
+	$help_text .= '<h3>'.__('Version References', 'url-shortener').'</h3>';
+	$help_text .= '<p><ul>';
+		$help_text .= '<li>'.__('Plugin Version: ', 'url-shortener').$this->plugin_version.'-'.$this->plugin_status.'</li>';
+	$help_text .= '</ul></p>';
+
+
+	$help_text .= '<h3>'. __('Shortener Modules', 'url-shortener').'</h3>'; 
+	$help_text .= '<table id="component_list" class="widefat post fixed" cellspacing="0">';
+		$help_text .= '<thead>';
+			$help_text .= '<tr>';
+				$help_text .= '<th scope="col" class="manage-column">' . __('Name', 'url-shortener') . '</th>';
+				$help_text .= '<th scope="col" class="manage-column">'. __('Description', 'url-shortener') .'</th>';
+				$help_text .= '<th scope="col" class="manage-column colsmall">'. __('ID', 'url-shortener') .'</th>';
+			$help_text .= '</tr>';
+		$help_text .= '</thead>';
+		$help_text .= '<tbody>';
+			foreach ($this->shortener_modules as $modules){ 
+			$help_text .= '<tr>';
+				$help_text .= '<td class="name">';
+					$help_text .= '<strong class="checkit">'.$modules['name'] .'</strong>';
+					$help_text .= '<span>Version:'. $modules['version'] .'</span>';
+				$help_text .= '</td>';
+				$help_text .= '<td>';
+					$help_text .= $modules['description'];
+				$help_text .= '</td>';
+				$help_text .= '<td>'.$modules['classname'] .'</td>';
+			$help_text .= '</tr>';
+			}
+		$help_text .= '</tbody>';
+	$help_text .= '</table>';
+
+
+
+
+	$help_text .= '<h3>'. __('Support', 'url-shortener') . '</h3>';
+	$help_text .= '<p>'. __('You can get support for the plugin via the following channels: ', 'url-shortener') . '<ul>';
+		$help_text .= '<li>'. __('<a href="http://wordpress.org/tags/url-shortener">WordPress Support Forum</a>', 'url-shortener'). '</li>';
+		$help_text .= '<li>'. __('<a href="https://www.salamzadeh.net/contact/">Send me a message</a>', 'url-shortener').'</li>';
+	$help_text .= '</ul></p>';
+	$help_text .= '<p>' . __('If you like this plugin and would like to <a href="http://salamzadeh.net/plugins/urlyar/contribute/">Contribute</a> back, I\'ll be very grateful!', 'url-shortener') . '</p>';
+$help_text .= '</div>';
+?>

+ 168 - 0
include/pub_get_shortlink.php

@@ -0,0 +1,168 @@
+<?php
+if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+
+global $wp_query;
+
+$shortlink = '';
+$options = $this->plugin_option;
+
+
+/*
+    Ensure shortener is loaded.. 
+    i.e all options are set correctly
+    Abort otherwise
+*/
+
+if (!$this->shortener_loader()) {
+    return '';
+}
+
+
+/*
+    Page type switches
+*/
+if ($context == 'query') {
+    if (is_singular()) {
+        $id = $wp_query->get_queried_object_id();
+        $context = 'post';
+    } elseif (is_front_page()) {
+        $context = 'blog';
+    } else {
+        return '';
+    }
+}
+
+
+$home_url = get_option('home');
+
+
+/*
+    If Homepage
+*/
+if ($context == 'blog') {
+    if (empty($id))
+        $url = $home_url;
+
+    if ($options->get('urlservice') != 'yourls') {
+        $shortlink = $this->shortener->generate($url);
+    }
+    return $shortlink;
+}
+
+/*
+    If post
+*/
+$post = get_post($id);
+if (empty($post)) {
+    return '';
+}
+
+
+/*
+    Set up post details
+*/
+
+$post_id = $post->ID;
+$post_type = $post->post_type;
+$post_status = $post->post_status;
+$url = '';
+$saved_url = get_post_meta($post_id, 'shorturl', true);
+
+
+/*
+ ************************
+ *
+ * Main Shortening Work
+ *
+ ************************
+ */
+
+//check prior generation and publish status
+if (empty($saved_url) && ($post_status == 'publish' || $transition == true)) {
+
+
+    //Add 'Generating' word stub to prevent generation loops (esp. Yourls)
+    update_post_meta($post_id, 'shorturl', 'Generating...');
+
+    //Use permalinks
+    if ($options->get('useslug') == 'yes') {
+        $url = get_permalink($post_id);
+
+        if ($url) {
+            $shortlink = $this->shortener->generate($url);
+        }
+
+        //Use IDs
+    } else {
+
+
+        switch ($post_type) {
+            case 'post' :
+                $url = $home_url . "/index.php?p=" . $post_id;
+                break;
+            case 'product' :
+                $url = $home_url . "/index.php?p=" . $post_id;
+                break;
+            case 'page' :
+                $url = $home_url . "/index.php?page_id=" . $post_id;
+                break;
+            default :
+                break;
+        }
+        if ($url) {
+            $shortlink = $this->shortener->generate($url);
+        }
+    }
+
+    /*
+     ***********************
+     * Allow other plugins to use generated shortlink (1st generation) 
+     ************************
+     */
+
+    if (!empty($shortlink)) {
+        do_action('urlyar_use_shortlink', $post_id, $shortlink);
+    }
+
+
+//assign saved URL if already generated    
+} elseif (!empty($saved_url)) {
+    $shortlink = $saved_url;
+}
+
+//Update Custom Field
+if (empty($saved_url) && !empty($shortlink)) {
+    update_post_meta($post_id, 'shorturl', $shortlink);
+
+} elseif (empty($saved_url)) {
+    //remove 'Generating' word stub in case generation failed
+    delete_post_meta($post_id, 'shorturl', 'Generating...');
+}
+
+
+//Return Nice ID if shortlink is still empty
+if ($options->get('niceid') == 'yes' && empty($shortlink)) {
+    $shortlink = $home_url . $options->get('niceid_prefix') . $post_id;
+}
+
+
+/*
+ ***********************
+ * Allow other plugins to filter output
+ ************************
+ */
+
+if (!empty($shortlink)) {
+    apply_filters('urlyar_filter_shortlink', $post_id, $shortlink);
+}
+
+
+/*
+ ***********************
+ * Finally!
+ ************************
+ */
+return $shortlink;
+
+
+?>

+ 90 - 0
include/ss_shortener/lib/urlyar.interface.php

@@ -0,0 +1,90 @@
+<?php
+/*
+ * URLYarLib Name:		urlyar.interface - JZ Shortener Component (URLYar) Interface
+ * URLYarLib Description: This is the interface declarion for component classes of the main ss_shortener
+ * classname: 			urlyar_interface
+ * version: 			1.1.0
+ * link: 				http://urlyar.ir
+ * author: 				Sasan Salamzadeh <me@salamzadeh.net>
+ */
+
+
+if (!interface_exists('urlyar_interface')) :
+    interface urlyar_interface
+    {
+
+
+        /*
+         *****************************************
+         *	Methods
+         *****************************************
+         */
+
+
+        function generate($url);                    //main generator
+
+        function config($key, $user, $generic);        //config call to parent
+
+        function api_list();                        //calls parent api_list function with parameter
+
+        function set_service($service);            //loads $api_config and service into parent class
+
+
+        /*
+         *****************************************
+         *	Variables
+         *****************************************
+         */
+
+        /*
+            private $ua_string
+                Stores the replacement UA String.
+            ----------------------------------------------------------------
+
+
+            private $api_config = array()
+            ----------------------------------------------------------------
+            - name
+                Display name
+
+            - endpoint
+                URL to send request to
+
+            - format
+                JSON, XML, TXT, or any special formats
+
+            - ua (TRUE/FALSE)
+                Override UA strings
+
+            - override
+                Override WP_HTTP. i.e. Use normal methods of request
+
+            - method (POST / GET )
+
+            - sticky
+                Append to front of generated API listing
+
+            - type
+                NULL = disabled / suspended
+
+                0 = no auth/key required
+
+                1 = authuser
+                2 = authkey
+                3 = authuser & key
+                4 = requser
+                5 = reqkey
+                6 = requser & key
+
+                101 - 200 = Generic / Special
+
+                sub = child of a complex type
+            ----------------------------------------------------------------
+
+        */
+
+
+//end interface
+    }
+endif;
+?>

+ 360 - 0
include/ss_shortener/lib/urlyar.shared.php

@@ -0,0 +1,360 @@
+<?php
+/*
+ * URLYarLib Name:		urlyar.shared - Shared JZ Shortener Components
+ * URLYarLib Description: This class contains the request gateway for shortening
+ * classname: 			urlyar_interface
+ * version: 			1.1.0
+ * link: 				https://salamzadeh.net
+ * author: 				Sasan Salamzadeh <me@salamzadeh.net>
+ */
+
+/*
+	Full Description:
+		This class contains the request gateway for shortening.. 
+		Where possible, it makes use of the WP_HTTP class, but will fall back on basic methods 
+		when the WP_HTTP class is not available.
+
+		It's meant to be extended / inherited, but can be used as is.
+*/
+
+
+
+
+if ( !class_exists('urlyar_shared') ) :
+	class urlyar_shared {
+        
+
+
+
+
+/*
+ *****************************************
+ *
+ *	Class Variables
+ *
+ *****************************************
+ */
+
+
+		protected 	$status 	= 'stable', //stable, beta, dev, trial?
+					$user 		= '', 		//Username if required
+				  	$key 		= '', 		//API key if required
+				  	$url 		= '',		//URL to shorten
+					$loaded_api	= '',		//API details and other definitions
+					$api_name	= '',		//Name of service	
+					$generic 	= '';		//generic fields (Optional)
+        
+
+
+
+/*
+ *****************************************
+ *
+ *	Constructors
+ *
+ *****************************************
+ */
+
+        //php 5.3.3
+        public function __construct() {
+            $this->urlyar_shared($status);
+        }
+       
+        //backward compatibility
+        public function urlyar_shared($status){
+			$this->status = $status;         
+        }
+      
+
+
+
+  
+
+
+/*
+ *****************************************
+ *
+ *	Configuration
+ *
+ *****************************************
+ */
+
+		public function config($key, $user, $loaded_api, $generic = ''){
+			$this->user = $user;
+			$this->key = $key;
+			$this->loaded_api = $loaded_api;
+			$this->generic = $generic;
+		}
+
+
+
+
+
+
+
+
+/*
+ *****************************************
+ *
+ *	Data Processing
+ *
+ *****************************************
+ */
+
+
+
+        /*
+         *****************************************
+         * JSON Parser
+		 * Use PHP built in fx where available
+         *****************************************
+         */
+        public function json_process($item){
+            if ( class_exists('Services_JSON') ){
+                $json = new Services_JSON();
+                $result = $json->decode($item);
+            }else{
+                $result = json_decode($item, false);
+            }
+            return $result;
+        }
+
+
+
+
+
+
+        /*
+         *****************************************
+         * XML Parser
+         *****************************************
+         */
+
+		public function xml_process($item){
+			if ( class_exists('SimpleXMLElement') ){
+				$result = new SimpleXMLElement($item);	
+			}
+			return $result;
+		}
+
+
+
+
+
+/*
+ *****************************************
+ *
+ *	Data Request
+ *
+ *****************************************
+ */
+
+
+	    /*
+         *****************************************
+         * "Normal" Gateway
+		 *
+		 * By default, uses CURL for POST, GET
+		 * Fallback on file_get_contents for GET
+         *****************************************
+         */
+
+        protected function request_ALT($request_url, $post_opt = array(), $method = 'GET', $fields = '') {
+			
+			$data = NULL;
+			
+			if ( function_exists('curl_init') ) {
+				if ( !empty($post_opt['useragent']) ){ ini_set($useragent); }
+
+				$ch = curl_init();
+
+				curl_setopt($ch, CURLOPT_URL, $request_url);
+				curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
+				curl_setopt($ch, CURLOPT_HEADER, false);	
+
+				if ( !empty($post_opt['useragent']) ){ curl_setopt($ch, CURLOPT_USERAGENT, $post_opt['useragent']); }
+
+				if ($method == 'POST'){
+					
+					curl_setopt($ch, CURLOPT_POST, 1);
+					curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
+					curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);	
+				}      
+
+
+				if ( !empty($post_opt['httpheader']) ){        		
+					curl_setopt($ch, CURLOPT_HTTPHEADER, $post_opt['httpheader']);
+				}
+
+				$data = curl_exec($ch);
+				curl_close($ch);
+
+				if ( !empty($post_opt['useragent']) ){ ini_restore('user_agent'); }
+
+
+			} elseif($method = 'GET') {
+				$data = file_get_contents($request_url);
+			}
+
+		 	return $data;
+        }
+
+
+
+
+
+        /*
+         *****************************************
+         * WordPress Specific Gateway
+		 * Uses WP_HTTP class methods
+         *****************************************
+         */
+		protected function request_WP($request_url, $post_opt, $method, $body){
+			$data = NULL;
+
+	
+			if ( class_exists('WP_Http') ){
+				$request = new WP_Http;
+				$details = array();
+
+
+				if ($method == 'GET'){
+					$result = $request->request( $request_url );
+				}else{	
+					$details['method'] = $method;
+					$details['body'] = $body;
+
+					if ( empty($post_opt['useragent']) ){
+						$details['user-agent'] = $useragent;
+					}
+
+					$result = $request->request( $request_url, $details ); 
+				}
+
+
+				if($result['body']){
+					$data = $result['body'];
+				}
+				
+			}
+
+			return $data;
+
+		}
+
+
+
+
+ 	    /*
+         *****************************************
+         * Overall Gateway
+		 *
+		 * Switches between WordPress or Universal 
+		 * where appropriate
+		 *
+         *****************************************
+         */
+
+        public function request_gateway($request_url, $override = false, $method='POST', $post_opt = array(), $body = ''){
+            $data = '';
+
+			//check status
+			switch ($this->status){	
+				case 'trial'	:
+				case 'stable'	:
+
+				    //check for WP Http
+				    if ( class_exists('WP_Http') && !$override ){
+
+				       $data = $this->request_WP( $request_url, $post_opt, $method, $body);
+
+				    } else {
+					//use backup methods
+					
+						$data = $this->request_ALT($request_url, $post_opt, $method, $body);
+						
+					} //end if WP_HTTP
+					break;
+
+
+				case 'beta'	:
+				case 'dev'	:
+					$data = '[ '.$request_url.' ]-[ '.$body.' ]';
+					break;
+
+				default: 
+					break;
+
+
+			} //end switch
+
+
+
+			return $data;
+        }
+
+
+
+
+
+
+
+/*
+ *****************************************
+ *
+ *	Misc
+ *
+ *****************************************
+ */
+
+
+        /*
+         *****************************************
+         * URL Encoding
+         *****************************************
+         */
+
+        public function cleanurl(){
+            return urlencode($this->url);
+        }
+
+
+
+
+
+        /*
+         *****************************************
+         * Supported API List generation
+         *****************************************
+         */
+
+		public function api_list($list){
+			$compiled = array();
+
+			foreach ($list as $keys => $values){
+				if ( is_int($values['type']) ){
+					$compiled[$keys] = array($values['name'], $values['type'], $values['sticky']);
+				}
+			}
+			return $compiled;
+		}
+
+
+
+        /*
+         *****************************************
+         * Setting service
+         *****************************************
+         */
+		public function set_service($service, $api_config){
+			$this->api_name = $service;
+			$this->loaded_api = $api_config;
+		}
+
+
+
+//end class  
+    }
+endif;
+ 
+?>

+ 167 - 0
include/ss_shortener/urlyar.urlyar.php

@@ -0,0 +1,167 @@
+<?php
+/*
+ * URLYar Name: URLYar Support
+ * URLYar Description: This component adds support for URLYar's URL Shortening Service
+ * classname: urlyar_urlyar
+ * version: 1.1.0
+ * link: https://salamzadeh.net
+ * author: Sasan Salamzadeh
+ */
+
+if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+
+/*
+ *****************************************
+ *
+ *	Dependencies
+ *
+ *****************************************
+ */
+if (!class_exists('urlyar_shared')) :
+    include(dirname(__FILE__) . '/lib/urlyar.shared.php');
+endif;
+
+
+/*
+ *****************************************
+ *
+ *	Main Class Declaration
+ *
+ *****************************************
+ */
+
+if (!class_exists('urlyar_urlyar')) :
+    class urlyar_urlyar extends urlyar_shared
+    {
+
+
+        /*
+         *****************************************
+         *
+         *	Class Variables
+         *
+         *****************************************
+         */
+
+        private $api_config = array(
+            'urlyar' => array(
+                'name' => 'URLYar',
+                'endpoint' => 'http://urlyar.ir/api/',
+                'format' => 'json',
+                'ua' => FALSE,
+                'override' => TRUE,
+                'method' => 'GET',
+                'type' => 2,
+                'sticky' => TRUE,
+            ),
+
+        );
+
+
+        /*
+         *****************************************
+         *
+         *	Constructors
+         *
+         *****************************************
+         */
+
+
+        //php 5.3.3
+        public function __construct($service = NULL, $status = 'dev')
+        {
+            $this->urlyar_urlyar($service, $status);
+        }
+
+        //backward compatibility
+        public function urlyar_urlyar($service = NULL, $status = 'dev')
+        {
+            $this->api_name = 'urlyar';
+            $this->loaded_api = $this->api_config['urlyar'];
+            $this->status = $status;
+        }
+
+
+
+
+        /*
+         *****************************************
+         *
+         *	Methods
+         *
+         *****************************************
+         */
+
+
+        /*
+         *****************************************
+         * 	Config Requirements
+         *****************************************
+         */
+        public function set_service($service,$api_config = '')
+        {
+            parent::set_service('urlyar', $this->api_config['urlyar']);
+        }
+
+        public function config($key = '', $user = '',$loaded_api='', $generic = '')
+        {
+            $loaded_api = $this->api_config['urlyar'];
+            parent::config($key, $user, $loaded_api, $generic);
+        }
+
+        public function api_list($list='')
+        {
+            return parent::api_list($this->api_config);
+        }
+
+
+        /*
+         *****************************************
+         * 	Main Generator 
+         *****************************************
+         */
+        public function generate($url)
+        {
+            $this->url = $url;
+
+            if ($this->url) {
+
+                $request_url = $this->loaded_api['endpoint'] ."url/add";
+				$body = json_encode(["url" => $this->url]);
+                if ($this->key) {
+					$post_opt['httpheader'] = array('Content-Type: application/json',
+					'Authorization: Bearer '.$this->key);
+                    
+                } else {
+					echo __("Please use a valid API Key");
+                    return "";
+                }
+
+                if ($this->loaded_api['ua']) {
+                    $post_opt['useragent'] = $ua_string;
+                }
+                $result = parent::request_gateway($request_url, TRUE, "POST", $post_opt, $body);
+                //die($result);
+                if ($result) {
+                    $result = parent::json_process($result);
+					if($result->error == 1){
+						echo $result->message;
+						$result = '';
+					}
+                    else
+						$result = $result->shorturl;
+                }
+
+                //remove url request
+                $this->url = '';
+
+                return $result;
+            }
+        }
+
+
+//end class
+    }
+endif;
+
+?>

BIN
languages/url-shortener-fa_IR.mo


+ 342 - 0
languages/url-shortener-fa_IR.po

@@ -0,0 +1,342 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: URLYar\n"
+"POT-Creation-Date: 2019-01-25 11:42+0330\n"
+"PO-Revision-Date: 2019-01-25 11:42+0330\n"
+"Last-Translator: \n"
+"Language-Team: \n"
+"Language: fa_IR\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.2\n"
+"X-Poedit-Basepath: ..\n"
+"X-Poedit-WPHeader: urlyar.php\n"
+"X-Poedit-SourceCharset: UTF-8\n"
+"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
+"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
+"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+"X-Poedit-SearchPath-0: .\n"
+"X-Poedit-SearchPathExcluded-0: *.js\n"
+
+#: include/options_page.php:130
+msgid "URLYar URL Shortener"
+msgstr "کوتاه کننده یو آر ال یار"
+
+#: include/options_page.php:134
+msgid "Options"
+msgstr "تنظیمات"
+
+#: include/options_page.php:136
+msgid "General"
+msgstr "عمومی"
+
+#: include/options_page.php:137
+msgid "Additional Features"
+msgstr "امکانات بیشتر"
+
+#: include/options_page.php:156
+msgid "Main Settings"
+msgstr "تنظیمات اصلی"
+
+#: include/options_page.php:160
+msgid "URL Shortener Integration"
+msgstr "کوتاه کننده URL"
+
+#: include/options_page.php:165
+msgid ""
+"Enable Short URL generation using your <a href=\"#shorturl_selector"
+"\">configured service<a/>."
+msgstr ""
+"با استفاده از <a href=\"#shorturl_selector\">تنظیمات انجام شده</a> خود، "
+"تولید URL کوتاه را فعال کنید ."
+
+#: include/options_page.php:170
+msgid "Use Permalinks for Short URLs"
+msgstr "از پیوندهای یکتا برای URL های کوتاه استفاده کنید"
+
+#: include/options_page.php:175
+#, php-format
+msgid ""
+"Use your <a href=\"%s/wp-admin/options-permalink.php\">permalinks</a> to "
+"generate the Short URL."
+msgstr ""
+"از <a href=\"%s/wp-admin/options-permalink.php\">پیوندهای یکتا</a> برای "
+"تولید URL کوتاه استفاده کنید."
+
+#: include/options_page.php:176
+msgid ""
+"(Default: \"http://yoursite/?p=123\" or \"http://yoursite/?page_id=123\")"
+msgstr ""
+"(پیش فرض: \"http: // yoursite /؟ p = 123\" یا \"http: // yoursite /؟ page_id "
+"= 123\")"
+
+#: include/options_page.php:180
+msgid "Append Short URL to: "
+msgstr "اضافه کردن URL کوتاه به:"
+
+#: include/options_page.php:184 include/options_page.php:267
+msgid "Posts (Homepage)"
+msgstr "نوشته ها (صفحه اصلی)"
+
+#: include/options_page.php:188 include/options_page.php:271
+msgid "Posts (Individual)"
+msgstr "نوشته های (داخلی)"
+
+#: include/options_page.php:192 include/options_page.php:275
+msgid "Pages"
+msgstr "برگه‌ها"
+
+#: include/options_page.php:196
+msgid "Products"
+msgstr "محصولات"
+
+#: include/options_page.php:200
+msgid "Text before Short URL link "
+msgstr "متن قبل از لینک کوتاه لینک"
+
+#: include/options_page.php:219
+msgid "Nice ID"
+msgstr "شناسه خوب"
+
+#: include/options_page.php:223
+msgid "Nice ID URLs"
+msgstr "URL های شناسه خوب"
+
+#: include/options_page.php:224
+msgid "(Formally named template_redirection)"
+msgstr "(به طور معمول به نام template_redirection)"
+
+#: include/options_page.php:228
+msgid ""
+"Allows usage of \"http://yoursite/123\" instead of \"http://yoursite/?p=123\""
+msgstr ""
+"به \"http: // yoursite /؟ p = 123\" اجازه استفاده از \"http: // yoursite / "
+"123\" را می دهد"
+
+#: include/options_page.php:233
+msgid "Nice ID URL Prefix"
+msgstr "پیشوند دلخواه URL های شناسه خوب"
+
+#: include/options_page.php:237
+msgid ""
+"default: \"/\"  (http://yoursite/123)</span>\n"
+"                        <p>Examples:\n"
+"                            <br />\"<span class=\"red\">prefix/</span>\" = "
+"http://yoursite/<span class=\"red\">prefix/</span>123\n"
+"                            <br />\"<span class=\"red\">prefix-</span>\" = "
+"http://yoursite/<span class=\"red\">prefix-</span>123\n"
+"                        </p>"
+msgstr ""
+"به طور پیش فرض: \"/\" (http: // yoursite / 123) </span>\n"
+"<p style=\";text-align:right;direction:rtl\"> مثال ها: \n"
+"                            <br />\"<span class=\"red\">prefix/</span>\" = "
+"http://yoursite/<span class=\"red\">prefix/</span>123\n"
+"                            <br />\"<span class=\"red\">prefix-</span>\" = "
+"http://yoursite/<span class=\"red\">prefix-</span>123\n"
+"                        </p>"
+
+#: include/options_page.php:246
+msgid "Shortcode"
+msgstr "کد کوتاه"
+
+#: include/options_page.php:250
+msgid "Disable Shortcode [urlyar_shortlink]"
+msgstr "غیر فعال کردن شورتکد [urlyar_shortlink]"
+
+#: include/options_page.php:255
+msgid "Disables the usage of URL Shortener shortcode [urlyar_shortlink]"
+msgstr ""
+"استفاده از شورتکد کوتاه کننده لینک [urlyar_shortlink] را غیرفعال می کند"
+
+#: include/options_page.php:260
+msgid "QR Code"
+msgstr "کد کیو آر"
+
+#: include/options_page.php:263
+msgid "Append QR Code to: "
+msgstr "اضافه کردن QR به:"
+
+#: include/options_page.php:279
+msgid "QR Code Provider "
+msgstr "سرویس دهنده QR"
+
+#. Plugin Name of the plugin/theme
+#: include/options_page.php:284 urlyar.php:418
+msgid "URLYar"
+msgstr "URLYar"
+
+#: include/options_page.php:289
+msgid "Google"
+msgstr "گوگل"
+
+#: include/options_page.php:294
+msgid "Text before QR Code "
+msgstr "متن قبل از کد QR"
+
+#: include/options_page.php:353
+msgid "URL Service Configuration"
+msgstr "پیکربندی سرویس URL"
+
+#: include/options_page.php:354
+msgid "Select and configure your desired Short URL service."
+msgstr "سرویس کوتاه کننده URL دلخواه خود را انتخاب و تنظیم کنید"
+
+#: include/options_page.php:355
+msgid ""
+"<span class=\"red\">*</span> are required configurations for that service."
+msgstr "<span class=\"red\">*</span> تنظیمات برای آن سرویس الزامی است."
+
+#: include/options_page.php:360 include/options_page.php:368
+msgid "Select"
+msgstr "انتخاب"
+
+#: include/options_page.php:361 include/options_page.php:369
+msgid "Services"
+msgstr "سرویس ها"
+
+#: include/options_page.php:363 include/options_page.php:371
+msgid "Configuration"
+msgstr "پیکربندی"
+
+#: include/options_page.php:409 include/options_page.php:435
+msgid "User/ID"
+msgstr "شناسه کاربری"
+
+#: include/options_page.php:421
+msgid "Key/API"
+msgstr "Key / API Key مشتری"
+
+#: include/options_page.php:438
+msgid "Password"
+msgstr "کلمه عبور"
+
+#: include/options_page.php:442
+msgid "URL to the YOURLS API"
+msgstr "آدرس مربوط وب سرویس"
+
+#: include/options_page.php:451
+msgid "Service/Domain"
+msgstr "خدمات / دامنه"
+
+#: include/options_page.php:485
+msgid "No Configuration Needed"
+msgstr "بدون نیاز به پیکربندی"
+
+#: include/options_page.php:551
+msgid ""
+"<strong>Service Configuration: </strong>Please fill the required User/ID"
+msgstr ""
+"<strong>پیکربندی سرویس:</strong> لطفا کاربر / شناسه مورد نیاز را پر کنید"
+
+#: include/options_page.php:559
+msgid ""
+"<strong>Service Configuration: </strong>Please fill in the required API/Key"
+msgstr "<strong>پیکربندی سرویس:</strong> لطفا API / کلید مورد نیاز را پر کنید"
+
+#: include/options_page.php:576
+msgid "Save Changes"
+msgstr "ذخیره‌ی تغییرات"
+
+#: include/options_page_help.php:6
+msgid "More Information"
+msgstr "اطلاعات بیشتر"
+
+#: include/options_page_help.php:7
+msgid ""
+"Additional information and upgrade notes are available via the plugin's <a "
+"href=\"http://salamzadeh.net/plugins/urlyar/docs/url-shortener-wordpress-"
+"plugin\">Wiki Page</a>"
+msgstr ""
+"اطلاعات اضافی و نکات ارتقاء از طریق <a href=\"http://salamzadeh.net/plugins/"
+"urlyar/docs/url-shortener-wordpress-plugin\">صفحه ویکی</a> پلاگین قابل "
+"دسترسی است"
+
+#: include/options_page_help.php:9
+msgid ""
+"Do check out the <a href=\"http://salamzadeh.net/plugins/urlyar/docs/url-"
+"shortener-wordpress-plugin/faq\">FAQ</a> and <a href=\"http://salamzadeh.net/"
+"plugins/urlyar/docs/url-shortener-wordpress-plugin/known-issues\">Known "
+"Issues</a> as well"
+msgstr ""
+"همچنین بخش های <a href=\"http://salamzadeh.net/plugins/urlyar/docs/url-"
+"shortener-wordpress-plugin/faq\">سوالات متداول</a> و <a href=\"http://"
+"salamzadeh.net/plugins/urlyar/docs/url-shortener-wordpress-plugin/known-"
+"issues\">مسائل شناخته شده</a> را بررسی کنید"
+
+#: include/options_page_help.php:12
+msgid "Version References"
+msgstr "مراجع نسخه"
+
+#: include/options_page_help.php:14
+msgid "Plugin Version: "
+msgstr "ورژن افزونه:"
+
+#: include/options_page_help.php:18
+msgid "Shortener Modules"
+msgstr "ماژول های کوتاه کننده"
+
+#: include/options_page_help.php:22
+msgid "Name"
+msgstr "نام"
+
+#: include/options_page_help.php:23
+msgid "Description"
+msgstr "توضیحات"
+
+#: include/options_page_help.php:24
+msgid "ID"
+msgstr "آیدی"
+
+#: include/options_page_help.php:46
+msgid "Support"
+msgstr "پشتیبانی"
+
+#: include/options_page_help.php:47
+msgid "You can get support for the plugin via the following channels: "
+msgstr ""
+"شما می توانید از طریق کانال های زیر در خصوص افزونه پشتیبانی دریافت کنید:"
+
+#: include/options_page_help.php:48
+msgid ""
+"<a href=\"http://wordpress.org/tags/url-shortener\">WordPress Support Forum</"
+"a>"
+msgstr ""
+"<a href=\"http://wordpress.org/tags/url-shortener\">انجمن پشتیبانی وردپرس</a>"
+
+#: include/options_page_help.php:49
+msgid "<a href=\"https://www.salamzadeh.net/contact/\">Send me a message</a>"
+msgstr "<a href=\"https://www.salamzadeh.net/contact/\">برایم پیام بفرست</a>"
+
+#: include/options_page_help.php:51
+msgid ""
+"If you like this plugin and would like to <a href=\"http://salamzadeh.net/"
+"plugins/urlyar/contribute/\">Contribute</a> back, I'll be very grateful!"
+msgstr ""
+"اگر این افزونه را دوست دارید و مایل به <a href=\"http://salamzadeh.net/"
+"plugins/urlyar/contribute/\">کمک هستید</a> ، بسیار سپاسگزارم!"
+
+#: urlyar.php:388 urlyar.php:452
+msgid "Get Shortlink"
+msgstr "دریافت پیوندک"
+
+#. Plugin URI of the plugin/theme
+msgid "https://salamzadeh.net/plugins/urlyar"
+msgstr "https://salamzadeh.net/plugins/urlyar"
+
+#. Description of the plugin/theme
+msgid ""
+"This plugin provides integration of URL Shorteners (e.g. urlyar.ir, trew.ir, "
+"fsda.ir, saqw.ir and what you want)."
+msgstr ""
+"این افزونه خدمات کوتاه کردن لینک را فراهم می کند (مانند urlyar.ir، trew.ir، "
+"fsda.ir، saqw.ir و آنچه شما بخواهید)."
+
+#. Author of the plugin/theme
+msgid "Sasan Salamzadeh"
+msgstr "ساسان سلام زاده"
+
+#. Author URI of the plugin/theme
+msgid "http://www.salamzadeh.net"
+msgstr "http://www.salamzadeh.net"

+ 311 - 0
languages/url-shortener.pot

@@ -0,0 +1,311 @@
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: URLYar\n"
+"POT-Creation-Date: 2019-01-25 11:42+0330\n"
+"PO-Revision-Date: 2019-01-25 00:38+0330\n"
+"Last-Translator: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.2\n"
+"X-Poedit-Basepath: ..\n"
+"X-Poedit-WPHeader: urlyar.php\n"
+"X-Poedit-SourceCharset: UTF-8\n"
+"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
+"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
+"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
+"X-Poedit-SearchPath-0: .\n"
+"X-Poedit-SearchPathExcluded-0: *.js\n"
+
+#: include/options_page.php:130
+msgid "URLYar URL Shortener"
+msgstr ""
+
+#: include/options_page.php:134
+msgid "Options"
+msgstr ""
+
+#: include/options_page.php:136
+msgid "General"
+msgstr ""
+
+#: include/options_page.php:137
+msgid "Additional Features"
+msgstr ""
+
+#: include/options_page.php:156
+msgid "Main Settings"
+msgstr ""
+
+#: include/options_page.php:160
+msgid "URL Shortener Integration"
+msgstr ""
+
+#: include/options_page.php:165
+msgid ""
+"Enable Short URL generation using your <a href=\"#shorturl_selector"
+"\">configured service<a/>."
+msgstr ""
+
+#: include/options_page.php:170
+msgid "Use Permalinks for Short URLs"
+msgstr ""
+
+#: include/options_page.php:175
+#, php-format
+msgid ""
+"Use your <a href=\"%s/wp-admin/options-permalink.php\">permalinks</a> to "
+"generate the Short URL."
+msgstr ""
+
+#: include/options_page.php:176
+msgid ""
+"(Default: \"http://yoursite/?p=123\" or \"http://yoursite/?page_id=123\")"
+msgstr ""
+
+#: include/options_page.php:180
+msgid "Append Short URL to: "
+msgstr ""
+
+#: include/options_page.php:184 include/options_page.php:267
+msgid "Posts (Homepage)"
+msgstr ""
+
+#: include/options_page.php:188 include/options_page.php:271
+msgid "Posts (Individual)"
+msgstr ""
+
+#: include/options_page.php:192 include/options_page.php:275
+msgid "Pages"
+msgstr ""
+
+#: include/options_page.php:196
+msgid "Products"
+msgstr ""
+
+#: include/options_page.php:200
+msgid "Text before Short URL link "
+msgstr ""
+
+#: include/options_page.php:219
+msgid "Nice ID"
+msgstr ""
+
+#: include/options_page.php:223
+msgid "Nice ID URLs"
+msgstr ""
+
+#: include/options_page.php:224
+msgid "(Formally named template_redirection)"
+msgstr ""
+
+#: include/options_page.php:228
+msgid ""
+"Allows usage of \"http://yoursite/123\" instead of \"http://yoursite/?p=123\""
+msgstr ""
+
+#: include/options_page.php:233
+msgid "Nice ID URL Prefix"
+msgstr ""
+
+#: include/options_page.php:237
+msgid ""
+"default: \"/\"  (http://yoursite/123)</span>\n"
+"                        <p>Examples:\n"
+"                            <br />\"<span class=\"red\">prefix/</span>\" = "
+"http://yoursite/<span class=\"red\">prefix/</span>123\n"
+"                            <br />\"<span class=\"red\">prefix-</span>\" = "
+"http://yoursite/<span class=\"red\">prefix-</span>123\n"
+"                        </p>"
+msgstr ""
+
+#: include/options_page.php:246
+msgid "Shortcode"
+msgstr ""
+
+#: include/options_page.php:250
+msgid "Disable Shortcode [urlyar_shortlink]"
+msgstr ""
+
+#: include/options_page.php:255
+msgid "Disables the usage of URL Shortener shortcode [urlyar_shortlink]"
+msgstr ""
+
+#: include/options_page.php:260
+msgid "QR Code"
+msgstr ""
+
+#: include/options_page.php:263
+msgid "Append QR Code to: "
+msgstr ""
+
+#: include/options_page.php:279
+msgid "QR Code Provider "
+msgstr ""
+
+#. Plugin Name of the plugin/theme
+#: include/options_page.php:284 urlyar.php:418
+msgid "URLYar"
+msgstr ""
+
+#: include/options_page.php:289
+msgid "Google"
+msgstr ""
+
+#: include/options_page.php:294
+msgid "Text before QR Code "
+msgstr ""
+
+#: include/options_page.php:353
+msgid "URL Service Configuration"
+msgstr ""
+
+#: include/options_page.php:354
+msgid "Select and configure your desired Short URL service."
+msgstr ""
+
+#: include/options_page.php:355
+msgid ""
+"<span class=\"red\">*</span> are required configurations for that service."
+msgstr ""
+
+#: include/options_page.php:360 include/options_page.php:368
+msgid "Select"
+msgstr ""
+
+#: include/options_page.php:361 include/options_page.php:369
+msgid "Services"
+msgstr ""
+
+#: include/options_page.php:363 include/options_page.php:371
+msgid "Configuration"
+msgstr ""
+
+#: include/options_page.php:409 include/options_page.php:435
+msgid "User/ID"
+msgstr ""
+
+#: include/options_page.php:421
+msgid "Key/API"
+msgstr ""
+
+#: include/options_page.php:438
+msgid "Password"
+msgstr ""
+
+#: include/options_page.php:442
+msgid "URL to the YOURLS API"
+msgstr ""
+
+#: include/options_page.php:451
+msgid "Service/Domain"
+msgstr ""
+
+#: include/options_page.php:485
+msgid "No Configuration Needed"
+msgstr ""
+
+#: include/options_page.php:551
+msgid ""
+"<strong>Service Configuration: </strong>Please fill the required User/ID"
+msgstr ""
+
+#: include/options_page.php:559
+msgid ""
+"<strong>Service Configuration: </strong>Please fill in the required API/Key"
+msgstr ""
+
+#: include/options_page.php:576
+msgid "Save Changes"
+msgstr ""
+
+#: include/options_page_help.php:6
+msgid "More Information"
+msgstr ""
+
+#: include/options_page_help.php:7
+msgid ""
+"Additional information and upgrade notes are available via the plugin's <a "
+"href=\"http://salamzadeh.net/plugins/urlyar/docs/url-shortener-wordpress-"
+"plugin\">Wiki Page</a>"
+msgstr ""
+
+#: include/options_page_help.php:9
+msgid ""
+"Do check out the <a href=\"http://salamzadeh.net/plugins/urlyar/docs/url-"
+"shortener-wordpress-plugin/faq\">FAQ</a> and <a href=\"http://salamzadeh.net/"
+"plugins/urlyar/docs/url-shortener-wordpress-plugin/known-issues\">Known "
+"Issues</a> as well"
+msgstr ""
+
+#: include/options_page_help.php:12
+msgid "Version References"
+msgstr ""
+
+#: include/options_page_help.php:14
+msgid "Plugin Version: "
+msgstr ""
+
+#: include/options_page_help.php:18
+msgid "Shortener Modules"
+msgstr ""
+
+#: include/options_page_help.php:22
+msgid "Name"
+msgstr ""
+
+#: include/options_page_help.php:23
+msgid "Description"
+msgstr ""
+
+#: include/options_page_help.php:24
+msgid "ID"
+msgstr ""
+
+#: include/options_page_help.php:46
+msgid "Support"
+msgstr ""
+
+#: include/options_page_help.php:47
+msgid "You can get support for the plugin via the following channels: "
+msgstr ""
+
+#: include/options_page_help.php:48
+msgid ""
+"<a href=\"http://wordpress.org/tags/url-shortener\">WordPress Support Forum</"
+"a>"
+msgstr ""
+
+#: include/options_page_help.php:49
+msgid "<a href=\"https://www.salamzadeh.net/contact/\">Send me a message</a>"
+msgstr ""
+
+#: include/options_page_help.php:51
+msgid ""
+"If you like this plugin and would like to <a href=\"http://salamzadeh.net/"
+"plugins/urlyar/contribute/\">Contribute</a> back, I'll be very grateful!"
+msgstr ""
+
+#: urlyar.php:388 urlyar.php:452
+msgid "Get Shortlink"
+msgstr ""
+
+#. Plugin URI of the plugin/theme
+msgid "https://salamzadeh.net/plugins/urlyar"
+msgstr ""
+
+#. Description of the plugin/theme
+msgid ""
+"This plugin provides integration of URL Shorteners (e.g. urlyar.ir, trew.ir, "
+"fsda.ir, saqw.ir and what you want)."
+msgstr ""
+
+#. Author of the plugin/theme
+msgid "Sasan Salamzadeh"
+msgstr ""
+
+#. Author URI of the plugin/theme
+msgid "http://www.salamzadeh.net"
+msgstr ""

+ 113 - 0
readme.txt

@@ -0,0 +1,113 @@
+=== URLYar URL Shortner ===
+Contributors: Salamzadeh
+Donate link: http://urlyar.ir/donate
+Tags: urlyar, url-shortener, short url, url, shortlink, shorten, shortener, qr, qr code,
+Requires at least: 3.0.1
+Tested up to: 6.4.0
+Stable tag: trunk
+License: GPLv2 or later
+License URI: http://www.gnu.org/licenses/gpl-2.0.html
+This plugin allows you to generate shortlinks for post/pages using URLYar URL Shorteners
+== Description ==
+
+
+[URLYar URL Shortener](http://salamzadeh.net/plugins/urlyar/ "URLYar URL Shortener") allows you to generate shortlinks for post/pages using URLYar URL Shorteners, with a few additional features.
+
+
+**Features:**
+* Language file as 100% translation now available at wordpress.org
+* Localization - Persian translation added (100% complete)
+* QR Code Support (using Google Chart API Or URLYar QR API)
+* Nice ID links with QR Code (i.e. http://your_site/123.qr)
+* Automatic generation of a Short URL/Shortlinks
+* *Cached Shortlink* - thus generated only once.
+* Choose to generate shortlinks using permalinks or the posts ID (e.g. http://your_site/index.php?p=123).
+* Relatively extensive shortlink support
+* *Action Hooks available* for other plugins to utilize generated shortlinks (From Ver 3.0 Onwards)
+* Nice ID links - http://your_site/123 instead of http://your_site/index.php?p=123
+* Shortcode support: Place [urlyar_shortlink] in your article where you want to display the shortened url.
+* Append a link to short URL below your post content
+* Append a link to short URL below your page content
+* Append a link to short URL below your woocommerce product content
+
+
+
+
+**Available Template Tags**
+
+On-demand shortening function:
+
+`<?php urlyar_shorturl('http://www.wpnegar.com', 'urlyar'); ?>`
+
+To show the generated links::
+
+`<?php urlyar_show_shorturl($post); ?>`
+
+Or if WordPress 3.0:
+
+`<?php the_shortlink(); ?>`
+
+http://codex.wordpress.org/Function_Reference/the_shortlink
+
+
+**Available hooks and filters**
+
+*  urlyar_use_shortlink (Action Hook)
+*  urlyar_filter_shortlink (Filter)
+
+
+**Future Versions and on:**
+
+*  More services/features can be added upon request (https://salamzadeh.net/plugins/urlyar)
+
+**Support via:**
+
+*  http://wordpress.org/tags/url-shortener
+*  Contact me via my website ( https://salamzadeh.net/contact/ )
+
+== Installation ==
+
+1. Upload files to your `/wp-content/plugins/` directory (preserve sub-directory structure if applicable)
+1. Activate the plugin through the 'Plugins' menu in WordPress
+
+Or
+
+1. Within your WordPress admin, go to plugins > add new
+1. Search for "URLYar URL Shortener".
+1. Click Install Now for the plugin named "URLYar URL Shortener"
+
+== Frequently Asked Questions ==
+= What's Service Provider URL =
+Supported service provider is urlyar.ir
+you can register and use this services always free from (http://urlyar.ir/?lang=en) url
+URLYar is Free and Always Will Be
+
+== Screenshots ==
+
+https://salamzadeh.net/plugins/urlyar
+
+== Changelog ==
+
+Expanded list can be found at: http://salamzadeh.net/plugins/urlyar/release-history
+= 1.1.0 =
+* Connect to new version API's
+* Update to support new version of Wordpress
+
+= 1.0.5 =
+* Language file as 100% translation now available at wordpress.org
+* Localization - Persian translation added (100% complete)
+* Woocommerce Products support
+
+= 1.0 =
+* First Public Release
+* Added simple validation to options page
+
+= 0.5 =
+* Initial Private release.
+* supports URLYar
+
+== Upgrade Notice ==
+
+For those upgrading from a version prior to 1.0, please check your settings as Version 1.0 has options code that was re-written.
+
+Read More: http://salamzadeh.net/plugins/urlyar/upgrade-notes

BIN
urlyar-logo.jpg


+ 770 - 0
urlyar.php

@@ -0,0 +1,770 @@
+<?php
+/*
+Plugin Name: URLYar
+Plugin URI: https://salamzadeh.net/plugins/urlyar
+Description: This plugin provides integration of URL Shorteners (e.g. urlyar.ir, trew.ir, fsda.ir, saqw.ir and what you want).
+Author: Sasan Salamzadeh
+Author URI: http://www.salamzadeh.net
+Text Domain: url-shortener
+Version: 1.1.0
+*/
+
+
+if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+
+define('URLYAR_URL_SHORTENER_VERSION', '1.1.0');
+define('URLYAR_URL_SHORTENER_STATUS', 'stable');
+
+
+/*
+ *****************************************
+ *
+ *	Dependencies
+ *
+ *****************************************
+ */
+
+if (!class_exists('ss_options')) :
+    include(dirname(__FILE__) . '/include/class.ss_options.php');
+endif;
+
+if (!class_exists('ss_shortener')) :
+    include(dirname(__FILE__) . '/include/class.ss_shortener.php');
+endif;
+
+
+/**
+ * Load plugin textdomain.
+ *
+ * @since 1.0.0
+ */
+function urlyar_load_textdomain() {
+    load_plugin_textdomain( 'url-shortener', null, basename( dirname( __FILE__ ) ) . '/languages' );
+}
+add_action( 'init', 'urlyar_load_textdomain' );
+
+
+/*
+ *****************************************
+ *
+ *	Main Class Declaration
+ *
+ *****************************************
+ */
+
+if (!class_exists('URLYAR_URL_Shortener')) :
+    class URLYAR_URL_Shortener
+    {
+
+
+        /*
+         *****************************************
+         *
+         *	Class Variables
+         *
+         *****************************************
+         */
+
+
+        private $plugin_version,
+            $plugin_status,
+            $plugin_option,            //(global) plugin options
+            $plugin_url,
+            $plugin_page,            //options page
+            $shortener,                //(global) shared shortener assignment
+            $shortener_modules;        //available modules for shortener
+
+
+        /*
+         *****************************************
+         *
+         *	Constructors
+         *
+         *****************************************
+         */
+
+
+        //php 5.3.3
+        function __construct($version = '0.0', $status = 'dev')
+        {
+            $this->URLYAR_URL_Shortener($version, $status);
+        }
+
+        //backward compatibility
+        function URLYAR_URL_Shortener($version = '0.0', $status = 'dev')
+        {
+            $this->plugin_version = $version;
+            $this->plugin_status = $status;
+
+            $this->plugin_option = new ss_options('urlyar_urlfx', $this->plugin_version, $this->plugin_status);
+            $this->shortener = new ss_shortener($this->plugin_status);
+            $this->shortener_modules = $this->shortener->get_modules();
+        }
+
+
+
+
+        /*
+         *****************************************
+         *
+         *	Plugin Activation Calls
+         *
+         *****************************************
+         */
+
+        //hooks and loaders
+        public function activate_shortener()
+        {
+            $this->plugin_url = defined('WP_PLUGIN_URL') ? WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) : trailingslashit(get_bloginfo('wpurl')) . PLUGINDIR . '/' . dirname(plugin_basename(__FILE__));
+
+            if ($this->plugin_option->get('urlserviceenable') == 'yes') {
+                //FX registration mirrors WP stats plugin
+                if (!function_exists('wp_get_shortlink')) {
+                    //Register these only for WP < 3.0.
+                    add_action('wp_head', array(&$this, 'urlyar_shortlink_wp_head'));
+                    add_action('wp', array(&$this, 'urlyar_shortlink_header'));
+
+
+                    //edit post-page button
+                    if ($this->check_wp_version(2.9)) {
+                        add_filter('get_sample_permalink_html', array(&$this, 'urlyar_get_shortlink_html'), 10, 2);
+                    }
+
+
+                    //compatibility - remove wp.me
+                    remove_action('wp_head', 'wpme_shortlink_wp_head');
+                    remove_action('wp', 'wpme_shortlink_header');
+                    remove_filter('get_sample_permalink_html', 'wpme_get_shortlink_html', 10, 2);
+
+
+                } else {
+                    //Register a shortlink handler for WP >= 3.0.
+                    add_filter('get_shortlink', array(&$this, 'pub_gateway'), 10, 4);
+                }
+
+
+                //Future to Present
+                add_action('future_to_publish', array(&$this, 'transition_get_shortlink'), 10, 1);
+            }
+
+            //Options
+            add_action('admin_menu', array(&$this, 'plugin_menu'));
+
+
+            //Tables
+            add_filter('post_row_actions', array(&$this, 'table_hover_link'), 10, 2);
+            add_filter('page_row_actions', array(&$this, 'table_hover_link'), 10, 2);
+            add_action('admin_head', array(&$this, 'urlyar_urlshortener_adminhead'));
+            add_action('load-edit.php', array(&$this, 'urlyar_urlshortener_edit_head'));
+            add_action('load-edit-pages.php', array(&$this, 'urlyar_urlshortener_edit_head'));
+
+
+            //AJAX Calls
+            add_action('wp_ajax_urlshortener_act', array(&$this, 'urlyar_urlshortener_ajaxcallback'));
+
+
+            //Nice IDs
+            if ($this->plugin_option->get('niceid') == 'yes') {
+                add_filter('template_redirect', array(&$this, 'template_redirect'), 10, 2);
+            }
+
+
+            //Shortcode
+            if ($this->plugin_option->get('url_shortcode') != 'disable') {
+                add_shortcode('urlyar_shortlink', array(&$this, 'shortcode_support'));
+            }
+
+            //Append Text
+            add_filter('the_content', array(&$this, 'urlyar_filter_append_post'));
+
+            //Append QR Code
+            add_filter('the_content', array(&$this, 'urlyar_filter_append_post_qr'));
+
+
+        }
+
+
+        private function check_wp_version($version, $operator = ">=")
+        {
+            global $wp_version;
+            return version_compare($wp_version, $version, $operator);
+        }
+
+
+        /*
+         *****************************************
+         * Check if shortener loaded. 
+         * Attempt to load it otherwise
+         * Return false when all fails.
+         *****************************************
+         */
+
+        private function shortener_loader()
+        {
+
+            if (!$this->shortener->load_status()) {
+
+                $service = $this->plugin_option->get('urlservice');
+
+                $this->shortener->set_user($this->plugin_option->get('apiuser_' . $service));
+                $this->shortener->set_key($this->plugin_option->get('apikey_' . $service));
+                $this->shortener->set_generic($this->plugin_option->get('generic_' . $service));
+                $this->shortener->set_service($service);
+
+                $result = $this->shortener->init_shortener();
+
+                return ($result == 'OK') ? true : false;
+            }
+
+            return true;
+        }
+
+
+        /*
+         *****************************************
+         * Plugin Installer
+         * Includes setting of default values
+         * Migration Utility for v3.0 Series
+         *****************************************
+         */
+
+        public function install()
+        {
+            $defaults = array(
+                'urlserviceenable' => 'no',
+                'urlservice' => '',
+                'useslug' => 'no',
+                'niceid' => 'no',
+                'niceid_prefix' => '/',
+                'appendurl' => array(
+                    'home ' => 'no',
+                    'single' => 'no',
+                    'page' => 'no',
+                    'product' => 'no',
+                    'text' => 'Short URL:',
+                ),
+                'appendqr' => array(
+                    'home' => 'no',
+                    'single' => 'no',
+                    'page' => 'no',
+                    'product' => 'no',
+                    'text' => '',
+                    'provider' => 'urlyar'
+                ),
+                'url_shortcode' => 'disable',
+            );
+
+            $this->plugin_option->set_default($defaults);
+
+            $this->plugin_option->migrate_options('about_plugin'); //check migration requirement
+            $this->plugin_option->install_options();
+        }
+
+
+
+
+
+
+
+        /*
+         *****************************************
+         *
+         *	Shortlink Generation Main Functions
+         *
+         *****************************************
+         */
+
+
+        /*
+         *****************************************
+         * Automatic shortener
+		 *
+         * Activated during Post Publishing or Post Viewing
+         *****************************************
+         */
+
+        private function pub_get_shortlink($id = 0, $context = 'post', $allow_slugs = true, $transition = false)
+        {
+            include(dirname(__FILE__) . '/include/pub_get_shortlink.php');
+            return $shortlink;
+        }
+
+
+        /*
+         *****************************************
+         * On demand shortener
+		 *
+         * For calls directly from the public.
+         * Shortener allocation must be different from global shortener
+		 * Fallback on default setting if service undefined
+         *****************************************
+         */
+
+        public function od_get_shortlink($url = '', $service = '', $key = '', $user = '')
+        {
+            $shortlink = NULL;
+
+            if (!empty($url)) {
+                $od_shortener = new ss_shortener($this->plugin_status);
+
+                if (empty($service)) {
+
+                    $service = $this->plugin_option->get('urlservice');
+                    $od_shortener->set_user($this->plugin_option->get('apiuser_' . $service));
+                    $od_shortener->set_key($this->plugin_option->get('apikey_' . $service));
+                    $od_shortener->set_generic($this->plugin_option->get('generic_' . $service));
+                    $od_shortener->set_service($service);
+
+                } else {
+
+                    $od_shortener->config($service, $key, $user);
+
+                }
+
+                $status = $od_shortener->init_shortener();
+
+                $shortlink = ($status == 'OK') ? $od_shortener->generate($url) : NULL;
+            }
+
+            return $shortlink;
+        }
+
+
+        /*
+         *****************************************
+         * Status hook for future posts
+         * Hook to ensure generation only during publishing
+         *****************************************
+         */
+        public function transition_get_shortlink($post)
+        {
+            $shortlink = $this->pub_get_shortlink($post->ID, 'post', true, true);
+        }
+
+
+
+
+
+
+        /*
+         *****************************************
+         *
+         *	Publishing CALLBACKS
+         *
+         *****************************************
+         */
+
+
+        //WP >= 3.0
+
+        public function pub_gateway($shortlink, $id, $context, $allow_slugs)
+        {
+            $shortlink = $this->pub_get_shortlink($id, $context, $allow_slugs);
+            return $shortlink;
+        }
+
+        //WP < 3.0 
+        public function urlyar_shortlink_wp_head()
+        {
+            global $wp_query;
+            $shortlink = $this->pub_get_shortlink(0, 'query');
+            if ($shortlink) {
+                echo '<link rel="shortlink" href="' . $shortlink . '" />';
+            }
+        }
+
+        public function urlyar_shortlink_header()
+        {
+            global $wp_query;
+            if (headers_sent())
+                return;
+            $shortlink = $this->pub_get_shortlink(0, 'query');
+            header('Link: <' . $shortlink . '>; rel=shortlink');
+        }
+
+        public function urlyar_get_shortlink_html($html, $post_id)
+        {
+            $shortlink = $this->pub_get_shortlink($post_id);
+            if ($shortlink) {
+                $html .= '<input id="shortlink" type="hidden" value="' . $shortlink . '" /><a href="' . $shortlink . '" class="button" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
+            }
+            return $html;
+        }
+
+
+
+
+
+
+
+
+        /*
+         *****************************************
+         *
+         *	WordPress Admin Pages
+         *
+         *****************************************
+         */
+
+        /*
+         *****************************************
+         * Plugin Options Page
+         *****************************************
+         */
+        public function plugin_menu()
+        {
+            if (!is_admin())
+                return;
+
+            $this->plugin_page = add_options_page(__('URLYar', 'url-shortener'), __('URLYar', 'url-shortener'), 'manage_options', 'shorturl', array(&$this, 'options_page'));
+
+            add_action('load-' . $this->plugin_page, array(&$this, 'options_style_scripts'));
+
+            include(dirname(__FILE__) . '/include/options_page_help.php');
+            add_contextual_help($this->plugin_page, $help_text);
+
+        }
+
+        public function options_page()
+        {
+            if (!is_admin())
+                return;
+
+            $action_url = $_SERVER['REQUEST_URI'];
+            include(dirname(__FILE__) . '/include/options_page.php');
+        }
+
+
+        public function options_style_scripts()
+        {
+            wp_enqueue_style('url_shortener_options_css', $this->plugin_url . '/assets/css/options_page.css');
+        }
+
+
+        /*
+         *****************************************
+         * Table Pages
+         *****************************************
+         */
+        public function table_hover_link($actions, $post)
+        {
+            $shortlink = $this->pub_get_shortlink($post->ID);
+            if ($shortlink) {
+                $actions['shortlink'] = '<a href="' . $shortlink . '" onclick="prompt(&#39;URL:&#39;, jQuery(this).attr(\'href\')); return false;">' . __('Get Shortlink') . '</a>';
+            }
+            return $actions;
+        }
+
+        public function urlyar_urlshortener_adminhead()
+        {
+            ?>
+            <script type="text/javascript">
+                var aaurl = '<?php echo admin_url('admin-ajax.php'); ?>';
+                var nonce = '<?php echo wp_create_nonce('urlshortener_ajax');?>';
+            </script>
+            <?php
+        }
+
+        public function urlyar_urlshortener_edit_head()
+        {
+            wp_enqueue_script('urlyar_surl_ajax', $this->plugin_url . '/assets/js/jquery.ajaxq.js', array('jquery'), 1.0);
+            wp_enqueue_script('urlyar_surl_edit', $this->plugin_url . '/assets/js/tablecol.js', array('jquery'), 1.0);
+        }
+
+
+
+
+
+
+
+
+
+        /*
+         *****************************************
+         *
+         *	AJAX CALLBACKS
+         *
+         *****************************************
+         */
+
+
+        /*
+         *****************************************
+         * Bulk Delete in Table Pages
+         *****************************************
+         */
+        public function urlyar_urlshortener_ajaxcallback()
+        {
+            check_ajax_referer('urlshortener_ajax');
+            $post_id = $_POST['pid'];
+            delete_post_meta($post_id, 'shorturl');
+        }
+
+
+
+
+        /*
+         *****************************************
+         *
+         *	Misc Functions
+         *
+         *****************************************
+         */
+
+
+        /*
+         *****************************************
+         * QR Code Support
+		 * Used in: 
+		 * - Shortcode
+		 * - Template Display
+		 * - Nice ID redirect
+         *****************************************
+
+         */
+        public function get_qrcode($url, $size = '57', $qr_error = 'M', $url_only = false)
+        {
+            $append = $this->plugin_option->get('appendqr');
+            if ($append["provider"] == "google")
+                $link = 'https://chart.googleapis.com/chart?cht=qr&chl=' . $url . '&chs=' . $size . 'x' . $size . '&chld=' . $qr_error;
+            else
+                $link = $url . '/qr?chs=' . $size . 'x' . $size . '&chld=' . $qr_error;
+            return ($url_only) ? $link : '<img class="urlyar-qr-img" width="' . $size . '" height="' . $size . '" src="' . $link . '" alt="" />';
+        }
+
+
+        /*
+         *****************************************
+         * Nice ID URL Redirect
+         *****************************************
+         */
+        public function template_redirect($requested_url = null, $do_redirect = true)
+        {
+
+            global $wp;
+            global $wp_query;
+
+            if (is_404()) {
+                $post_id = '';
+                $request = $wp->request;
+                $qr = false;
+
+                //check for QR Code endings
+                if (substr($request, -3) == '.qr') {
+                    $qr = true;
+                    $request = substr($request, 0, -3);
+                }
+
+                //matching for post id
+                if (preg_match('/(\\d+)/', $request, $matches)) {
+                    $post_id = $matches[0];
+                }
+
+                //determine if still 404
+                if (!empty($post_id) && is_numeric($post_id)) {
+                    $full_url = get_permalink($post_id);
+
+                    if ($full_url) {
+                        if ($qr) {
+                            header('Location: ' . $this->get_qrcode($full_url, 150, 'M', true));
+                            exit();
+                        } else {
+                            status_header(200);
+                            wp_redirect($full_url, 301);
+                            exit();
+                        }
+                    }
+                }
+
+            } //ends is_404 block
+
+        }
+
+
+        /*
+         *****************************************
+         * For use in template to 
+		 * display shorturl
+         *****************************************
+         */
+
+        public function urlyar_get_shortlink_display($post_id)
+        {
+            $shortlink = $this->pub_get_shortlink($post_id);
+            return $shortlink;
+        }
+
+
+        /*
+         *****************************************
+         * Shortcode Support
+         *****************************************
+         */
+
+        public function shortcode_support($atts, $content = null)
+        {
+            extract(shortcode_atts(array(
+                'name' => '',
+                'url' => '',
+                'service' => $this->plugin_option->get('urlservice'),
+                'key' => '',
+                'user' => '',
+                'qr' => false,
+                'size' => '',
+                'qr_error' => '',
+                'full' => false,
+            ), $atts));
+
+            global $post;
+
+            $post_id = $post->ID;
+            $full_url = get_permalink($post_id);
+
+            //Assign URL as content if content not empty
+            if (!empty($content)) {
+                $url = $content;
+            }
+
+
+            //check if url still empty
+            //Get shortlink if url true
+            //Get Post URL and shortlink if false
+            $shortlink = ($url) ? $this->od_get_shortlink($url, $service, $key, $user) :
+                $this->pub_get_shortlink($post_id);
+
+            //output type QR code?
+            if (empty($qr)) {
+
+                $output = '<a href="' . $shortlink . '">';
+                $output .= ($name) ? $name : $shortlink;
+                $output .= '</a>';
+
+            } else {
+
+                //determine if full URL used in QR code
+                $output = ($full) ? '<a href="' . $full_url . '">' . $this->get_qrcode($full_url, $size, $qr_error) . '</a>' :
+                    '<a href="' . $shortlink . '">' . $this->get_qrcode($shortlink, $size, $qr_error) . '</a>';
+            }
+
+            return $output;
+
+        }
+
+
+        /*
+         *****************************************
+         * Append Shortlink to content
+         *****************************************
+         */
+
+        public function urlyar_filter_append_post($content)
+        {
+            global $post;
+            $append = $this->plugin_option->get('appendurl');
+
+            if ((is_home() && $append['home'] == 'yes') ||
+                (is_single() && $append['single'] == 'yes') ||
+                (is_single() && $append['product'] == 'yes') ||
+                (is_page() && $append['page'] == 'yes')
+            ) {
+
+                $shortlink = $this->pub_get_shortlink($post->ID);
+                $content .= '<div class="urlyar-shortlink"><strong>' . $append['text'] . '</strong> <a class="urlyar-link" href="' . $shortlink . '">' . $shortlink . '</a></div>';
+            }
+            return $content;
+        }
+
+
+        /*
+         *****************************************
+         * Append QR Code to content
+         *****************************************
+         */
+        public function urlyar_filter_append_post_qr($content)
+        {
+            global $post;
+            $append = $this->plugin_option->get('appendqr');
+
+            if ((is_home() && $append['home'] == 'yes') ||
+                (is_single() && $append['single'] == 'yes') ||
+                (is_single() && $append['product'] == 'yes') ||
+                (is_page() && $append['page'] == 'yes')
+            ) {
+
+                $shortlink = $this->pub_get_shortlink($post->ID);
+                $content .= '<div class="urlyar-qr">';
+                $content .= (!empty($append['text'])) ? '<strong>' . $append['text'] . '</strong>' : '';
+                $content .= $this->get_qrcode($shortlink, 150) . '</div>';
+            }
+            return $content;
+        }
+
+
+//end class
+    }
+endif;
+
+
+/*
+ *****************************************
+ *
+ *	WordPress Call to
+ *	Initialize and Activate Object
+ *
+ *****************************************
+ */
+if (class_exists('URLYAR_URL_Shortener')) :
+
+
+    /*
+     *****************************************
+     * Plugin Activation and assignments
+     *****************************************
+     */
+    global $URLYAR_URL_Shortener;
+    $URLYAR_URL_Shortener = new URLYAR_URL_Shortener(URLYAR_URL_SHORTENER_VERSION, URLYAR_URL_SHORTENER_STATUS);
+    $URLYAR_URL_Shortener->activate_shortener();
+
+    if (isset($URLYAR_URL_Shortener)) {
+        register_activation_hook(__FILE__, array(&$URLYAR_URL_Shortener, 'install'));
+    }
+
+
+    /*
+     *****************************************
+     * Backward compatibility (template) functions
+     *****************************************
+     */
+
+    //Show URL
+    function urlyar_show_shorturl($post, $output = true)
+    {
+        global $URLYAR_URL_Shortener;
+
+        $post_id = $post->ID;
+        $shorturl = $URLYAR_URL_Shortener->urlyar_get_shortlink_display($post_id);
+
+        if ($output) {
+            echo $shorturl;
+        } else {
+            return $shorturl;
+        }
+    }
+
+    //On-demand URL Shortener
+    function urlyar_shorturl($url, $service, $output = true, $key = '', $user = '')
+    {
+        global $URLYAR_URL_Shortener;
+
+        $shorturl = $URLYAR_URL_Shortener->od_get_shortlink($url, $service, $key, $user);
+
+        if ($output) {
+            echo $shorturl;
+        } else {
+            return $shorturl;
+        }
+    }
+
+
+endif;
+?>