Post Views Counter - Version 1.0.0

Version Description

Initial release

=

Download this release

Release Info

Developer dfactory
Plugin Icon 128x128 Post Views Counter
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

assets/chosen/chosen-sprite.png ADDED
Binary file
assets/chosen/chosen-sprite@2x.png ADDED
Binary file
assets/chosen/chosen.jquery.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /* Chosen v1.1.0 | (c) 2011-2013 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
2
+ !function(){var a,AbstractChosen,Chosen,SelectParser,b,c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(a){return"OPTGROUP"===a.nodeName.toUpperCase()?this.add_group(a):this.add_option(a)},SelectParser.prototype.add_group=function(a){var b,c,d,e,f,g;for(b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:this.escapeExpression(a.label),children:0,disabled:a.disabled}),f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},SelectParser.prototype.add_option=function(a,b,c){return"OPTION"===a.nodeName.toUpperCase()?(""!==a.text?(null!=b&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1):void 0},SelectParser.prototype.escapeExpression=function(a){var b,c;return null==a||a===!1?"":/[\&\<\>\"\'\`]/.test(a)?(b={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&amp;"})):a},SelectParser}(),SelectParser.select_to_array=function(a){var b,c,d,e,f;for(c=new SelectParser,f=a.childNodes,d=0,e=f.length;e>d;d++)b=f[d],c.add_node(b);return c.parsed},AbstractChosen=function(){function AbstractChosen(a,b){this.form_field=a,this.options=null!=b?b:{},AbstractChosen.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers())}return AbstractChosen.prototype.set_default_values=function(){var a=this;return this.click_test_action=function(b){return a.test_active_click(b)},this.activate_action=function(b){return a.activate_field(b)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null!=this.options.enable_split_word_search?this.options.enable_split_word_search:!0,this.group_search=null!=this.options.group_search?this.options.group_search:!0,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null!=this.options.single_backstroke_delete?this.options.single_backstroke_delete:!0,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null!=this.options.display_selected_options?this.options.display_selected_options:!0,this.display_disabled_options=null!=this.options.display_disabled_options?this.options.display_disabled_options:!0},AbstractChosen.prototype.set_default_text=function(){return this.default_text=this.form_field.getAttribute("data-placeholder")?this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.options.placeholder_text_multiple||this.options.placeholder_text||AbstractChosen.default_multiple_text:this.options.placeholder_text_single||this.options.placeholder_text||AbstractChosen.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||AbstractChosen.default_no_result_text},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(){var a=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return a.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(){var a=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return a.blur_test()},100))},AbstractChosen.prototype.results_option_build=function(a){var b,c,d,e,f;for(b="",f=this.results_data,d=0,e=f.length;e>d;d++)c=f[d],b+=c.group?this.result_add_group(c):this.result_add_option(c),(null!=a?a.first:void 0)&&(c.selected&&this.is_multiple?this.choice_build(c):c.selected&&!this.is_multiple&&this.single_set_selected_text(c.text));return b},AbstractChosen.prototype.result_add_option=function(a){var b,c;return a.search_match?this.include_option_in_results(a)?(b=[],a.disabled||a.selected&&this.is_multiple||b.push("active-result"),!a.disabled||a.selected&&this.is_multiple||b.push("disabled-result"),a.selected&&b.push("result-selected"),null!=a.group_array_index&&b.push("group-option"),""!==a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.style.cssText=a.style,c.setAttribute("data-option-array-index",a.array_index),c.innerHTML=a.search_text,this.outerHTML(c)):"":""},AbstractChosen.prototype.result_add_group=function(a){var b;return a.search_match||a.group_match?a.active_options>0?(b=document.createElement("li"),b.className="group-result",b.innerHTML=a.search_text,this.outerHTML(b)):"":""},AbstractChosen.prototype.results_update_field=function(){return this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing?this.winnow_results():void 0},AbstractChosen.prototype.reset_single_select_options=function(){var a,b,c,d,e;for(d=this.results_data,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.selected?e.push(a.selected=!1):e.push(void 0);return e},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m;for(this.no_results_clear(),e=0,g=this.get_search_text(),a=g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),d=this.search_contains?"":"^",c=new RegExp(d+a,"i"),j=new RegExp(a,"i"),m=this.results_data,k=0,l=m.length;l>k;k++)b=m[k],b.search_match=!1,f=null,this.include_option_in_results(b)&&(b.group&&(b.group_match=!1,b.active_options=0),null!=b.group_array_index&&this.results_data[b.group_array_index]&&(f=this.results_data[b.group_array_index],0===f.active_options&&f.search_match&&(e+=1),f.active_options+=1),(!b.group||this.group_search)&&(b.search_text=b.group?b.label:b.html,b.search_match=this.search_string_match(b.search_text,c),b.search_match&&!b.group&&(e+=1),b.search_match?(g.length&&(h=b.search_text.search(j),i=b.search_text.substr(0,h+g.length)+"</em>"+b.search_text.substr(h+g.length),b.search_text=i.substr(0,h)+"<em>"+i.substr(h)),null!=f&&(f.group_match=!0)):null!=b.group_array_index&&this.results_data[b.group_array_index].search_match&&(b.search_match=!0)));return this.result_clear_highlight(),1>e&&g.length?(this.update_results_content(""),this.no_results(g)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},AbstractChosen.prototype.search_string_match=function(a,b){var c,d,e,f;if(b.test(a))return!0;if(this.enable_split_word_search&&(a.indexOf(" ")>=0||0===a.indexOf("["))&&(d=a.replace(/\[|\]/g,"").split(" "),d.length))for(e=0,f=d.length;f>e;e++)if(c=d[e],b.test(c))return!0},AbstractChosen.prototype.choices_count=function(){var a,b,c,d;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,d=this.form_field.options,b=0,c=d.length;c>b;b++)a=d[b],a.selected&&(this.selected_option_count+=1);return this.selected_option_count},AbstractChosen.prototype.choices_click=function(a){return a.preventDefault(),this.results_showing||this.is_disabled?void 0:this.results_show()},AbstractChosen.prototype.keyup_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:if(a.preventDefault(),this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},AbstractChosen.prototype.clipboard_event_checker=function(){var a=this;return setTimeout(function(){return a.results_search()},50)},AbstractChosen.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},AbstractChosen.prototype.include_option_in_results=function(a){return this.is_multiple&&!this.display_selected_options&&a.selected?!1:!this.display_disabled_options&&a.disabled?!1:a.empty?!1:!0},AbstractChosen.prototype.search_results_touchstart=function(a){return this.touch_started=!0,this.search_results_mouseover(a)},AbstractChosen.prototype.search_results_touchmove=function(a){return this.touch_started=!1,this.search_results_mouseout(a)},AbstractChosen.prototype.search_results_touchend=function(a){return this.touch_started?this.search_results_mouseup(a):void 0},AbstractChosen.prototype.outerHTML=function(a){var b;return a.outerHTML?a.outerHTML:(b=document.createElement("div"),b.appendChild(a),b.innerHTML)},AbstractChosen.browser_is_supported=function(){return"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:!0},AbstractChosen.default_multiple_text="Select Some Options",AbstractChosen.default_single_text="Select an Option",AbstractChosen.default_no_result_text="No results match",AbstractChosen}(),a=jQuery,a.fn.extend({chosen:function(b){return AbstractChosen.browser_is_supported()?this.each(function(){var c,d;c=a(this),d=c.data("chosen"),"destroy"===b&&d?d.destroy():d||c.data("chosen",new Chosen(this,b))}):this}}),Chosen=function(c){function Chosen(){return b=Chosen.__super__.constructor.apply(this,arguments)}return d(Chosen,c),Chosen.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex,this.is_rtl=this.form_field_jq.hasClass("chosen-rtl")},Chosen.prototype.set_up_html=function(){var b,c;return b=["chosen-container"],b.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&b.push(this.form_field.className),this.is_rtl&&b.push("chosen-rtl"),c={"class":b.join(" "),style:"width: "+this.container_width()+";",title:this.form_field.title},this.form_field.id.length&&(c.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=a("<div />",c),this.is_multiple?this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>'):this.container.html('<a class="chosen-single chosen-default" tabindex="-1"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>'),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior(),this.form_field_jq.trigger("chosen:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var a=this;return this.container.bind("mousedown.chosen",function(b){a.container_mousedown(b)}),this.container.bind("mouseup.chosen",function(b){a.container_mouseup(b)}),this.container.bind("mouseenter.chosen",function(b){a.mouse_enter(b)}),this.container.bind("mouseleave.chosen",function(b){a.mouse_leave(b)}),this.search_results.bind("mouseup.chosen",function(b){a.search_results_mouseup(b)}),this.search_results.bind("mouseover.chosen",function(b){a.search_results_mouseover(b)}),this.search_results.bind("mouseout.chosen",function(b){a.search_results_mouseout(b)}),this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen",function(b){a.search_results_mousewheel(b)}),this.search_results.bind("touchstart.chosen",function(b){a.search_results_touchstart(b)}),this.search_results.bind("touchmove.chosen",function(b){a.search_results_touchmove(b)}),this.search_results.bind("touchend.chosen",function(b){a.search_results_touchend(b)}),this.form_field_jq.bind("chosen:updated.chosen",function(b){a.results_update_field(b)}),this.form_field_jq.bind("chosen:activate.chosen",function(b){a.activate_field(b)}),this.form_field_jq.bind("chosen:open.chosen",function(b){a.container_mousedown(b)}),this.form_field_jq.bind("chosen:close.chosen",function(b){a.input_blur(b)}),this.search_field.bind("blur.chosen",function(b){a.input_blur(b)}),this.search_field.bind("keyup.chosen",function(b){a.keyup_checker(b)}),this.search_field.bind("keydown.chosen",function(b){a.keydown_checker(b)}),this.search_field.bind("focus.chosen",function(b){a.input_focus(b)}),this.search_field.bind("cut.chosen",function(b){a.clipboard_event_checker(b)}),this.search_field.bind("paste.chosen",function(b){a.clipboard_event_checker(b)}),this.is_multiple?this.search_choices.bind("click.chosen",function(b){a.choices_click(b)}):this.container.bind("click.chosen",function(a){a.preventDefault()})},Chosen.prototype.destroy=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},Chosen.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field_jq[0].disabled,this.is_disabled?(this.container.addClass("chosen-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus.chosen",this.activate_action),this.close_field()):(this.container.removeClass("chosen-disabled"),this.search_field[0].disabled=!1,this.is_multiple?void 0:this.selected_item.bind("focus.chosen",this.activate_action))},Chosen.prototype.container_mousedown=function(b){return this.is_disabled||(b&&"mousedown"===b.type&&!this.results_showing&&b.preventDefault(),null!=b&&a(b.target).hasClass("search-choice-close"))?void 0:(this.active_field?this.is_multiple||!b||a(b.target)[0]!==this.selected_item[0]&&!a(b.target).parents("a.chosen-single").length||(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(this.container[0].ownerDocument).bind("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},Chosen.prototype.container_mouseup=function(a){return"ABBR"!==a.target.nodeName||this.is_disabled?void 0:this.results_reset(a)},Chosen.prototype.search_results_mousewheel=function(a){var b;return a.originalEvent&&(b=-a.originalEvent.wheelDelta||a.originalEvent.detail),null!=b?(a.preventDefault(),"DOMMouseScroll"===a.type&&(b=40*b),this.search_results.scrollTop(b+this.search_results.scrollTop())):void 0},Chosen.prototype.blur_test=function(){return!this.active_field&&this.container.hasClass("chosen-container-active")?this.close_field():void 0},Chosen.prototype.close_field=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},Chosen.prototype.test_active_click=function(b){var c;return c=a(b.target).closest(".chosen-container"),c.length&&this.container[0]===c[0]?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=SelectParser.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},Chosen.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){if(this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight(),b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(f>c)return this.search_results.scrollTop(c)}},Chosen.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},Chosen.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))},Chosen.prototype.update_results_content=function(a){return this.search_results.html(a)},Chosen.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},Chosen.prototype.set_tab_index=function(){var a;return this.form_field.tabIndex?(a=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=a):void 0},Chosen.prototype.set_label_behavior=function(){var b=this;return this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=a("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0?this.form_field_label.bind("click.chosen",function(a){return b.is_multiple?b.container_mousedown(a):b.activate_field()}):void 0},Chosen.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))},Chosen.prototype.search_results_mouseup=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c.length?(this.result_highlight=c,this.result_select(b),this.search_field.focus()):void 0},Chosen.prototype.search_results_mouseover=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c?this.result_do_highlight(c):void 0},Chosen.prototype.search_results_mouseout=function(b){return a(b.target).hasClass("active-result")?this.result_clear_highlight():void 0},Chosen.prototype.choice_build=function(b){var c,d,e=this;return c=a("<li />",{"class":"search-choice"}).html("<span>"+b.html+"</span>"),b.disabled?c.addClass("search-choice-disabled"):(d=a("<a />",{"class":"search-choice-close","data-option-array-index":b.array_index}),d.bind("click.chosen",function(a){return e.choice_destroy_link_click(a)}),c.append(d)),this.search_container.before(c)},Chosen.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),b.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(a(b.target))},Chosen.prototype.choice_destroy=function(a){return this.result_deselect(a[0].getAttribute("data-option-array-index"))?(this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.search_field.val().length<1&&this.results_hide(),a.parents("li").first().remove(),this.search_field_scale()):void 0},Chosen.prototype.results_reset=function(){return this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change"),this.active_field?this.results_hide():void 0},Chosen.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},Chosen.prototype.result_select=function(a){var b,c;return this.result_highlight?(b=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?b.removeClass("active-result"):this.reset_single_select_options(),c=this.results_data[b[0].getAttribute("data-option-array-index")],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(c):this.single_set_selected_text(c.text),(a.metaKey||a.ctrlKey)&&this.is_multiple||this.results_hide(),this.search_field.val(""),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[c.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,this.search_field_scale())):void 0},Chosen.prototype.single_set_selected_text=function(a){return null==a&&(a=this.default_text),a===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").text(a)},Chosen.prototype.result_deselect=function(a){var b;return b=this.results_data[a],this.form_field.options[b.options_index].disabled?!1:(b.selected=!1,this.form_field.options[b.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[b.options_index].value}),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){return this.allow_single_deselect?(this.selected_item.find("abbr").length||this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'),this.selected_item.addClass("chosen-single-with-deselect")):void 0},Chosen.prototype.get_search_text=function(){return this.search_field.val()===this.default_text?"":a("<div/>").text(a.trim(this.search_field.val())).html()},Chosen.prototype.winnow_results_set_highlight=function(){var a,b;return b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first(),null!=a?this.result_do_highlight(a):void 0},Chosen.prototype.no_results=function(b){var c;return c=a('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),c.find("span").first().html(b),this.search_results.append(c),this.form_field_jq.trigger("chosen:no_results",{chosen:this})},Chosen.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},Chosen.prototype.keydown_arrow=function(){var a;return this.results_showing&&this.result_highlight?(a=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(a):void 0:this.results_show()},Chosen.prototype.keyup_arrow=function(){var a;return this.results_showing||this.is_multiple?this.result_highlight?(a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},Chosen.prototype.keydown_backstroke=function(){var a;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(a=this.search_container.siblings("li.search-choice").last(),a.length&&!a.hasClass("search-choice-disabled")?(this.pending_backstroke=a,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0)},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),8!==b&&this.pending_backstroke&&this.clear_backstroke(),b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:a.preventDefault(),this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){for(d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"],i=0,j=g.length;j>i;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";return b=a("<div />",{style:f}),b.text(this.search_field.val()),a("body").append(b),h=b.width()+25,b.remove(),c=this.container.outerWidth(),h>c-10&&(h=c-10),this.search_field.css({width:h+"px"})}},Chosen}(AbstractChosen)}.call(this);
assets/chosen/chosen.min.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ /* Chosen v1.1.0 | (c) 2011-2013 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
2
+
3
+ .chosen-container{position:relative;display:inline-block;vertical-align:middle;font-size:13px;zoom:1;*display:inline;-webkit-user-select:none;-moz-user-select:none;user-select:none}.chosen-container .chosen-drop{position:absolute;top:100%;left:-9999px;z-index:1010;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;border:1px solid #aaa;border-top:0;background:#fff;box-shadow:0 4px 5px rgba(0,0,0,.15)}.chosen-container.chosen-with-drop .chosen-drop{left:0}.chosen-container a{cursor:pointer}.chosen-container-single .chosen-single{position:relative;display:block;overflow:hidden;padding:0 0 0 8px;height:23px;border:1px solid #aaa;border-radius:5px;background-color:#fff;background:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#fff),color-stop(50%,#f6f6f6),color-stop(52%,#eee),color-stop(100%,#f4f4f4));background:-webkit-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-moz-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-o-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background-clip:padding-box;box-shadow:0 0 3px #fff inset,0 1px 1px rgba(0,0,0,.1);color:#444;text-decoration:none;white-space:nowrap;line-height:24px}.chosen-container-single .chosen-default{color:#999}.chosen-container-single .chosen-single span{display:block;overflow:hidden;margin-right:26px;text-overflow:ellipsis;white-space:nowrap}.chosen-container-single .chosen-single-with-deselect span{margin-right:38px}.chosen-container-single .chosen-single abbr{position:absolute;top:6px;right:26px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-single .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single.chosen-disabled .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single .chosen-single div{position:absolute;top:0;right:0;display:block;width:18px;height:100%}.chosen-container-single .chosen-single div b{display:block;width:100%;height:100%;background:url(chosen-sprite.png) no-repeat 0 2px}.chosen-container-single .chosen-search{position:relative;z-index:1010;margin:0;padding:3px 4px;white-space:nowrap}.chosen-container-single .chosen-search input[type=text]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin:1px 0;padding:4px 20px 4px 5px;width:100%;height:auto;outline:0;border:1px solid #aaa;background:#fff url(chosen-sprite.png) no-repeat 100% -20px;background:url(chosen-sprite.png) no-repeat 100% -20px;font-size:1em;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-single .chosen-drop{margin-top:-1px;border-radius:0 0 4px 4px;background-clip:padding-box}.chosen-container-single.chosen-container-single-nosearch .chosen-search{position:absolute;left:-9999px}.chosen-container .chosen-results{position:relative;overflow-x:hidden;overflow-y:auto;margin:0 4px 4px 0;padding:0 0 0 4px;max-height:240px;-webkit-overflow-scrolling:touch}.chosen-container .chosen-results li{display:none;margin:0;padding:5px 6px;list-style:none;line-height:15px;-webkit-touch-callout:none}.chosen-container .chosen-results li.active-result{display:list-item;cursor:pointer}.chosen-container .chosen-results li.disabled-result{display:list-item;color:#ccc;cursor:default}.chosen-container .chosen-results li.highlighted{background-color:#3875d7;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#3875d7),color-stop(90%,#2a62bc));background-image:-webkit-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-moz-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-o-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:linear-gradient(#3875d7 20%,#2a62bc 90%);color:#fff}.chosen-container .chosen-results li.no-results{display:list-item;background:#f4f4f4}.chosen-container .chosen-results li.group-result{display:list-item;font-weight:700;cursor:default}.chosen-container .chosen-results li.group-option{padding-left:15px}.chosen-container .chosen-results li em{font-style:normal;text-decoration:underline}.chosen-container-multi .chosen-choices{position:relative;overflow:hidden;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin:0;padding:0;width:100%;height:auto!important;height:1%;border:1px solid #aaa;background-color:#fff;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(1%,#eee),color-stop(15%,#fff));background-image:-webkit-linear-gradient(#eee 1%,#fff 15%);background-image:-moz-linear-gradient(#eee 1%,#fff 15%);background-image:-o-linear-gradient(#eee 1%,#fff 15%);background-image:linear-gradient(#eee 1%,#fff 15%);cursor:text}.chosen-container-multi .chosen-choices li{float:left;list-style:none}.chosen-container-multi .chosen-choices li.search-field{margin:0;padding:0;white-space:nowrap}.chosen-container-multi .chosen-choices li.search-field input[type=text]{margin:1px 0;padding:5px;height:15px;outline:0;border:0!important;background:transparent!important;box-shadow:none;color:#666;font-size:100%;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-multi .chosen-choices li.search-field .default{color:#999}.chosen-container-multi .chosen-choices li.search-choice{position:relative;margin:3px 0 3px 5px;padding:3px 20px 3px 5px;border:1px solid #aaa;border-radius:3px;background-color:#e4e4e4;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-clip:padding-box;box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05);color:#333;line-height:13px;cursor:default}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close{position:absolute;top:4px;right:3px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover{background-position:-42px -10px}.chosen-container-multi .chosen-choices li.search-choice-disabled{padding-right:5px;border:1px solid #ccc;background-color:#e4e4e4;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);color:#666}.chosen-container-multi .chosen-choices li.search-choice-focus{background:#d4d4d4}.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close{background-position:-42px -10px}.chosen-container-multi .chosen-results{margin:0;padding:0}.chosen-container-multi .chosen-drop .result-selected{display:list-item;color:#ccc;cursor:default}.chosen-container-active .chosen-single{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active.chosen-with-drop .chosen-single{border:1px solid #aaa;-moz-border-radius-bottomright:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;border-bottom-left-radius:0;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#eee),color-stop(80%,#fff));background-image:-webkit-linear-gradient(#eee 20%,#fff 80%);background-image:-moz-linear-gradient(#eee 20%,#fff 80%);background-image:-o-linear-gradient(#eee 20%,#fff 80%);background-image:linear-gradient(#eee 20%,#fff 80%);box-shadow:0 1px 0 #fff inset}.chosen-container-active.chosen-with-drop .chosen-single div{border-left:0;background:transparent}.chosen-container-active.chosen-with-drop .chosen-single div b{background-position:-18px 2px}.chosen-container-active .chosen-choices{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active .chosen-choices li.search-field input[type=text]{color:#111!important}.chosen-disabled{opacity:.5!important;cursor:default}.chosen-disabled .chosen-single{cursor:default}.chosen-disabled .chosen-choices .search-choice .search-choice-close{cursor:default}.chosen-rtl{text-align:right}.chosen-rtl .chosen-single{overflow:visible;padding:0 8px 0 0}.chosen-rtl .chosen-single span{margin-right:0;margin-left:26px;direction:rtl}.chosen-rtl .chosen-single-with-deselect span{margin-left:38px}.chosen-rtl .chosen-single div{right:auto;left:3px}.chosen-rtl .chosen-single abbr{right:auto;left:26px}.chosen-rtl .chosen-choices li{float:right}.chosen-rtl .chosen-choices li.search-field input[type=text]{direction:rtl}.chosen-rtl .chosen-choices li.search-choice{margin:3px 5px 3px 0;padding:3px 5px 3px 19px}.chosen-rtl .chosen-choices li.search-choice .search-choice-close{right:auto;left:4px}.chosen-rtl.chosen-container-single-nosearch .chosen-search,.chosen-rtl .chosen-drop{left:9999px}.chosen-rtl.chosen-container-single .chosen-results{margin:0 0 4px 4px;padding:0 4px 0 0}.chosen-rtl .chosen-results li.group-option{padding-right:15px;padding-left:0}.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div{border-right:0}.chosen-rtl .chosen-search input[type=text]{padding:4px 5px 4px 20px;background:#fff url(chosen-sprite.png) no-repeat -30px -20px;background:url(chosen-sprite.png) no-repeat -30px -20px;direction:rtl}.chosen-rtl.chosen-container-single .chosen-single div b{background-position:6px 2px}.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b{background-position:-12px 2px}@media only screen and (-webkit-min-device-pixel-ratio:2),only screen and (min-resolution:144dpi){.chosen-rtl .chosen-search input[type=text],.chosen-container-single .chosen-single abbr,.chosen-container-single .chosen-single div b,.chosen-container-single .chosen-search input[type=text],.chosen-container-multi .chosen-choices .search-choice .search-choice-close,.chosen-container .chosen-results-scroll-down span,.chosen-container .chosen-results-scroll-up span{background-image:url(chosen-sprite@2x.png)!important;background-size:52px 37px!important;background-repeat:no-repeat!important}}
css/admin.css ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Post Views Counter settings */
2
+ .post-views-counter-settings { margin-right: 300px; }
3
+ .post-views-counter-settings form { float: left; min-width: 463px; width: auto; }
4
+ .post-views-counter-settings fieldset .description { font-size: 13px; margin-bottom: 8px; margin-top: 4px; display: block; }
5
+ .post-views-counter-settings .chosen-container { margin: 0.25em 0 0.5em; }
6
+ .post-views-counter-settings .chosen-container-multi .chosen-choices li.search-field input[type="text"] { font-family: inherit; height: inherit; line-height: 1em; margin: 0; }
7
+ .post-views-counter-settings p.help, .post-views-counter-settings p.description, .post-views-counter-settings span.description { font-size: 13px; font-style: italic; }
8
+ .post-views-counter-settings div.ip-box { margin-bottom: 3px; }
9
+
10
+ .df-credits { float: right; width: 280px; background: #fff; margin: 20px -300px 20px 20px; position: relative; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05); }
11
+ .df-credits .inner { padding-left: 10px; padding-right: 10px; }
12
+ .df-credits h3 { font-size: 14px; line-height: 1.4; margin: 0; padding: 8px 12px; border-bottom: 1px solid #eee; }
13
+ .df-credits .df-link { font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; font-style:italic; padding-bottom: 10px; margin: 0; }
14
+ .df-credits .df-link a { vertical-align: middle; padding: 5px 0 0 4px; }
15
+ .df-credits hr { border: solid #eee; border-width: 1px 0 0; clear: both; height: 0; }
css/frontend.css ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ .post-views.entry-meta > span {
2
+ margin-right: 0!important;
3
+ font: 16px/1;
4
+ }
5
+ .post-views.entry-meta > span.post-views-icon.dashicons {
6
+ display: inline-block;
7
+ font-size: 16px;
8
+ line-height: 1;
9
+ text-decoration: inherit;
10
+ vertical-align: middle;
11
+ }
images/logo-dfactory.png ADDED
Binary file
includes/columns.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(!defined('ABSPATH')) exit;
3
+
4
+ new Post_Views_Counter_Columns();
5
+
6
+ class Post_Views_Counter_Columns
7
+ {
8
+ public function __construct()
9
+ {
10
+ // actions
11
+ add_action('current_screen', array(&$this, 'register_new_column'));
12
+ }
13
+
14
+
15
+ /**
16
+ *
17
+ */
18
+ public function register_new_column()
19
+ {
20
+ $screen = get_current_screen();
21
+
22
+ if(Post_Views_Counter()->get_attribute('options', 'general', 'post_views_column') && ($screen->base == 'edit' && in_array($screen->post_type, Post_Views_Counter()->get_attribute('options', 'general', 'post_types_count'))))
23
+ {
24
+ foreach(Post_Views_Counter()->get_attribute('options', 'general', 'post_types_count') as $post_type)
25
+ {
26
+ if($post_type === 'page' && $screen->post_type === 'page')
27
+ {
28
+ // actions
29
+ add_action('manage_pages_custom_column', array(&$this, 'add_new_column_content'), 10, 2);
30
+
31
+ // filters
32
+ add_filter('manage_pages_columns', array(&$this, 'add_new_column'));
33
+ add_filter('manage_edit-page_sortable_columns', array(&$this, 'register_sortable_custom_column'));
34
+ }
35
+ elseif($post_type === 'post' && $screen->post_type === 'post')
36
+ {
37
+ // actions
38
+ add_action('manage_posts_custom_column', array(&$this, 'add_new_column_content'), 10, 2);
39
+
40
+ // filters
41
+ add_filter('manage_posts_columns', array(&$this, 'add_new_column'));
42
+ add_filter('manage_edit-post_sortable_columns', array(&$this, 'register_sortable_custom_column'));
43
+ }
44
+ elseif($screen->post_type === $post_type)
45
+ {
46
+ // actions
47
+ add_action('manage_'.$post_type.'_posts_custom_column', array(&$this, 'add_new_column_content'), 10, 2);
48
+
49
+ // filters
50
+ add_filter('manage_'.$post_type.'_posts_columns', array(&$this, 'add_new_column'));
51
+ add_filter('manage_edit-'.$post_type.'_sortable_columns', array(&$this, 'register_sortable_custom_column'));
52
+ }
53
+ }
54
+ }
55
+ }
56
+
57
+
58
+ /**
59
+ * Registers sortable column
60
+ */
61
+ public function register_sortable_custom_column($columns)
62
+ {
63
+ // adds new sortable column
64
+ $columns['post_views'] = 'post_views';
65
+
66
+ return $columns;
67
+ }
68
+
69
+
70
+ /**
71
+ * Adds new content to specific column
72
+ */
73
+ public function add_new_column_content($column_name, $id)
74
+ {
75
+ if($column_name === 'post_views')
76
+ {
77
+ global $wpdb;
78
+
79
+ // gets post views
80
+ $views = $wpdb->get_var(
81
+ $wpdb->prepare("
82
+ SELECT count
83
+ FROM ".$wpdb->prefix."post_views
84
+ WHERE id = %d AND type = 4",
85
+ $id
86
+ )
87
+ );
88
+
89
+ echo (int)$views;
90
+ }
91
+ }
92
+
93
+
94
+ public function add_new_column($columns)
95
+ {
96
+ $offset = 0;
97
+
98
+ if(isset($columns['date']))
99
+ $offset++;
100
+
101
+ if(isset($columns['comments']))
102
+ $offset++;
103
+
104
+ if($offset > 0)
105
+ {
106
+ $date = array_slice($columns, -$offset, $offset, true);
107
+
108
+ foreach($date as $column => $name)
109
+ {
110
+ unset($columns[$column]);
111
+ }
112
+
113
+ $columns['post_views'] = __('Post Views', 'post-views-counter');
114
+
115
+ foreach($date as $column => $name)
116
+ {
117
+ $columns[$column] = $name;
118
+ }
119
+ }
120
+ else
121
+ $columns['post_views'] = __('Post Views', 'post-views-counter');
122
+
123
+ return $columns;
124
+ }
125
+ }
126
+ ?>
includes/counter.php ADDED
@@ -0,0 +1,411 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(!defined('ABSPATH')) exit;
3
+
4
+ new Post_Views_Counter_Counter();
5
+
6
+ class Post_Views_Counter_Counter
7
+ {
8
+ private $cookie = array(
9
+ 'exists' => false,
10
+ 'visited_posts' => array(),
11
+ 'expiration' => 0
12
+ );
13
+
14
+
15
+ public function __construct()
16
+ {
17
+ // sets instance
18
+ Post_Views_Counter()->add_instance('counter', $this);
19
+
20
+ // actions
21
+ add_action('plugins_loaded', array(&$this, 'check_cookie'), 1);
22
+ add_action('wp', array(&$this, 'check_post'));
23
+ add_action('deleted_post', array(&$this, 'delete_post_views'));
24
+ add_action('wp_ajax_pvc-check-post', array(&$this, 'check_post_ajax'));
25
+ add_action('wp_ajax_nopriv_pvc-check-post', array(&$this, 'check_post_ajax'));
26
+ }
27
+
28
+
29
+ /**
30
+ * Removes post views from database when post is deleted
31
+ */
32
+ public function delete_post_views($post_id)
33
+ {
34
+ global $wpdb;
35
+
36
+ $wpdb->delete($wpdb->prefix.'post_views', array('id' => $post_id), array('%d'));
37
+ }
38
+
39
+
40
+ /**
41
+ * Checks whether user has excluded roles
42
+ */
43
+ public function is_user_roles_excluded($option)
44
+ {
45
+ $user = wp_get_current_user();
46
+
47
+ if(empty($user))
48
+ return false;
49
+
50
+ $roles = (array)$user->roles;
51
+
52
+ if(!empty($roles))
53
+ {
54
+ foreach($roles as $role)
55
+ {
56
+ if(in_array($role, $option, true))
57
+ return true;
58
+ }
59
+ }
60
+
61
+ return false;
62
+ }
63
+
64
+
65
+ /**
66
+ * Gets timestamp convertion
67
+ */
68
+ public function get_timestamp($type, $number, $timestamp = true)
69
+ {
70
+ $converter = array(
71
+ 'minutes' => 60,
72
+ 'hours' => 3600,
73
+ 'days' => 86400,
74
+ 'weeks' => 604800,
75
+ 'months' => 2592000,
76
+ 'years' => 946080000
77
+ );
78
+
79
+ return ($timestamp ? current_time('timestamp', true) : 0) + $number * $converter[$type];
80
+ }
81
+
82
+
83
+ /**
84
+ * Checks whether to count visit via AJAX request
85
+ */
86
+ public function check_post_ajax()
87
+ {
88
+ if(isset($_POST['action'], $_POST['post_id'], $_POST['pvc_nonce'], $_POST['post_type']) && $_POST['action'] === 'pvc-check-post' && ($post_id = (int)$_POST['post_id']) > 0 && wp_verify_nonce($_POST['pvc_nonce'], 'pvc-check-post') !== false && Post_Views_Counter()->get_attribute('options', 'general', 'counter_mode') === 'js')
89
+ {
90
+ // gets countable post types
91
+ $post_types = Post_Views_Counter()->get_attribute('options', 'general', 'post_types_count');
92
+
93
+ // gets post type
94
+ $post_type = get_post_type($post_id);
95
+
96
+ // whether to count this post type
97
+ if(empty($post_types) || empty($post_type) || $post_type !== $_POST['post_type'] || !in_array($post_type, $post_types, true))
98
+ exit;
99
+
100
+ // gets excluded ips
101
+ $excluded_ips = Post_Views_Counter()->get_attribute('options', 'general', 'exclude_ips');
102
+
103
+ // whether to count this ip
104
+ if(!empty($excluded_ips) && filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && in_array($_SERVER['REMOTE_ADDR'], $excluded_ips, true))
105
+ exit;
106
+
107
+ // gets groups to check them faster
108
+ $groups = Post_Views_Counter()->get_attribute('options', 'general', 'exclude', 'groups');
109
+
110
+ // whether to count this user
111
+ if(is_user_logged_in())
112
+ {
113
+ // exclude logged in users?
114
+ if(in_array('users', $groups, true))
115
+ exit;
116
+ // exclude specific roles?
117
+ elseif(in_array('roles', $groups, true) && $this->is_user_roles_excluded(Post_Views_Counter()->get_attribute('options', 'general', 'exclude', 'roles')))
118
+ exit;
119
+ }
120
+ // exclude guests?
121
+ elseif(in_array('guests', $groups, true))
122
+ exit;
123
+
124
+ // whether to count robots
125
+ if($this->is_robot())
126
+ exit;
127
+
128
+ // cookie already existed?
129
+ if($this->cookie['exists'])
130
+ {
131
+ // post already viewed but not expired?
132
+ if(in_array($post_id, array_keys($this->cookie['visited_posts']), true) && current_time('timestamp', true) < $this->cookie['visited_posts'][$post_id])
133
+ {
134
+ // updates cookie but do not count visit
135
+ $this->save_cookie($post_id, $this->cookie, false);
136
+
137
+ exit;
138
+ }
139
+ else
140
+ // updates cookie
141
+ $this->save_cookie($post_id, $this->cookie);
142
+ }
143
+ else
144
+ // sets new cookie
145
+ $this->save_cookie($post_id);
146
+
147
+ // count visit
148
+ $this->count_visit($post_id);
149
+ }
150
+
151
+ exit;
152
+ }
153
+
154
+
155
+ /**
156
+ *
157
+ */
158
+ public function check_post()
159
+ {
160
+ // do not count admin entries
161
+ if(is_admin())
162
+ return;
163
+
164
+ // do we use PHP as counter?
165
+ if(Post_Views_Counter()->get_attribute('options', 'general', 'counter_mode') === 'php')
166
+ {
167
+ $post_types = Post_Views_Counter()->get_attribute('options', 'general', 'post_types_count');
168
+
169
+ // whether to count this post type
170
+ if(empty($post_types) || !is_singular($post_types))
171
+ return;
172
+
173
+ $ips = Post_Views_Counter()->get_attribute('options', 'general', 'exclude_ips');
174
+
175
+ // whether to count this ip
176
+ if(!empty($ips) && filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && in_array($_SERVER['REMOTE_ADDR'], $ips, true))
177
+ return;
178
+
179
+ // gets groups to check them faster
180
+ $groups = Post_Views_Counter()->get_attribute('options', 'general', 'exclude', 'groups');
181
+
182
+ // whether to count this user
183
+ if(is_user_logged_in())
184
+ {
185
+ // exclude logged in users?
186
+ if(in_array('users', $groups, true))
187
+ return;
188
+ // exclude specific roles?
189
+ elseif(in_array('roles', $groups, true) && $this->is_user_roles_excluded(Post_Views_Counter()->get_attribute('options', 'general', 'exclude', 'roles')))
190
+ return;
191
+ }
192
+ // exclude guests?
193
+ elseif(in_array('guests', $groups, true))
194
+ return;
195
+
196
+ // whether to count robots
197
+ if($this->is_robot())
198
+ return;
199
+
200
+ // gets post id
201
+ $id = get_the_ID();
202
+
203
+ // cookie already existed?
204
+ if($this->cookie['exists'])
205
+ {
206
+ // post already viewed but not expired?
207
+ if(in_array($id, array_keys($this->cookie['visited_posts']), true) && current_time('timestamp', true) < $this->cookie['visited_posts'][$id])
208
+ {
209
+ // updates cookie but do not count visit
210
+ $this->save_cookie($id, $this->cookie, false);
211
+
212
+ return;
213
+ }
214
+ else
215
+ // updates cookie
216
+ $this->save_cookie($id, $this->cookie);
217
+ }
218
+ else
219
+ // sets new cookie
220
+ $this->save_cookie($id);
221
+
222
+ // count visit
223
+ $this->count_visit($id);
224
+ }
225
+ }
226
+
227
+
228
+ /**
229
+ * Initializes cookie session
230
+ */
231
+ public function check_cookie()
232
+ {
233
+ // do not run in admin except ajax requests
234
+ if(is_admin() && !(defined('DOING_AJAX') && DOING_AJAX))
235
+ return;
236
+
237
+ // is cookie set?
238
+ if(isset($_COOKIE['pvc_visits']) && !empty($_COOKIE['pvc_visits']))
239
+ {
240
+ $visited_posts = $expirations = array();
241
+
242
+ foreach($_COOKIE['pvc_visits'] as $content)
243
+ {
244
+ // valid cookie?
245
+ if(preg_match('/^(([0-9]+b[0-9]+a?)+)$/', $content) === 1)
246
+ {
247
+ // gets single id with expiration
248
+ $expiration_ids = explode('a', $content);
249
+
250
+ // checks every expiration => id pair
251
+ foreach($expiration_ids as $pair)
252
+ {
253
+ $pair = explode('b', $pair);
254
+ $expirations[] = (int)$pair[0];
255
+ $visited_posts[(int)$pair[1]] = (int)$pair[0];
256
+ }
257
+ }
258
+ }
259
+
260
+ $this->cookie = array(
261
+ 'exists' => true,
262
+ 'visited_posts' => $visited_posts,
263
+ 'expiration' => max($expirations)
264
+ );
265
+ }
266
+ }
267
+
268
+
269
+ /**
270
+ *
271
+ */
272
+ private function save_cookie($id, $cookie = array(), $expired = true)
273
+ {
274
+ $expiration = $this->get_timestamp(Post_Views_Counter()->get_attribute('options', 'general', 'time_between_counts', 'type'), Post_Views_Counter()->get_attribute('options', 'general', 'time_between_counts', 'number'));
275
+
276
+ // is it new cookie?
277
+ if(empty($cookie))
278
+ {
279
+ // sets cookie
280
+ setcookie('pvc_visits[0]', $expiration.'b'.$id, $expiration, COOKIEPATH, COOKIE_DOMAIN, (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? true : false), true);
281
+ }
282
+ else
283
+ {
284
+ if($expired)
285
+ {
286
+ // adds new id or changes expiration date if id already exists
287
+ $cookie['visited_posts'][$id] = $expiration;
288
+ }
289
+
290
+ // creates copy for better foreach performance
291
+ $visited_posts_expirations = $cookie['visited_posts'];
292
+
293
+ // gets current gmt time
294
+ $time = current_time('timestamp', true);
295
+
296
+ // checks whether viewed id has expired - no need to keep it in cookie (less size)
297
+ foreach($visited_posts_expirations as $post_id => $post_expiration)
298
+ {
299
+ if($time > $post_expiration)
300
+ unset($cookie['visited_posts'][$post_id]);
301
+ }
302
+
303
+ // sets new last expiration date if needed
304
+ $cookie['expiration'] = max($cookie['visited_posts']);
305
+
306
+ $cookies = $imploded = array();
307
+
308
+ // creates pairs
309
+ foreach($cookie['visited_posts'] as $id => $exp)
310
+ {
311
+ $imploded[] = $exp.'b'.$id;
312
+ }
313
+
314
+ // splits cookie into chunks (4000 bytes to make sure it is safe for every browser)
315
+ $chunks = str_split(implode('a', $imploded), 4000);
316
+
317
+ // more then one chunk?
318
+ if(count($chunks) > 1)
319
+ {
320
+ $last_id = '';
321
+
322
+ foreach($chunks as $chunk_id => $chunk)
323
+ {
324
+ // new chunk
325
+ $chunk_c = $last_id.$chunk;
326
+
327
+ // is it full-length chunk?
328
+ if(strlen($chunk) === 4000)
329
+ {
330
+ // gets last part
331
+ $last_part = strrchr($chunk_c, 'a');
332
+
333
+ // gets last id
334
+ $last_id = substr($last_part, 1);
335
+
336
+ // adds new full-lenght chunk
337
+ $cookies[$chunk_id] = substr($chunk_c, 0, strlen($chunk_c) - strlen($last_part));
338
+ }
339
+ else
340
+ // adds last chunk
341
+ $cookies[$chunk_id] = $chunk_c;
342
+ }
343
+ }
344
+ else
345
+ // only one chunk
346
+ $cookies[] = $chunks[0];
347
+
348
+ foreach($cookies as $key => $value)
349
+ {
350
+ // sets cookie
351
+ setcookie('pvc_visits['.$key.']', $value, $cookie['expiration'], COOKIEPATH, COOKIE_DOMAIN, (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? true : false), true);
352
+ }
353
+ }
354
+ }
355
+
356
+
357
+ /**
358
+ *
359
+ */
360
+ private function count_visit($id)
361
+ {
362
+ global $wpdb;
363
+
364
+ // gets day, week, month and year
365
+ $date = explode('-', date('W-d-m-Y', current_time('timestamp')));
366
+
367
+ foreach(array(
368
+ 0 => $date[3].$date[2].$date[1], // day like 20140324
369
+ 1 => $date[3].$date[0], // week like 201439
370
+ 2 => $date[3].$date[2], // month like 201405
371
+ 3 => $date[3], // year like 2014
372
+ 4 => 'total' // total views
373
+ ) as $type => $period)
374
+ {
375
+ // updates views
376
+ $wpdb->query(
377
+ $wpdb->prepare("
378
+ INSERT INTO ".$wpdb->prefix."post_views (id, type, period, count)
379
+ VALUES (%d, %d, %s, 1)
380
+ ON DUPLICATE KEY UPDATE count = count + 1",
381
+ $id,
382
+ $type,
383
+ $period
384
+ )
385
+ );
386
+ }
387
+ }
388
+
389
+
390
+ /**
391
+ * Checks whether visitor is a bot
392
+ */
393
+ private function is_robot()
394
+ {
395
+ if(!isset($_SERVER['HTTP_USER_AGENT']) || (isset($_SERVER['HTTP_USER_AGENT']) && trim($_SERVER['HTTP_USER_AGENT']) === ''))
396
+ return false;
397
+
398
+ $robots = array(
399
+ 'bot', 'b0t', 'Acme.Spider', 'Ahoy! The Homepage Finder', 'Alkaline', 'Anthill', 'Walhello appie', 'Arachnophilia', 'Arale', 'Araneo', 'ArchitextSpider', 'Aretha', 'ARIADNE', 'arks', 'AskJeeves', 'ASpider (Associative Spider)', 'ATN Worldwide', 'AURESYS', 'BackRub', 'Bay Spider', 'Big Brother', 'Bjaaland', 'BlackWidow', 'Die Blinde Kuh', 'Bloodhound', 'BSpider', 'CACTVS Chemistry Spider', 'Calif', 'Cassandra', 'Digimarc Marcspider/CGI', 'ChristCrawler.com', 'churl', 'cIeNcIaFiCcIoN.nEt', 'CMC/0.01', 'Collective', 'Combine System', 'Web Core / Roots', 'Cusco', 'CyberSpyder Link Test', 'CydralSpider', 'Desert Realm Spider', 'DeWeb(c) Katalog/Index', 'DienstSpider', 'Digger', 'Direct Hit Grabber', 'DownLoad Express', 'DWCP (Dridus\' Web Cataloging Project)', 'e-collector', 'EbiNess', 'Emacs-w3 Search Engine', 'ananzi', 'esculapio', 'Esther', 'Evliya Celebi', 'FastCrawler', 'Felix IDE', 'Wild Ferret Web Hopper #1, #2, #3', 'FetchRover', 'fido', 'KIT-Fireball', 'Fish search', 'Fouineur', 'Freecrawl', 'FunnelWeb', 'gammaSpider, FocusedCrawler', 'gazz', 'GCreep', 'GetURL', 'Golem', 'Grapnel/0.01 Experiment', 'Griffon', 'Gromit', 'Northern Light Gulliver', 'Harvest', 'havIndex', 'HI (HTML Index) Search', 'Hometown Spider Pro', 'ht://Dig', 'HTMLgobble', 'Hyper-Decontextualizer', 'IBM_Planetwide', 'Popular Iconoclast', 'Ingrid', 'Imagelock', 'IncyWincy', 'Informant', 'Infoseek Sidewinder', 'InfoSpiders', 'Inspector Web', 'IntelliAgent', 'Iron33', 'Israeli-search', 'JavaBee', 'JCrawler', 'Jeeves', 'JumpStation', 'image.kapsi.net', 'Katipo', 'KDD-Explorer', 'Kilroy', 'LabelGrabber', 'larbin', 'legs', 'Link Validator', 'LinkScan', 'LinkWalker', 'Lockon', 'logo.gif Crawler', 'Lycos', 'Mac WWWWorm', 'Magpie', 'marvin/infoseek', 'Mattie', 'MediaFox', 'MerzScope', 'NEC-MeshExplorer', 'MindCrawler', 'mnoGoSearch search engine software', 'moget', 'MOMspider', 'Monster', 'Motor', 'Muncher', 'Muninn', 'Muscat Ferret', 'Mwd.Search', 'Internet Shinchakubin', 'NDSpider', 'Nederland.zoek', 'NetCarta WebMap Engine', 'NetMechanic', 'NetScoop', 'newscan-online', 'NHSE Web Forager', 'Nomad', 'nzexplorer', 'ObjectsSearch', 'Occam', 'HKU WWW Octopus', 'OntoSpider', 'Openfind data gatherer', 'Orb Search', 'Pack Rat', 'PageBoy', 'ParaSite', 'Patric', 'pegasus', 'The Peregrinator', 'PerlCrawler 1.0', 'Phantom', 'PhpDig', 'PiltdownMan', 'Pioneer', 'html_analyzer', 'Portal Juice Spider', 'PGP Key Agent', 'PlumtreeWebAccessor', 'Poppi', 'PortalB Spider', 'GetterroboPlus Puu', 'Raven Search', 'RBSE Spider', 'RoadHouse Crawling System', 'ComputingSite Robi/1.0', 'RoboCrawl Spider', 'RoboFox', 'Robozilla', 'RuLeS', 'Scooter', 'Sleek', 'Search.Aus-AU.COM', 'SearchProcess', 'Senrigan', 'SG-Scout', 'ShagSeeker', 'Shai\'Hulud', 'Sift', 'Site Valet', 'SiteTech-Rover', 'Skymob.com', 'SLCrawler', 'Inktomi Slurp', 'Smart Spider', 'Snooper', 'Spanner', 'Speedy Spider', 'spider_monkey', 'Spiderline Crawler', 'SpiderMan', 'SpiderView(tm)', 'Site Searcher', 'Suke', 'suntek search engine', 'Sven', 'Sygol', 'TACH Black Widow', 'Tarantula', 'tarspider', 'Templeton', 'TeomaTechnologies', 'TITAN', 'TitIn', 'TLSpider', 'UCSD Crawl', 'UdmSearch', 'URL Check', 'URL Spider Pro', 'Valkyrie', 'Verticrawl', 'Victoria', 'vision-search', 'Voyager', 'W3M2', 'WallPaper (alias crawlpaper)', 'the World Wide Web Wanderer', 'w@pSpider by wap4.com', 'WebBandit Web Spider', 'WebCatcher', 'WebCopy', 'webfetcher', 'Webinator', 'weblayers', 'WebLinker', 'WebMirror', 'The Web Moose', 'WebQuest', 'Digimarc MarcSpider', 'WebReaper', 'webs', 'Websnarf', 'WebSpider', 'WebVac', 'webwalk', 'WebWalker', 'WebWatch', 'Wget', 'whatUseek Winona', 'Wired Digital', 'Weblog Monitor', 'w3mir', 'WebStolperer', 'The Web Wombat', 'The World Wide Web Worm', 'WWWC Ver 0.2.5', 'WebZinger', 'XGET'
400
+ );
401
+
402
+ foreach($robots as $robot)
403
+ {
404
+ if(stripos($_SERVER['HTTP_USER_AGENT'], $robot) !== false)
405
+ return true;
406
+ }
407
+
408
+ return false;
409
+ }
410
+ }
411
+ ?>
includes/cron.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(!defined('ABSPATH')) exit;
3
+
4
+ new Post_Views_Counter_Cron();
5
+
6
+ class Post_Views_Counter_Cron
7
+ {
8
+ public function __construct()
9
+ {
10
+ // sets instance
11
+ Post_Views_Counter()->add_instance('cron', $this);
12
+
13
+ // actions
14
+ add_action('init', array(&$this, 'check_cron'));
15
+ add_action('pvc_reset_counts', array(&$this, 'reset_counts'));
16
+
17
+ // filters
18
+ add_filter('cron_schedules', array(&$this, 'cron_time_intervals'));
19
+ }
20
+
21
+
22
+ /**
23
+ * Resets daily counts
24
+ */
25
+ public function reset_counts()
26
+ {
27
+ global $wpdb;
28
+
29
+ $wpdb->query('DELETE FROM '.$wpdb->prefix.'post_views WHERE type = 0');
30
+ }
31
+
32
+
33
+ /**
34
+ * Adds new cron interval from settings
35
+ */
36
+ public function cron_time_intervals($schedules)
37
+ {
38
+ $schedules['post_views_counter_interval'] = array(
39
+ 'interval' => Post_Views_Counter()->get_instance('counter')->get_timestamp(Post_Views_Counter()->get_attribute('options', 'general', 'reset_counts', 'type'), Post_Views_Counter()->get_attribute('options', 'general', 'reset_counts', 'number'), false),
40
+ 'display' => __('Post Views Counter reset daily counts interval', 'post-views-counter')
41
+ );
42
+
43
+ return $schedules;
44
+ }
45
+
46
+
47
+ /**
48
+ * Checks whether WP Cron needs to add new task
49
+ */
50
+ public function check_cron()
51
+ {
52
+ if(!is_admin())
53
+ return;
54
+
55
+ // sets wp cron task
56
+ if(Post_Views_Counter()->get_attribute('options', 'general', 'cron_run'))
57
+ {
58
+ // not set or need to be updated?
59
+ if(!wp_next_scheduled('pvc_reset_counts') || Post_Views_Counter()->get_attribute('options', 'general', 'cron_update'))
60
+ {
61
+ // task is added but need to be updated
62
+ if(Post_Views_Counter()->get_attribute('options', 'general', 'cron_update'))
63
+ {
64
+ // removes old schedule
65
+ wp_clear_scheduled_hook('pvc_reset_counts');
66
+
67
+ // sets update to false
68
+ $general = Post_Views_Counter()->get_attribute('options', 'general');
69
+ $general['cron_update'] = false;
70
+
71
+ // updates settings
72
+ update_option('post_views_counter_settings_general', $general);
73
+ }
74
+
75
+ // sets schedule
76
+ wp_schedule_event(Post_Views_Counter()->get_instance('counter')->get_timestamp(Post_Views_Counter()->get_attribute('options', 'general', 'reset_counts', 'type'), Post_Views_Counter()->get_attribute('options', 'general', 'reset_counts', 'number')), 'post_views_counter_interval', 'pvc_reset_counts');
77
+ }
78
+ }
79
+ else
80
+ {
81
+ // removes schedule
82
+ wp_clear_scheduled_hook('pvc_reset_counts');
83
+ remove_action('pvc_reset_counts', array(&$this, 'reset_counts'));
84
+ }
85
+ }
86
+ }
87
+ ?>
includes/frontend.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(!defined('ABSPATH')) exit;
3
+
4
+ new Post_Views_Counter_Frontend();
5
+
6
+ class Post_Views_Counter_Frontend
7
+ {
8
+ public function __construct()
9
+ {
10
+ // actions
11
+ add_action('wp_loaded', array(&$this, 'register_shortcode'));
12
+ add_action('wp_enqueue_scripts', array(&$this, 'frontend_scripts_styles'));
13
+
14
+ // filters
15
+ add_filter('the_content', array(&$this, 'add_post_counts'));
16
+ }
17
+
18
+
19
+ /**
20
+ *
21
+ */
22
+ public function register_shortcode()
23
+ {
24
+ add_shortcode('post-views', array(&$this, 'post_views_shortcode'));
25
+ }
26
+
27
+
28
+ /**
29
+ *
30
+ */
31
+ public function post_views_shortcode($args)
32
+ {
33
+ $defaults = array(
34
+ 'id' => get_the_ID()
35
+ );
36
+
37
+ $args = shortcode_atts($defaults, $args);
38
+
39
+ return pvc_post_views($args['id'], false);
40
+ }
41
+
42
+
43
+ /**
44
+ *
45
+ */
46
+ public function add_post_counts($content)
47
+ {
48
+ if(is_singular() && in_array(get_post_type(), Post_Views_Counter()->get_attribute('options', 'display', 'post_types_display'), true))
49
+ {
50
+ // gets groups to check it faster
51
+ $groups = Post_Views_Counter()->get_attribute('options', 'display', 'restrict_display', 'groups');
52
+
53
+ // whether to display views
54
+ if(is_user_logged_in())
55
+ {
56
+ // exclude logged in users?
57
+ if(in_array('users', $groups, true))
58
+ return $content;
59
+ // exclude specific roles?
60
+ elseif(in_array('roles', $groups, true) && Post_Views_Counter()->get_instance('counter')->is_user_roles_excluded(Post_Views_Counter()->get_attribute('options', 'display', 'restrict_display', 'roles')))
61
+ return $content;
62
+ }
63
+ // exclude guests?
64
+ elseif(in_array('guests', $groups, true))
65
+ return $content;
66
+
67
+ switch(Post_Views_Counter()->get_attribute('options', 'display', 'position'))
68
+ {
69
+ case 'after':
70
+ return $content.'[post-views]';
71
+
72
+ case 'before':
73
+ return '[post-views]'.$content;
74
+
75
+ default:
76
+ case 'manual':
77
+ return $content;
78
+ }
79
+ }
80
+
81
+ return $content;
82
+ }
83
+
84
+
85
+ /**
86
+ *
87
+ */
88
+ public function frontend_scripts_styles()
89
+ {
90
+ $post_types = Post_Views_Counter()->get_attribute('options', 'display', 'post_types_display');
91
+
92
+ // loads dashicons
93
+ wp_enqueue_style('dashicons');
94
+
95
+ wp_register_style(
96
+ 'post-views-counter-frontend',
97
+ POST_VIEWS_COUNTER_URL.'/css/frontend.css'
98
+ );
99
+
100
+ wp_enqueue_style('post-views-counter-frontend');
101
+
102
+ if(Post_Views_Counter()->get_attribute('options', 'general', 'counter_mode') === 'js')
103
+ {
104
+ $post_types = Post_Views_Counter()->get_attribute('options', 'general', 'post_types_count');
105
+
106
+ // whether to count this post type
107
+ if(empty($post_types) || !is_singular($post_types))
108
+ return;
109
+
110
+ wp_register_script(
111
+ 'post-views-counter-frontend',
112
+ POST_VIEWS_COUNTER_URL.'/js/frontend.js',
113
+ array('jquery')
114
+ );
115
+
116
+ wp_enqueue_script('post-views-counter-frontend');
117
+
118
+ wp_localize_script(
119
+ 'post-views-counter-frontend',
120
+ 'pvcArgsFrontend',
121
+ array(
122
+ 'ajaxURL' => admin_url('admin-ajax.php'),
123
+ 'postID' => get_the_ID(),
124
+ 'nonce' => wp_create_nonce('pvc-check-post'),
125
+ 'postType' => get_post_type()
126
+ )
127
+ );
128
+ }
129
+ }
130
+ }
131
+ ?>
includes/functions.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Post Views Counter pluggable template functions
4
+ *
5
+ * Override any of those functions by copying it to your theme or replace it via plugin
6
+ *
7
+ * @author Digital Factory
8
+ * @package Post Views Counter
9
+ * @version 1.0.0
10
+ */
11
+
12
+ if(!defined('ABSPATH')) exit;
13
+
14
+ // Get post views for a post or array of posts
15
+ if(!function_exists('pvc_get_post_views'))
16
+ {
17
+ function pvc_get_post_views($post_id = 0)
18
+ {
19
+ if(empty($post_id))
20
+ $post_id = get_the_ID();
21
+
22
+ if(is_array($post_id))
23
+ $post_id = implode(',', array_map('intval', $post_id));
24
+ else
25
+ $post_id = (int)$post_id;
26
+
27
+ global $wpdb;
28
+
29
+ $post_views = (int)$wpdb->get_var("
30
+ SELECT SUM(count) AS views
31
+ FROM ".$wpdb->prefix."post_views
32
+ WHERE id IN (".$post_id.") AND type = 4"
33
+ );
34
+
35
+ return apply_filters('pvc_get_post_views', $post_views, $post_id);
36
+ }
37
+ }
38
+
39
+
40
+ // Display post views for a given post
41
+ if(!function_exists('pvc_post_views'))
42
+ {
43
+ function pvc_post_views($post_id = 0, $display = true)
44
+ {
45
+ // get all data
46
+ $post_id = (int)(empty($post_id) ? get_the_ID() : $post_id);
47
+ $options = Post_Views_Counter()->get_attribute('options', 'display');
48
+ $views = pvc_get_post_views($post_id);
49
+
50
+ // prepares display
51
+ $label = apply_filters('pvc_post_views_label', (function_exists('icl_t') ? icl_t('Post Views Counter', 'Post Views Label', $options['label']) : $options['label']), $post_id);
52
+ $icon_class = ($options['icon_class'] !== '' ? ' '.esc_attr($options['icon_class']) : '');
53
+ $icon = apply_filters('pvc_post_views_icon', '<span class="post-views-icon dashicons '.$icon_class.'"></span>', $post_id);
54
+
55
+ $html = apply_filters(
56
+ 'pvc_post_views_html',
57
+ '<div class="post-views post-'.$post_id.' entry-meta">
58
+ '.($options['display_style']['icon'] && $icon_class !== '' ? $icon : '').'
59
+ '.($options['display_style']['text'] ? '<span class="post-views-label">'.$label.' </span>' : '').'
60
+ <span class="post-views-count">'.$views.'</span>
61
+ </div>',
62
+ $post_id,
63
+ $views,
64
+ $label,
65
+ $icon
66
+ );
67
+
68
+ if($display)
69
+ echo $html;
70
+ else
71
+ return $html;
72
+ }
73
+ }
74
+
75
+
76
+ // Get most viewed posts
77
+ if(!function_exists('pvc_get_most_viewed_posts'))
78
+ {
79
+ function pvc_get_most_viewed_posts($args = array())
80
+ {
81
+ $args = array_merge(
82
+ array(
83
+ 'posts_per_page' => 10,
84
+ 'order' => 'desc',
85
+ 'post_type' => 'post'
86
+ ),
87
+ $args
88
+ );
89
+
90
+ $args = apply_filters('pvc_get_most_viewed_posts_args', $args);
91
+
92
+ // forces to use filters and post views as order
93
+ $args['suppress_filters'] = false;
94
+ $args['orderby'] = 'post_views';
95
+
96
+ return get_posts($args);
97
+ }
98
+ }
99
+
100
+
101
+ // Display a list of most viewed posts
102
+ if(!function_exists('pvc_most_viewed_posts'))
103
+ {
104
+ function pvc_most_viewed_posts($args = array(), $display = true)
105
+ {
106
+ $defaults = array(
107
+ 'number_of_posts' => 5,
108
+ 'post_types' => array('post'),
109
+ 'order' => 'desc',
110
+ 'thumbnail_size' => 'thumbnail',
111
+ 'show_post_views' => true,
112
+ 'show_post_thumbnail' => false,
113
+ 'show_post_excerpt' => false,
114
+ 'no_posts_message' => __('No Posts', 'post-views-counter')
115
+ );
116
+
117
+ $args = apply_filters('pvc_most_viewed_posts_args', wp_parse_args($args, $defaults));
118
+
119
+ $args['show_post_views'] = (bool)$args['show_post_views'];
120
+ $args['show_post_thumbnail'] = (bool)$args['show_post_thumbnail'];
121
+ $args['show_post_excerpt'] = (bool)$args['show_post_excerpt'];
122
+
123
+ $posts = pvc_get_most_viewed_posts(
124
+ apply_filters(
125
+ 'pvc_get_most_viewed_posts_args',
126
+ array(
127
+ 'posts_per_page' => (isset($args['number_of_posts']) ? (int)$args['number_of_posts'] : $defaults['number_of_posts']),
128
+ 'order' => (isset($args['order']) ? $args['order'] : $defaults['order']),
129
+ 'post_type' => (isset($args['post_types']) ? $args['post_types'] : $defaults['post_types'])
130
+ )
131
+ )
132
+ );
133
+
134
+ if(!empty($posts))
135
+ {
136
+ $html = '
137
+ <ul>';
138
+
139
+ foreach($posts as $post)
140
+ {
141
+ setup_postdata($post);
142
+
143
+ $html .= '
144
+ <li>';
145
+
146
+ if($args['show_post_thumbnail'] && has_post_thumbnail($post->ID))
147
+ {
148
+ $html .= '
149
+ <span class="post-thumbnail">
150
+ '.get_the_post_thumbnail($post->ID, $args['thumbnail_size']).'
151
+ </span>';
152
+ }
153
+
154
+ $html .= '
155
+ <a class="post-title" href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a>'.($args['show_post_views'] ? ' <span class="count">('.pvc_get_post_views($post->ID).')</span>' : '');
156
+
157
+ $excerpt = '';
158
+
159
+ if($args['show_post_excerpt'])
160
+ {
161
+ if(empty($post->post_excerpt))
162
+ $text = $post->post_content;
163
+ else
164
+ $text = $post->post_excerpt;
165
+
166
+ if(!empty($text))
167
+ $excerpt = wp_trim_words(str_replace(']]>', ']]&gt;', strip_shortcodes($text)), apply_filters('excerpt_length', 55), apply_filters('excerpt_more', ' '.'[&hellip;]'));
168
+ }
169
+
170
+ if(!empty($excerpt))
171
+ $html .= '
172
+ <div class="post-excerpt">'.esc_html($excerpt).'</div>';
173
+
174
+ $html .= '
175
+ </li>';
176
+ }
177
+
178
+ wp_reset_postdata();
179
+
180
+ $html .= '
181
+ </ul>';
182
+ }
183
+ else
184
+ $html = $args['no_posts_message'];
185
+
186
+ $html = apply_filters('pvc_most_viewed_posts_html', $html, $args);
187
+
188
+ if($display)
189
+ echo $html;
190
+ else
191
+ return $html;
192
+ }
193
+ }
194
+ ?>
includes/query.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(!defined('ABSPATH')) exit;
3
+
4
+ new Post_Views_Counter_Query();
5
+
6
+ class Post_Views_Counter_Query
7
+ {
8
+ public function __construct()
9
+ {
10
+ // actions
11
+ add_action('pre_get_posts', array(&$this, 'extend_pre_query'), 9);
12
+
13
+ // filters
14
+ add_filter('posts_join', array(&$this, 'posts_join'), 10, 2);
15
+ add_filter('posts_groupby', array(&$this, 'posts_groupby'), 10, 2);
16
+ add_filter('posts_orderby', array(&$this, 'posts_orderby'), 10, 2);
17
+ }
18
+
19
+
20
+ /**
21
+ *
22
+ */
23
+ public function extend_pre_query($query)
24
+ {
25
+ // adds new parameter
26
+ if(isset($query->query_vars['orderby']) && $query->query_vars['orderby'] === 'post_views')
27
+ $query->order_by_post_views = true;
28
+ }
29
+
30
+
31
+ /**
32
+ *
33
+ */
34
+ public function posts_join($join, $query)
35
+ {
36
+ global $wpdb;
37
+
38
+ // is it sorted by post views?
39
+ if(isset($query->order_by_post_views) && $query->order_by_post_views)
40
+ $join .= " LEFT JOIN ".$wpdb->prefix."post_views pvc ON pvc.id = ".$wpdb->prefix."posts.ID AND pvc.type = 4";
41
+
42
+ return $join;
43
+ }
44
+
45
+
46
+ /**
47
+ *
48
+ */
49
+ public function posts_groupby($groupby, $query)
50
+ {
51
+ global $wpdb;
52
+
53
+ // is it sorted by post views?
54
+ if(isset($query->order_by_post_views) && $query->order_by_post_views)
55
+ $groupby = (trim($groupby) !== '' ? $groupby.', ' : '').$wpdb->prefix.'posts.ID';
56
+
57
+ return $groupby;
58
+ }
59
+
60
+
61
+ /**
62
+ *
63
+ */
64
+ public function posts_orderby($orderby, $query)
65
+ {
66
+ global $wpdb;
67
+
68
+ // is it sorted by post views?
69
+ if(isset($query->order_by_post_views) && $query->order_by_post_views)
70
+ {
71
+ $order = $query->get('order');
72
+ $orderby = 'pvc.count '.$order.', '.$wpdb->prefix.'posts.ID '.$order;
73
+ }
74
+
75
+ return $orderby;
76
+ }
77
+ }
78
+ ?>
includes/settings.php ADDED
@@ -0,0 +1,861 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(!defined('ABSPATH')) exit;
3
+
4
+ new Post_Views_Counter_Settings();
5
+
6
+ class Post_Views_Counter_Settings
7
+ {
8
+ private $tabs;
9
+ private $choices;
10
+ private $modes;
11
+ private $time_types;
12
+ private $groups;
13
+ private $user_roles;
14
+ private $positions;
15
+ private $display_styles;
16
+ public $post_types;
17
+
18
+
19
+ public function __construct()
20
+ {
21
+ // sets instance
22
+ Post_Views_Counter()->add_instance('settings', $this);
23
+
24
+ // actions
25
+ add_action('admin_init', array(&$this, 'register_settings'));
26
+ add_action('admin_menu', array(&$this, 'admin_menu_options'));
27
+ add_action('after_setup_theme', array(&$this, 'load_defaults'));
28
+ add_action('wp_loaded', array(&$this, 'load_post_types'));
29
+
30
+ // filters
31
+ add_filter('plugin_row_meta', array(&$this, 'plugin_extend_links'), 10, 2);
32
+ }
33
+
34
+
35
+ /**
36
+ *
37
+ */
38
+ public function load_defaults()
39
+ {
40
+ $this->choices = array(
41
+ 'yes' => __('Enable', 'post-views-counter'),
42
+ 'no' => __('Disable', 'post-views-counter')
43
+ );
44
+
45
+ $this->modes = array(
46
+ 'php' => __('PHP', 'post-views-counter'),
47
+ 'js' => __('JavaScript', 'post-views-counter')
48
+ );
49
+
50
+ $this->time_types = array(
51
+ 'minutes' => __('minutes', 'post-views-counter'),
52
+ 'hours' => __('hours', 'post-views-counter'),
53
+ 'days' => __('days', 'post-views-counter'),
54
+ 'weeks' => __('weeks', 'post-views-counter'),
55
+ 'months' => __('months', 'post-views-counter'),
56
+ 'years' => __('years', 'post-views-counter')
57
+ );
58
+
59
+ $this->groups = array(
60
+ 'robots' => __('robots', 'post-views-counter'),
61
+ 'users' => __('logged in users', 'post-views-counter'),
62
+ 'guests' => __('guests', 'post-views-counter'),
63
+ 'roles' => __('selected user roles', 'post-views-counter')
64
+ );
65
+
66
+ $this->positions = array(
67
+ 'before' => __('before the content', 'post-views-counter'),
68
+ 'after' => __('after the content', 'post-views-counter'),
69
+ 'manual' => __('manual', 'post-views-counter')
70
+ );
71
+
72
+ $this->display_styles = array(
73
+ 'icon' => __('icon', 'post-views-counter'),
74
+ 'text' => __('label', 'post-views-counter')
75
+ );
76
+
77
+ $this->tabs = array(
78
+ 'general' => array(
79
+ 'name' => __('General', 'post-views-counter'),
80
+ 'key' => 'post_views_counter_settings_general',
81
+ 'submit' => 'save_pvc_general',
82
+ 'reset' => 'reset_pvc_general'
83
+ ),
84
+ 'display' => array(
85
+ 'name' => __('Display', 'post-views-counter'),
86
+ 'key' => 'post_views_counter_settings_display',
87
+ 'submit' => 'save_pvc_display',
88
+ 'reset' => 'reset_pvc_display'
89
+ )
90
+ );
91
+
92
+ $this->user_roles = $this->get_users_roles();
93
+ }
94
+
95
+
96
+ /**
97
+ *
98
+ */
99
+ public function load_post_types()
100
+ {
101
+ $post_types = array();
102
+
103
+ // built in public post types
104
+ foreach(get_post_types(array('_builtin' => true, 'public' => true), 'objects', 'and') as $key => $post_type)
105
+ {
106
+ if($key !== 'attachment')
107
+ $post_types[$key] = $post_type->labels->name;
108
+ }
109
+
110
+ // public custom post types
111
+ foreach(get_post_types(array('_builtin' => false, 'public' => true), 'objects', 'and') as $key => $post_type)
112
+ {
113
+ $post_types[$key] = $post_type->labels->name;
114
+ }
115
+
116
+ // sorts post types alphabetically with their keys
117
+ asort($post_types, SORT_STRING);
118
+
119
+ $this->post_types = $post_types;
120
+ }
121
+
122
+
123
+ /**
124
+ * Gets all users roles
125
+ */
126
+ public function get_users_roles()
127
+ {
128
+ global $wp_roles;
129
+
130
+ $roles = array();
131
+
132
+ foreach(apply_filters('editable_roles', $wp_roles->roles) as $role => $details)
133
+ {
134
+ $roles[$role] = translate_user_role($details['name']);
135
+ }
136
+
137
+ asort($roles, SORT_STRING);
138
+
139
+ return $roles;
140
+ }
141
+
142
+
143
+ /**
144
+ * Adds options page
145
+ */
146
+ public function admin_menu_options()
147
+ {
148
+ add_options_page(
149
+ __('Post Views Counter', 'post-views-counter'),
150
+ __('Post Views Counter', 'post-views-counter'),
151
+ 'manage_options',
152
+ 'post-views-counter',
153
+ array(&$this, 'options_page')
154
+ );
155
+ }
156
+
157
+
158
+ /**
159
+ *
160
+ */
161
+ public function options_page()
162
+ {
163
+ $tab_key = (isset($_GET['tab']) ? $_GET['tab'] : 'general');
164
+
165
+ echo '
166
+ <div class="wrap">'.screen_icon().'
167
+ <h2>'.__('Post Views Counter', 'post-views-counter').'</h2>
168
+ <h2 class="nav-tab-wrapper">';
169
+
170
+ foreach($this->tabs as $key => $name)
171
+ {
172
+ echo '
173
+ <a class="nav-tab '.($tab_key == $key ? 'nav-tab-active' : '').'" href="'.esc_url(admin_url('options-general.php?page=post-views-counter&tab='.$key)).'">'.$name['name'].'</a>';
174
+ }
175
+
176
+ echo '
177
+ </h2>
178
+ <div class="post-views-counter-settings">
179
+ <div class="df-credits">
180
+ <h3 class="hndle">'.__('Post Views Counter', 'post-views-counter').' '.Post_Views_Counter()->get_attribute('defaults', 'version').'</h3>
181
+ <div class="inside">
182
+ <h4 class="inner">'.__('Need support?', 'post-views-counter').'</h4>
183
+ <p class="inner">'.__('If you are having problems with this plugin, please talk about them in the', 'post-views-counter').' <a href="http://www.dfactory.eu/support/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=support" target="_blank" title="'.__('Support forum', 'post-views-counter').'">'.__('Support forum', 'post-views-counter').'</a></p>
184
+ <hr />
185
+ <h4 class="inner">'.__('Do you like this plugin?', 'post-views-counter').'</h4>
186
+ <p class="inner"><a href="http://wordpress.org/support/view/plugin-reviews/post-views-counter" target="_blank" title="'.__('Rate it 5', 'events-maker').'">'.__('Rate it 5', 'post-views-counter').'</a> '.__('on WordPress.org', 'post-views-counter').'<br />'.
187
+ __('Blog about it & link to the', 'post-views-counter').' <a href="http://www.dfactory.eu/plugins/post-views-counter/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=blog-about" target="_blank" title="'.__('plugin page', 'post-views-counter').'">'.__('plugin page', 'post-views-counter').'</a><br/>'.
188
+ __('Check out our other', 'post-views-counter').' <a href="http://www.dfactory.eu/plugins/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=other-plugins" target="_blank" title="'.__('WordPress plugins', 'post-views-counter').'">'.__('WordPress plugins', 'post-views-counter').'</a>
189
+ </p>
190
+ <hr />
191
+ <p class="df-link inner">'.__('Created by', 'post-views-counter').' <a href="http://www.dfactory.eu/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=created-by" target="_blank" title="dFactory - Quality plugins for WordPress"><img src="'.POST_VIEWS_COUNTER_URL.'/images/logo-dfactory.png'.'" title="dFactory - Quality plugins for WordPress" alt="dFactory - Quality plugins for WordPress" /></a></p>
192
+ </div>
193
+ </div>
194
+ <form action="options.php" method="post">';
195
+
196
+ wp_nonce_field('update-options');
197
+ settings_fields($this->tabs[$tab_key]['key']);
198
+ do_settings_sections($this->tabs[$tab_key]['key']);
199
+
200
+ echo '
201
+ <p class="submit">';
202
+
203
+ submit_button('', 'primary', $this->tabs[$tab_key]['submit'], FALSE);
204
+
205
+ echo ' ';
206
+
207
+ submit_button(__('Reset to defaults', 'post-views-counter'), 'secondary reset_pvc_settings', $this->tabs[$tab_key]['reset'], FALSE);
208
+
209
+ echo '
210
+ </p>
211
+ </form>
212
+ </div>
213
+ <div class="clear"></div>
214
+ </div>';
215
+ }
216
+
217
+
218
+ /**
219
+ *
220
+ */
221
+ public function register_settings()
222
+ {
223
+ // general options
224
+ register_setting('post_views_counter_settings_general', 'post_views_counter_settings_general', array(&$this, 'validate_settings'));
225
+ add_settings_section('post_views_counter_settings_general', __('General settings', 'post-views-counter'), '', 'post_views_counter_settings_general');
226
+ add_settings_field('pvc_post_types_count', __('Post Types Count', 'post-views-counter'), array(&$this, 'post_types_count'), 'post_views_counter_settings_general', 'post_views_counter_settings_general');
227
+ add_settings_field('pvc_counter_mode', __('Counter Mode', 'post-views-counter'), array(&$this, 'counter_mode'), 'post_views_counter_settings_general', 'post_views_counter_settings_general');
228
+ add_settings_field('pvc_post_views_column', __('Post Views Column', 'post-views-counter'), array(&$this, 'post_views_column'), 'post_views_counter_settings_general', 'post_views_counter_settings_general');
229
+ add_settings_field('pvc_time_between_counts', __('Time Between Counts', 'post-views-counter'), array(&$this, 'time_between_counts'), 'post_views_counter_settings_general', 'post_views_counter_settings_general');
230
+ add_settings_field('pvc_reset_counts', __('Reset Data', 'post-views-counter'), array(&$this, 'reset_counts'), 'post_views_counter_settings_general', 'post_views_counter_settings_general');
231
+ add_settings_field('pvc_exclude', __('Exclude Visitors', 'post-views-counter'), array(&$this, 'exclude'), 'post_views_counter_settings_general', 'post_views_counter_settings_general');
232
+ add_settings_field('pvc_exclude_ips', __('Exclude IPs', 'post-views-counter'), array(&$this, 'exclude_ips'), 'post_views_counter_settings_general', 'post_views_counter_settings_general');
233
+ add_settings_field('pvc_wp_postviews', __('WP-PostViews', 'post-views-counter'), array(&$this, 'wp_postviews'), 'post_views_counter_settings_general', 'post_views_counter_settings_general');
234
+ add_settings_field('pvc_deactivation_delete', __('Deactivation', 'post-views-counter'), array(&$this, 'deactivation_delete'), 'post_views_counter_settings_general', 'post_views_counter_settings_general');
235
+
236
+ // display options
237
+ register_setting('post_views_counter_settings_display', 'post_views_counter_settings_display', array(&$this, 'validate_settings'));
238
+ add_settings_section('post_views_counter_settings_display', __('Display settings', 'post-views-counter'), '', 'post_views_counter_settings_display');
239
+ add_settings_field('pvc_post_views_label', __('Post Views Label', 'post-views-counter'), array(&$this, 'post_views_label'), 'post_views_counter_settings_display', 'post_views_counter_settings_display');
240
+ add_settings_field('pvc_post_types_display', __('Post Types Display', 'post-views-counter'), array(&$this, 'post_types_display'), 'post_views_counter_settings_display', 'post_views_counter_settings_display');
241
+ add_settings_field('pvc_restrict_display', __('Restrict Display', 'post-views-counter'), array(&$this, 'restrict_display'), 'post_views_counter_settings_display', 'post_views_counter_settings_display');
242
+ add_settings_field('pvc_position', __('Position', 'post-views-counter'), array(&$this, 'position'), 'post_views_counter_settings_display', 'post_views_counter_settings_display');
243
+ add_settings_field('pvc_display_style', __('Display Style', 'post-views-counter'), array(&$this, 'display_style'), 'post_views_counter_settings_display', 'post_views_counter_settings_display');
244
+ add_settings_field('pvc_icon_class', __('Icon Class', 'post-views-counter'), array(&$this, 'icon_class'), 'post_views_counter_settings_display', 'post_views_counter_settings_display');
245
+ }
246
+
247
+
248
+ /**
249
+ *
250
+ */
251
+ public function post_views_label()
252
+ {
253
+ echo '
254
+ <div id="pvc_post_views_label">
255
+ <fieldset>
256
+ <input type="text" class="large-text" name="post_views_counter_settings_display[label]" value="'.esc_attr(Post_Views_Counter()->get_attribute('options', 'display', 'label')).'" />
257
+ <br/>
258
+ <span class="description">'.esc_html__('Enter the label for the post views counter field.', 'post-views-counter').'</span>
259
+ </fieldset>
260
+ </div>';
261
+ }
262
+
263
+
264
+ /**
265
+ *
266
+ */
267
+ public function post_types_count()
268
+ {
269
+ echo '
270
+ <div id="pvc_post_types_count">
271
+ <fieldset>
272
+ <select class="pvc-chosen" data-placeholder="'.esc_attr__('Select post types', 'post-views-counter').'" name="post_views_counter_settings_general[post_types_count][]" multiple="multiple">';
273
+
274
+ foreach($this->post_types as $post_type => $post_type_name)
275
+ {
276
+ echo '
277
+ <option value="'.esc_attr($post_type).'" '.selected(in_array($post_type, Post_Views_Counter()->get_attribute('options', 'general', 'post_types_count'), true), true, false).'>'.esc_html($post_type_name).'</option>';
278
+ }
279
+
280
+ echo '
281
+ </select>
282
+ <br/>
283
+ <span class="description">'.esc_html__('Select post types for which post views will be counted.', 'post-views-counter').'</span>
284
+ </fieldset>
285
+ </div>';
286
+ }
287
+
288
+
289
+ /**
290
+ *
291
+ */
292
+ public function post_types_display()
293
+ {
294
+ echo '
295
+ <div id="pvc_post_types_display">
296
+ <fieldset>
297
+ <select class="pvc-chosen" data-placeholder="'.esc_attr__('Select groups', 'post-views-counter').'" name="post_views_counter_settings_display[post_types_display][]" multiple="multiple">';
298
+
299
+ foreach($this->post_types as $post_type => $post_type_name)
300
+ {
301
+ echo '
302
+ <option value="'.esc_attr($post_type).'" '.selected(in_array($post_type, Post_Views_Counter()->get_attribute('options', 'display', 'post_types_display'), true), true, false).'>'.esc_html($post_type_name).'</option>';
303
+ }
304
+
305
+ echo '
306
+ </select>
307
+ <br/>
308
+ <span class="description">'.esc_html__('Select post types for which post views will be displayed.', 'post-views-counter').'</span>
309
+ </fieldset>
310
+ </div>';
311
+ }
312
+
313
+ /**
314
+ *
315
+ */
316
+ public function counter_mode()
317
+ {
318
+ echo '
319
+ <div id="pvc_counter_mode">
320
+ <fieldset>';
321
+
322
+ foreach($this->modes as $key => $value)
323
+ {
324
+ $key = esc_attr($key);
325
+
326
+ echo '
327
+ <input id="pvc-counter-mode-'.$key.'" type="radio" name="post_views_counter_settings_general[counter_mode]" value="'.$key.'" '.checked($key, Post_Views_Counter()->get_attribute('options', 'general', 'counter_mode'), false).' /><label for="pvc-counter-mode-'.$key.'">'.esc_html($value).'</label>';
328
+ }
329
+
330
+ echo '
331
+ <br/>
332
+ <span class="description">'.esc_html__('Select the method of collecting post views data. If you are using any of the caching plugins select Javascript.', 'post-views-counter').'</span>
333
+ </fieldset>
334
+ </div>';
335
+ }
336
+
337
+
338
+ /**
339
+ *
340
+ */
341
+ public function post_views_column()
342
+ {
343
+ echo '
344
+ <div id="pvc_post_views_column">
345
+ <fieldset>';
346
+
347
+ foreach($this->choices as $key => $value)
348
+ {
349
+ $key = esc_attr($key);
350
+
351
+ echo '
352
+ <input id="pvc-post-views-column-'.$key.'" type="radio" name="post_views_counter_settings_general[post_views_column]" value="'.$key.'" '.checked($key, (Post_Views_Counter()->get_attribute('options', 'general', 'post_views_column') === true ? 'yes' : 'no'), false).' /><label for="pvc-post-views-column-'.$key.'">'.esc_html($value).'</label>';
353
+ }
354
+
355
+ echo '
356
+ <br/>
357
+ <span class="description">'.esc_html__('Enable to display post views count column for each of the selected post types.', 'post-views-counter').'</span>
358
+ </fieldset>
359
+ </div>';
360
+ }
361
+
362
+
363
+ /**
364
+ *
365
+ */
366
+ public function time_between_counts()
367
+ {
368
+ echo '
369
+ <div id="pvc_time_between_counts">
370
+ <fieldset>
371
+ <input size="4" type="text" name="post_views_counter_settings_general[time_between_counts][number]" value="'.esc_attr(Post_Views_Counter()->get_attribute('options', 'general', 'time_between_counts', 'number')).'" />
372
+ <select class="pvc-chosen-short" name="post_views_counter_settings_general[time_between_counts][type]">';
373
+
374
+ foreach($this->time_types as $type => $type_name)
375
+ {
376
+ echo '
377
+ <option value="'.esc_attr($type).'" '.selected($type, Post_Views_Counter()->get_attribute('options', 'general', 'time_between_counts', 'type'), false).'>'.esc_html($type_name).'</option>';
378
+ }
379
+
380
+ echo '
381
+ </select>
382
+ <br/>
383
+ <span class="description">'.esc_html__('Enter the time between single user visit count.', 'post-views-counter').'</span>
384
+ </fieldset>
385
+ </div>';
386
+ }
387
+
388
+
389
+ /**
390
+ *
391
+ */
392
+ public function reset_counts()
393
+ {
394
+ echo '
395
+ <div id="pvc_reset_counts">
396
+ <fieldset>
397
+ <input size="4" type="text" name="post_views_counter_settings_general[reset_counts][number]" value="'.esc_attr(Post_Views_Counter()->get_attribute('options', 'general', 'reset_counts', 'number')).'" />
398
+ <select class="pvc-chosen-short" name="post_views_counter_settings_general[reset_counts][type]">';
399
+
400
+ foreach($this->time_types as $type => $type_name)
401
+ {
402
+ echo '
403
+ <option value="'.esc_attr($type).'" '.selected($type, Post_Views_Counter()->get_attribute('options', 'general', 'reset_counts', 'type'), false).'>'.esc_html($type_name).'</option>';
404
+ }
405
+
406
+ echo '
407
+ </select>
408
+ <br/>
409
+ <span class="description">'.esc_html__('Delete single day post views data older than specified above. Enter 0 (number zero) if you want to preserve your data regardless of its age.', 'post-views-counter').'</span>
410
+ </fieldset>
411
+ </div>';
412
+ }
413
+
414
+
415
+ /**
416
+ *
417
+ */
418
+ public function exclude()
419
+ {
420
+ echo '
421
+ <div id="pvc_exclude">
422
+ <fieldset>
423
+ <select class="pvc-chosen" data-placeholder="'.esc_attr__('Select groups', 'post-views-counter').'" name="post_views_counter_settings_general[exclude][groups][]" multiple="multiple">';
424
+
425
+ foreach($this->groups as $type => $type_name)
426
+ {
427
+ echo '
428
+ <option value="'.esc_attr($type).'" '.selected(in_array($type, Post_Views_Counter()->get_attribute('options', 'general', 'exclude', 'groups'), true), true, false).'>'.esc_html($type_name).'</option>';
429
+ }
430
+
431
+ echo '
432
+ </select>
433
+ <br/>
434
+ <div class="pvc_user_roles"'.(in_array('roles', Post_Views_Counter()->get_attribute('options', 'general', 'exclude', 'groups'), true) ? '' : ' style="display: none;"').'>
435
+ <select class="pvc-chosen" data-placeholder="'.esc_attr__('Select user roles', 'post-views-counter').'" name="post_views_counter_settings_general[exclude][roles][]" multiple="multiple">';
436
+
437
+ foreach($this->user_roles as $role => $role_name)
438
+ {
439
+ echo '
440
+ <option value="'.esc_attr($role).'" '.selected(in_array($role, Post_Views_Counter()->get_attribute('options', 'general', 'exclude', 'roles'), true), true, false).'>'.esc_html($role_name).'</option>';
441
+ }
442
+
443
+ echo '
444
+ </select>
445
+ <br/>
446
+ </div>
447
+ <span class="description">'.esc_html__('Select the type of visitors to be excluded from post views count.', 'post-views-counter').'</span>
448
+ </fieldset>
449
+ </div>';
450
+ }
451
+
452
+
453
+ /**
454
+ *
455
+ */
456
+ public function exclude_ips()
457
+ {
458
+ echo '
459
+ <div id="pvc_exclude_ips">
460
+ <fieldset>';
461
+
462
+ foreach(Post_Views_Counter()->get_attribute('options', 'general', 'exclude_ips') as $key => $ip)
463
+ {
464
+ echo '
465
+ <div class="ip-box">
466
+ <input type="text" name="post_views_counter_settings_general[exclude_ips][]" value="'.esc_attr($ip).'" /> <input type="button" class="button button-secondary remove-exclude-ip" value="'.esc_attr__('Remove', 'post-views-counter').'" />
467
+ </div>';
468
+ }
469
+
470
+ // lovely php 5.2 limitations
471
+ $ips = Post_Views_Counter()->get_attribute('options', 'general', 'exclude_ips');
472
+
473
+ echo '
474
+ <div class="ip-box">
475
+ <input type="text" name="post_views_counter_settings_general[exclude_ips][]" value="" /> <input type="button" class="button button-secondary remove-exclude-ip" value="'.esc_attr__('Remove', 'post-views-counter').'"'.(empty($ips) ? ' style="display: none;"' : '').' /> <input type="button" class="button button-secondary add-exclude-ip" value="'.esc_attr__('Add new', 'post-views-counter').'" /> <input type="button" class="button button-secondary add-current-ip" value="'.esc_attr__('Add my current IP', 'post-views-counter').'" data-rel="'.esc_attr($_SERVER['REMOTE_ADDR']).'" />
476
+ </div>
477
+ <span class="description">'.esc_html__('Enter the IP addresses to be excluded from post views count.', 'post-views-counter').'</span>
478
+ </fieldset>
479
+ </div>';
480
+ }
481
+
482
+
483
+ /**
484
+ *
485
+ */
486
+ public function wp_postviews()
487
+ {
488
+ echo '
489
+ <div id="pvc_wp_postviews">
490
+ <fieldset>
491
+ <input type="submit" class="button button-secondary" name="post_views_counter_import_wp_postviews" value="'.__('Import', 'post-views-counter').'"/>
492
+ <br/>
493
+ <p class="description">'.esc_html__('Import post views data from WP-PostViews plugin.', 'post-views-counter').'</p>
494
+ <input id="pvc-wp-postviews" type="checkbox" name="post_views_counter_import_wp_postviews_override"/><label for="pvc-wp-postviews">'.esc_html__('Override existing Post Views Counter data.', 'post-views-counter').'</label>
495
+ </fieldset>
496
+ </div>';
497
+ }
498
+
499
+
500
+ /**
501
+ *
502
+ */
503
+ public function deactivation_delete()
504
+ {
505
+ echo '
506
+ <div id="pvc_deactivation_delete">
507
+ <fieldset>';
508
+
509
+ foreach($this->choices as $key => $value)
510
+ {
511
+ $key = esc_attr($key);
512
+
513
+ echo '
514
+ <input id="pvc-deactivation-delete-'.$key.'" type="radio" name="post_views_counter_settings_general[deactivation_delete]" value="'.$key.'" '.checked($key, (Post_Views_Counter()->get_attribute('options', 'general', 'deactivation_delete') === true ? 'yes' : 'no'), false).' /><label for="pvc-deactivation-delete-'.$key.'">'.esc_html($value).'</label>';
515
+ }
516
+
517
+ echo '
518
+ <br/>
519
+ <span class="description">'.esc_html__('Enable to delete all plugin data on deactivation.', 'post-views-counter').'</span>
520
+ </fieldset>
521
+ </div>';
522
+ }
523
+
524
+
525
+ /**
526
+ *
527
+ */
528
+ public function position()
529
+ {
530
+ echo '
531
+ <div id="pvc_position">
532
+ <fieldset>
533
+ <select class="pvc-chosen-short" name="post_views_counter_settings_display[position]">';
534
+
535
+ foreach($this->positions as $position => $position_name)
536
+ {
537
+ echo '
538
+ <option value="'.esc_attr($position).'" '.selected($position, Post_Views_Counter()->get_attribute('options', 'display', 'position'), false).'>'.esc_html($position_name).'</option>';
539
+ }
540
+
541
+ echo '
542
+ </select>
543
+ <br/>
544
+ <span class="description">'.esc_html__('Select where would you like to display the post views counter. Use [post-views] shortcode for manual display.', 'post-views-counter').'</span>
545
+ </fieldset>
546
+ </div>';
547
+ }
548
+
549
+
550
+ /**
551
+ *
552
+ */
553
+ public function display_style()
554
+ {
555
+ echo '
556
+ <div id="pvc_display_style">
557
+ <fieldset>';
558
+
559
+ foreach($this->display_styles as $display => $style)
560
+ {
561
+ $display = esc_attr($display);
562
+
563
+ echo '
564
+ <input id="pvc-display-style-'.$display.'" type="checkbox" name="post_views_counter_settings_display[display_style]['.$display.']" value="'.$display.'" '.checked(true, Post_Views_Counter()->get_attribute('options', 'display', 'display_style', $display), false).' /><label for="pvc-display-style-'.$display.'">'.esc_html($style).'</label>';
565
+ }
566
+
567
+ echo '
568
+ <br/>
569
+ <span class="description">'.esc_html__('Choose how to display the post views counter.', 'post-views-counter').'</span>
570
+ </fieldset>
571
+ </div>';
572
+ }
573
+
574
+
575
+ /**
576
+ *
577
+ */
578
+ public function icon_class()
579
+ {
580
+ echo '
581
+ <div id="pvc_icon_class">
582
+ <fieldset>
583
+ <input type="text" name="post_views_counter_settings_display[icon_class]" class="large-text" value="'.esc_attr(Post_Views_Counter()->get_attribute('options', 'display', 'icon_class')).'"/>
584
+ <br/>
585
+ <span class="description">'.sprintf(__('Enter the post views icon class. Any of the <a href="%s" target="_blank">Dashicons</a> classes are available.', 'post-views-counter'), 'http://melchoyce.github.io/dashicons/').'</span>
586
+ </fieldset>
587
+ </div>';
588
+ }
589
+
590
+
591
+ /**
592
+ *
593
+ */
594
+ public function restrict_display()
595
+ {
596
+ echo '
597
+ <div id="pvc_restrict_display">
598
+ <fieldset>
599
+ <select class="pvc-chosen" data-placeholder="'.esc_attr__('Select groups', 'post-views-counter').'" name="post_views_counter_settings_display[restrict_display][groups][]" multiple="multiple">';
600
+
601
+ foreach($this->groups as $type => $type_name)
602
+ {
603
+ if($type === 'robots')
604
+ continue;
605
+
606
+ echo '
607
+ <option value="'.esc_attr($type).'" '.selected(in_array($type, Post_Views_Counter()->get_attribute('options', 'display', 'restrict_display', 'groups'), true), true, false).'>'.esc_html($type_name).'</option>';
608
+ }
609
+
610
+ echo '
611
+ </select>
612
+ <br/>
613
+ <div class="pvc_user_roles"'.(in_array('roles', Post_Views_Counter()->get_attribute('options', 'display', 'restrict_display', 'groups'), true) ? '' : ' style="display: none;"').'>
614
+ <select class="pvc-chosen" data-placeholder="'.esc_attr__('Select user roles', 'post-views-counter').'" name="post_views_counter_settings_display[restrict_display][roles][]" multiple="multiple">';
615
+
616
+ foreach($this->user_roles as $role => $role_name)
617
+ {
618
+ echo '
619
+ <option value="'.esc_attr($role).'" '.selected(in_array($role, Post_Views_Counter()->get_attribute('options', 'display', 'restrict_display', 'roles'), true), true, false).'>'.esc_html($role_name).'</option>';
620
+ }
621
+
622
+ echo '
623
+ </select>
624
+ <br/>
625
+ </div>
626
+ <span class="description">'.esc_html__('Use it to hide the post views counter from selected type of visitors.', 'post-views-counter').'</span>
627
+ </fieldset>
628
+ </div>';
629
+ }
630
+
631
+
632
+ /**
633
+ * Validates general settings
634
+ */
635
+ public function validate_settings($input)
636
+ {
637
+ if(isset($_POST['post_views_counter_import_wp_postviews']))
638
+ {
639
+ global $wpdb;
640
+
641
+ $views = $wpdb->get_results(
642
+ "SELECT post_id, meta_value FROM ".$wpdb->postmeta." WHERE meta_key = 'views'",
643
+ ARRAY_A,
644
+ 0
645
+ );
646
+
647
+ if(!empty($views))
648
+ {
649
+ $input = Post_Views_Counter()->get_attribute('defaults', 'general');
650
+ $input['wp_postviews_import'] = true;
651
+
652
+ $sql = '';
653
+
654
+ foreach($views as $view)
655
+ {
656
+ $sql[] = "(".$view['post_id'].", 4, 'total', ".$view['meta_value'].")";
657
+ }
658
+
659
+ $wpdb->query("INSERT INTO ".$wpdb->prefix."post_views(id, type, period, count) VALUES ".implode(',', $sql)." ON DUPLICATE KEY UPDATE count = ".(isset($_POST['post_views_counter_import_wp_postviews_override']) ? '' : 'count + ')."VALUES(count)");
660
+
661
+ add_settings_error('wp_postviews_import', 'wp_postviews_import', __('WP-PostViews data imported succesfully.', 'post-views-counter'), 'updated');
662
+ }
663
+ else
664
+ {
665
+ add_settings_error('wp_postviews_import', 'wp_postviews_import', __('There was no data to import.', 'post-views-counter'), 'updated');
666
+ }
667
+ }
668
+ elseif(isset($_POST['save_pvc_general']))
669
+ {
670
+ // post types count
671
+ if(isset($input['post_types_count']))
672
+ {
673
+ $post_types = array();
674
+
675
+ foreach($input['post_types_count'] as $post_type)
676
+ {
677
+ if(isset($this->post_types[$post_type]))
678
+ $post_types[] = $post_type;
679
+ }
680
+
681
+ $input['post_types_count'] = array_unique($post_types);
682
+ }
683
+ else
684
+ $input['post_types_count'] = array();
685
+
686
+ // counter mode
687
+ $input['counter_mode'] = (isset($input['counter_mode'], $this->modes[$input['counter_mode']]) ? $input['counter_mode'] : Post_Views_Counter()->get_attribute('defaults', 'general', 'counter_mode'));
688
+
689
+ // post views column
690
+ $input['post_views_column'] = (isset($input['post_views_column'], $this->choices[$input['post_views_column']]) ? ($input['post_views_column'] === 'yes' ? true : false) : Post_Views_Counter()->get_attribute('defaults', 'general', 'post_views_column'));
691
+
692
+ // time between counts
693
+ $input['time_between_counts']['number'] = (int)(isset($input['time_between_counts']['number']) ? $input['time_between_counts']['number'] : Post_Views_Counter()->get_attribute('defaults', 'general', 'time_between_counts', 'number'));
694
+ $input['time_between_counts']['type'] = (isset($input['time_between_counts']['type'], $this->time_types[$input['time_between_counts']['type']]) ? $input['time_between_counts']['type'] : Post_Views_Counter()->get_attribute('defaults', 'general', 'time_between_counts', 'type'));
695
+
696
+ // reset counts
697
+ $input['reset_counts']['number'] = (int)(isset($input['reset_counts']['number']) ? $input['reset_counts']['number'] : Post_Views_Counter()->get_attribute('defaults', 'general', 'reset_counts', 'number'));
698
+ $input['reset_counts']['type'] = (isset($input['reset_counts']['type'], $this->time_types[$input['reset_counts']['type']]) ? $input['reset_counts']['type'] : Post_Views_Counter()->get_attribute('defaults', 'general', 'reset_counts', 'type'));
699
+
700
+ // run cron on next visit?
701
+ $input['cron_run'] = ($input['reset_counts']['number'] > 0 ? true : false);
702
+ $input['cron_update'] = ($input['cron_run'] && (Post_Views_Counter()->get_attribute('options', 'general', 'reset_counts', 'number') !== $input['reset_counts']['number'] || Post_Views_Counter()->get_attribute('options', 'general', 'reset_counts', 'type') !== $input['reset_counts']['type']) ? true : false);
703
+
704
+ // exclude
705
+ if(isset($input['exclude']['groups']))
706
+ {
707
+ $groups = array();
708
+
709
+ foreach($input['exclude']['groups'] as $group)
710
+ {
711
+ if(isset($this->groups[$group]))
712
+ $groups[] = $group;
713
+ }
714
+
715
+ $input['exclude']['groups'] = array_unique($groups);
716
+ }
717
+ else
718
+ $input['exclude']['groups'] = array();
719
+
720
+ if(in_array('roles', $input['exclude']['groups'], true) && isset($input['exclude']['roles']))
721
+ {
722
+ $roles = array();
723
+
724
+ foreach($input['exclude']['roles'] as $role)
725
+ {
726
+ if(isset($this->user_roles[$role]))
727
+ $roles[] = $role;
728
+ }
729
+
730
+ $input['exclude']['roles'] = array_unique($roles);
731
+ }
732
+ else
733
+ $input['exclude']['roles'] = array();
734
+
735
+ // exclude ips
736
+ if(isset($input['exclude_ips']))
737
+ {
738
+ $ips = array();
739
+
740
+ foreach($input['exclude_ips'] as $ip)
741
+ {
742
+ if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4))
743
+ $ips[] = $ip;
744
+ }
745
+
746
+ $input['exclude_ips'] = array_unique($ips);
747
+ }
748
+
749
+ // deactivation delete
750
+ $input['deactivation_delete'] = (isset($input['deactivation_delete'], $this->choices[$input['deactivation_delete']]) ? ($input['deactivation_delete'] === 'yes' ? true : false) : Post_Views_Counter()->get_attribute('defaults', 'general', 'deactivation_delete'));
751
+ }
752
+ elseif(isset($_POST['save_pvc_display']))
753
+ {
754
+ // post views label
755
+ $input['label'] = (isset($input['label']) ? $input['label'] : Post_Views_Counter()->get_attribute('defaults', 'general', 'label'));
756
+
757
+ if(function_exists('icl_register_string'))
758
+ icl_register_string('Post Views Counter', 'Post Views Label', $input['label']);
759
+
760
+ // position
761
+ $input['position'] = (isset($input['position'], $this->positions[$input['position']]) ? $input['position'] : Post_Views_Counter()->get_attribute('defaults', 'general', 'position'));
762
+
763
+ // display style
764
+ $input['display_style']['icon'] = (isset($input['display_style']['icon']) ? true : false);
765
+ $input['display_style']['text'] = (isset($input['display_style']['text']) ? true : false);
766
+
767
+ // link to post
768
+ $input['link_to_post'] = (isset($input['link_to_post'], $this->choices[$input['link_to_post']]) ? ($input['link_to_post'] === 'yes' ? true : false) : Post_Views_Counter()->get_attribute('defaults', 'general', 'link_to_post'));
769
+
770
+ // icon class
771
+ $input['icon_class'] = (isset($input['icon_class']) ? trim($input['icon_class']) : Post_Views_Counter()->get_attribute('defaults', 'general', 'icon_class'));
772
+
773
+ // post types display
774
+ if(isset($input['post_types_display']))
775
+ {
776
+ $post_types = array();
777
+
778
+ foreach($input['post_types_display'] as $post_type)
779
+ {
780
+ if(isset($this->post_types[$post_type]))
781
+ $post_types[] = $post_type;
782
+ }
783
+
784
+ $input['post_types_display'] = array_unique($post_types);
785
+ }
786
+ else
787
+ $input['post_types_display'] = array();
788
+
789
+ // restrict display
790
+ if(isset($input['restrict_display']['groups']))
791
+ {
792
+ $groups = array();
793
+
794
+ foreach($input['restrict_display']['groups'] as $group)
795
+ {
796
+ if($group === 'robots')
797
+ continue;
798
+
799
+ if(isset($this->groups[$group]))
800
+ $groups[] = $group;
801
+ }
802
+
803
+ $input['restrict_display']['groups'] = array_unique($groups);
804
+ }
805
+ else
806
+ $input['restrict_display']['groups'] = array();
807
+
808
+ if(in_array('roles', $input['restrict_display']['groups'], true) && isset($input['restrict_display']['roles']))
809
+ {
810
+ $roles = array();
811
+
812
+ foreach($input['restrict_display']['roles'] as $role)
813
+ {
814
+ if(isset($this->user_roles[$role]))
815
+ $roles[] = $role;
816
+ }
817
+
818
+ $input['restrict_display']['roles'] = array_unique($roles);
819
+ }
820
+ else
821
+ $input['restrict_display']['roles'] = array();
822
+ }
823
+ elseif(isset($_POST['reset_pvc_general']))
824
+ {
825
+ $input = Post_Views_Counter()->get_attribute('defaults', 'general');
826
+
827
+ add_settings_error('reset_general_settings', 'settings_reset', __('General settings restored to defaults.', 'post-views-counter'), 'updated');
828
+ }
829
+ elseif(isset($_POST['reset_pvc_display']))
830
+ {
831
+ $input = Post_Views_Counter()->get_attribute('defaults', 'display');
832
+
833
+ add_settings_error('reset_general_settings', 'settings_reset', __('Display settings restored to defaults.', 'post-views-counter'), 'updated');
834
+ }
835
+
836
+ return $input;
837
+ }
838
+
839
+
840
+ /**
841
+ * Adds links to Support Forum
842
+ */
843
+ public function plugin_extend_links($links, $file)
844
+ {
845
+ if(!current_user_can('install_plugins'))
846
+ return $links;
847
+
848
+ $plugin = plugin_basename(__FILE__);
849
+
850
+ if($file == $plugin)
851
+ {
852
+ return array_merge(
853
+ $links,
854
+ array(sprintf('<a href="http://www.dfactory.eu/support/forum/post-views-counter/" target="_blank">%s</a>', __('Support', 'post-views-counter')))
855
+ );
856
+ }
857
+
858
+ return $links;
859
+ }
860
+ }
861
+ ?>
includes/update.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(!defined('ABSPATH')) exit;
3
+
4
+ new Post_Views_Counter_Update();
5
+
6
+ class Post_Views_Counter_Update
7
+ {
8
+ public function __construct()
9
+ {
10
+ // actions
11
+ add_action('init', array(&$this, 'check_update'));
12
+ }
13
+
14
+
15
+ /**
16
+ *
17
+ */
18
+ public function check_update()
19
+ {
20
+ if(!current_user_can('manage_options'))
21
+ return;
22
+
23
+ // gets current database version
24
+ $current_db_version = get_option('post_views_counter_version', '1.0.0');
25
+
26
+ // new version?
27
+ if(version_compare($current_db_version, Post_Views_Counter()->get_attribute('defaults', 'version'), '<'))
28
+ {
29
+ // updates plugin version
30
+ update_option('post_views_counter_version', Post_Views_Counter()->get_attribute('defaults', 'version'));
31
+ }
32
+ }
33
+ }
34
+ ?>
includes/widgets.php ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(!defined('ABSPATH')) exit;
3
+
4
+ new Post_Views_Counter_Widgets();
5
+
6
+ class Post_Views_Counter_Widgets
7
+ {
8
+ public function __construct()
9
+ {
10
+ // actions
11
+ add_action('widgets_init', array(&$this, 'register_widgets'));
12
+ }
13
+
14
+
15
+ /**
16
+ *
17
+ */
18
+ public function register_widgets()
19
+ {
20
+ register_widget('Post_Views_Counter_List_Widget');
21
+ }
22
+ }
23
+
24
+
25
+ class Post_Views_Counter_List_Widget extends WP_Widget
26
+ {
27
+ private $pvc_options;
28
+ private $pvc_defaults;
29
+ private $pvc_post_types;
30
+ private $pvc_order_types;
31
+ private $pvc_image_sizes;
32
+
33
+
34
+ public function __construct()
35
+ {
36
+ parent::__construct(
37
+ 'Post_Views_Counter_List_Widget',
38
+ __('Most Viewed Posts', 'post-views-counter'),
39
+ array(
40
+ 'description' => __('Displays a list of the most viewed posts', 'post-views-counter')
41
+ )
42
+ );
43
+
44
+ $this->pvc_options = array_merge(
45
+ array('general' => get_option('events_maker_general'))
46
+ );
47
+
48
+ $this->pvc_defaults = array(
49
+ 'title' => __('Most Viewed Posts', 'post-views-counter'),
50
+ 'number_of_posts' => 5,
51
+ 'thumbnail_size' => 'thumbnail',
52
+ 'post_types' => array(),
53
+ 'order' => 'desc',
54
+ 'show_post_views' => true,
55
+ 'show_post_thumbnail' => false,
56
+ 'show_post_excerpt' => false,
57
+ 'no_posts_message' => __('No Posts found', 'post-views-counter')
58
+ );
59
+
60
+ $this->pvc_order_types = array(
61
+ 'asc' => __('Ascending', 'post-views-counter'),
62
+ 'desc' => __('Descending', 'post-views-counter')
63
+ );
64
+
65
+ $this->pvc_image_sizes = array_merge(array('full'), get_intermediate_image_sizes());
66
+
67
+ // sorts image sizes ascending by name
68
+ sort($this->pvc_image_sizes, SORT_STRING);
69
+
70
+ add_action('wp_loaded', array(&$this, 'load_post_types'));
71
+ }
72
+
73
+
74
+ /**
75
+ *
76
+ */
77
+ public function load_post_types()
78
+ {
79
+ $this->pvc_post_types = Post_Views_Counter()->get_instance('settings')->post_types;
80
+ }
81
+
82
+
83
+ /**
84
+ *
85
+ */
86
+ public function widget($args, $instance)
87
+ {
88
+ $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
89
+
90
+ $html = $args['before_widget'].(!empty($instance['title']) ? $args['before_title'].$instance['title'].$args['after_title'] : '');
91
+ $html .= pvc_most_viewed_posts($instance, false);
92
+ $html .= $args['after_widget'];
93
+
94
+ echo $html;
95
+ }
96
+
97
+
98
+ /**
99
+ *
100
+ */
101
+ public function form($instance)
102
+ {
103
+ $html = '
104
+ <p>
105
+ <label for="'.$this->get_field_id('title').'">'.__('Title', 'post-views-counter').':</label>
106
+ <input id="'.$this->get_field_id('title').'" class="widefat" name="'.$this->get_field_name('title').'" type="text" value="'.esc_attr(isset($instance['title']) ? $instance['title'] : $this->pvc_defaults['title']).'" />
107
+ </p>
108
+ <p>
109
+ <label>'.__('Post types', 'post-views-counter').':</label><br />';
110
+
111
+ foreach($this->pvc_post_types as $post_type => $post_type_name)
112
+ {
113
+ $html .= '
114
+ <input id="'.$this->get_field_id('post_types').'-'.$post_type.'" type="checkbox" name="'.$this->get_field_name('post_types').'[]" value="'.$post_type.'" '.checked((!isset($instance['post_types']) ? true : in_array($post_type, $instance['post_types'], true)), true, false).'><label for="'.$this->get_field_id('post_types').'-'.$post_type.'">'.esc_html($post_type_name).'</label>';
115
+ }
116
+
117
+ $show_post_thumbnail = (isset($instance['show_post_thumbnail']) ? $instance['show_post_thumbnail'] : $this->pvc_defaults['show_post_thumbnail']);
118
+
119
+ $html .= '
120
+ </select>
121
+ </p>
122
+ <p>
123
+ <label for="'.$this->get_field_id('number_of_posts').'">'.__('Number of posts to show', 'post-views-counter').':</label>
124
+ <input id="'.$this->get_field_id('number_of_posts').'" name="'.$this->get_field_name('number_of_posts').'" type="text" size="3" value="'.esc_attr(isset($instance['number_of_posts']) ? $instance['number_of_posts'] : $this->pvc_defaults['number_of_posts']).'" />
125
+ </p>
126
+ <p>
127
+ <label for="'.$this->get_field_id('no_posts_message').'">'.__('No posts message', 'post-views-counter').':</label>
128
+ <input id="'.$this->get_field_id('no_posts_message').'" class="widefat" type="text" name="'.$this->get_field_name('no_posts_message').'" value="'.esc_attr(isset($instance['no_posts_message']) ? $instance['no_posts_message'] : $this->pvc_defaults['no_posts_message']).'" />
129
+ </p>
130
+ <p>
131
+ <label for="'.$this->get_field_id('order').'">'.__('Order', 'post-views-counter').':</label>
132
+ <select id="'.$this->get_field_id('order').'" name="'.$this->get_field_name('order').'">';
133
+
134
+ foreach($this->pvc_order_types as $id => $order)
135
+ {
136
+ $html .= '
137
+ <option value="'.esc_attr($id).'" '.selected($id, (isset($instance['order']) ? $instance['order'] : $this->pvc_defaults['order']), false).'>'.$order.'</option>';
138
+ }
139
+
140
+ $html .= '
141
+ </select>
142
+ </p>
143
+ <p>
144
+ <input id="'.$this->get_field_id('show_post_views').'" type="checkbox" name="'.$this->get_field_name('show_post_views').'" '.checked(true, (isset($instance['show_post_views']) ? $instance['show_post_views'] : $this->pvc_defaults['show_post_views']), false).' /> <label for="'.$this->get_field_id('show_post_views').'">'.__('Display post views?', 'post-views-counter').'</label>
145
+ <br />
146
+ <input id="'.$this->get_field_id('show_post_excerpt').'" type="checkbox" name="'.$this->get_field_name('show_post_excerpt').'" '.checked(true, (isset($instance['show_post_excerpt']) ? $instance['show_post_excerpt'] : $this->pvc_defaults['show_post_excerpt']), false).' /> <label for="'.$this->get_field_id('show_post_excerpt').'">'.__('Display post excerpt?', 'post-views-counter').'</label>
147
+ <br />
148
+ <input id="'.$this->get_field_id('show_post_thumbnail').'" class="em-show-event-thumbnail" type="checkbox" name="'.$this->get_field_name('show_post_thumbnail').'" '.checked(true, $show_post_thumbnail, false).' /> <label for="'.$this->get_field_id('show_post_thumbnail').'">'.__('Display post thumbnail?', 'post-views-counter').'</label>
149
+ </p>
150
+ <p class="em-event-thumbnail-size"'.($show_post_thumbnail ? '' : ' style="display: none;"').'>
151
+ <label for="'.$this->get_field_id('thumbnail_size').'">'.__('Thumbnail size', 'post-views-counter').':</label>
152
+ <select id="'.$this->get_field_id('thumbnail_size').'" name="'.$this->get_field_name('thumbnail_size').'">';
153
+
154
+ $size_type = (isset($instance['thumbnail_size']) ? $instance['thumbnail_size'] : $this->pvc_defaults['thumbnail_size']);
155
+
156
+ foreach($this->pvc_image_sizes as $size)
157
+ {
158
+ $html .= '
159
+ <option value="'.esc_attr($size).'" '.selected($size, $size_type, false).'>'.$size.'</option>';
160
+ }
161
+
162
+ $html .= '
163
+ </select>
164
+ </p>';
165
+
166
+ echo $html;
167
+ }
168
+
169
+
170
+ /**
171
+ *
172
+ */
173
+ public function update($new_instance, $old_instance)
174
+ {
175
+ // number of events
176
+ $old_instance['number_of_posts'] = (int)(isset($new_instance['number_of_posts']) ? $new_instance['number_of_posts'] : $this->pvc_defaults['number_of_posts']);
177
+
178
+ // order
179
+ $old_instance['order'] = (isset($new_instance['order']) && in_array($new_instance['order'], array_keys($this->pvc_order_types), true) ? $new_instance['order'] : $this->pvc_defaults['order']);
180
+
181
+ // thumbnail size
182
+ $old_instance['thumbnail_size'] = (isset($new_instance['thumbnail_size']) && in_array($new_instance['thumbnail_size'], $this->pvc_image_sizes, true) ? $new_instance['thumbnail_size'] : $this->pvc_defaults['thumbnail_size']);
183
+
184
+ // booleans
185
+ $old_instance['show_post_views'] = (isset($new_instance['show_post_views']) ? true : false);
186
+ $old_instance['show_post_thumbnail'] = (isset($new_instance['show_post_thumbnail']) ? true : false);
187
+ $old_instance['show_post_excerpt'] = (isset($new_instance['show_post_excerpt']) ? true : false);
188
+
189
+ // texts
190
+ $old_instance['title'] = sanitize_text_field(isset($new_instance['title']) ? $new_instance['title'] : $this->pvc_defaults['title']);
191
+ $old_instance['no_posts_message'] = sanitize_text_field(isset($new_instance['no_posts_message']) ? $new_instance['no_posts_message'] : $this->pvc_defaults['no_posts_message']);
192
+
193
+ // post types
194
+ if(isset($new_instance['post_types']))
195
+ {
196
+ $post_types = array();
197
+
198
+ foreach($new_instance['post_types'] as $post_type)
199
+ {
200
+ if(isset($this->pvc_post_types[$post_type]))
201
+ $post_types[] = $post_type;
202
+ }
203
+
204
+ $old_instance['post_types'] = array_unique($post_types);
205
+ }
206
+ else
207
+ $old_instance['post_types'] = array('post');
208
+
209
+ return $old_instance;
210
+ }
211
+ }
212
+ ?>
index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ ?>
js/admin.js ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+
3
+ // default chosen
4
+ $('.pvc-chosen').chosen({
5
+ disable_search_threshold: 8,
6
+ display_selected_options: false,
7
+ search_contains: true,
8
+ width: '300px'
9
+ });
10
+
11
+
12
+ // time types and position
13
+ $('.pvc-chosen-short').chosen({
14
+ disable_search_threshold: 8,
15
+ width: '200px'
16
+ });
17
+
18
+
19
+ // ask whether reset options to defaults
20
+ $(document).on('click', '.reset_pvc_settings', function() {
21
+ return confirm(pvcArgsSettings.resetToDefaults);
22
+ });
23
+
24
+
25
+ // removes ip box
26
+ $(document).on('click', '.remove-exclude-ip', function() {
27
+ var parent = $(this).parent(),
28
+ nextParent = parent.parent(),
29
+ addButton = parent.find('.add-exclude-ip').hide(),
30
+ addCurrentIPButton = parent.find('.add-current-ip').hide();
31
+
32
+ // removes ip box
33
+ parent.remove();
34
+
35
+ var children = nextParent.find('div');
36
+
37
+ // was there add button?
38
+ if(addButton.length === 1) {
39
+ children.last().append(addButton.show(), ' ', addCurrentIPButton.show());
40
+ // children.last().append();
41
+ }
42
+
43
+ // only one ip box left?
44
+ if(children.length === 1) {
45
+ children.find('.remove-exclude-ip').hide();
46
+ }
47
+ });
48
+
49
+
50
+ // adds ip box
51
+ $(document).on('click', '.add-exclude-ip', function() {
52
+ var parent = $(this).parent(),
53
+ newBox = parent.clone().hide();
54
+
55
+ // clears value
56
+ newBox.find('input').first().val('');
57
+
58
+ // removes add buttons
59
+ $(this).remove();
60
+ parent.find('.add-current-ip').remove();
61
+
62
+ // adds and displays new ip box
63
+ parent.after(newBox.show());
64
+
65
+ parent.parent().find('.remove-exclude-ip').show();
66
+ });
67
+
68
+
69
+ // adds current ip
70
+ $(document).on('click', '.add-current-ip', function() {
71
+ // fills input with user's current ip
72
+ $(this).parent().find('input').first().val($(this).attr('data-rel'));
73
+ });
74
+
75
+
76
+ // displays user roles if needed
77
+ $(document).on('change', '.pvc-chosen-groups', function() {
78
+ var foundRoles = false;
79
+
80
+ // checks whether roles are selected
81
+ $(this).find(':selected').each(function(i, item) {
82
+ if(item.value === 'roles') {
83
+ foundRoles = true;
84
+ }
85
+ });
86
+
87
+ // are roles selected?
88
+ if(foundRoles) {
89
+ $(this).parent().find('.pvc_user_roles').fadeIn(300);
90
+ } else {
91
+ $(this).parent().find('.pvc_user_roles').fadeOut(300);
92
+ }
93
+ });
94
+ });
js/frontend.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+
3
+ $.post(pvcArgsFrontend.ajaxURL, {
4
+ action: 'pvc-check-post',
5
+ pvc_nonce: pvcArgsFrontend.nonce,
6
+ post_id: pvcArgsFrontend.postID,
7
+ post_type: pvcArgsFrontend.postType
8
+ });
9
+ });
languages/post-views-counter-pl_PL.mo ADDED
Binary file
languages/post-views-counter-pl_PL.po ADDED
@@ -0,0 +1,670 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Post Views Counter\n"
4
+ "POT-Creation-Date: 2014-07-03 01:06+0100\n"
5
+ "PO-Revision-Date: 2014-07-03 01:07+0100\n"
6
+ "Last-Translator: Bartosz Arendt <info@dfactory.eu>\n"
7
+ "Language-Team: dFactory <info@dfactory.eu>\n"
8
+ "Language: pl_PL\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.6.5\n"
13
+ "X-Poedit-KeywordsList: gettext;gettext_noop;__;_e;esc_attr__;esc_attr_e;"
14
+ "esc_html__;esc_html_e\n"
15
+ "X-Poedit-Basepath: .\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "X-Poedit-SearchPath-0: ..\n"
19
+
20
+ #: ../includes/columns.php:113 ../includes/columns.php:121
21
+ msgid "Post Views"
22
+ msgstr "Odwiedziny"
23
+
24
+ #: ../includes/cron.php:40
25
+ msgid "Post Views Counter reset daily counts interval"
26
+ msgstr ""
27
+
28
+ #: ../includes/functions.php:114
29
+ msgid "No Posts"
30
+ msgstr "Brak wpisów"
31
+
32
+ #: ../includes/settings.php:41
33
+ msgid "Enable"
34
+ msgstr "Włącz"
35
+
36
+ #: ../includes/settings.php:42
37
+ msgid "Disable"
38
+ msgstr "Wyłącz"
39
+
40
+ #: ../includes/settings.php:46
41
+ msgid "PHP"
42
+ msgstr "PHP"
43
+
44
+ #: ../includes/settings.php:47
45
+ msgid "JavaScript"
46
+ msgstr "JavaScript"
47
+
48
+ #: ../includes/settings.php:51
49
+ msgid "minutes"
50
+ msgstr "minuty"
51
+
52
+ #: ../includes/settings.php:52
53
+ msgid "hours"
54
+ msgstr "godziny"
55
+
56
+ #: ../includes/settings.php:53
57
+ msgid "days"
58
+ msgstr "dni"
59
+
60
+ #: ../includes/settings.php:54
61
+ msgid "weeks"
62
+ msgstr "tygodnie"
63
+
64
+ #: ../includes/settings.php:55
65
+ msgid "months"
66
+ msgstr "miesiące"
67
+
68
+ #: ../includes/settings.php:56
69
+ msgid "years"
70
+ msgstr "lata"
71
+
72
+ #: ../includes/settings.php:60
73
+ msgid "robots"
74
+ msgstr "roboty"
75
+
76
+ #: ../includes/settings.php:61
77
+ msgid "logged in users"
78
+ msgstr "zalogowani użytkownicy"
79
+
80
+ #: ../includes/settings.php:62
81
+ msgid "guests"
82
+ msgstr "goście"
83
+
84
+ #: ../includes/settings.php:63
85
+ msgid "selected user roles"
86
+ msgstr "wybrane role użytkowników"
87
+
88
+ #: ../includes/settings.php:67
89
+ msgid "before the content"
90
+ msgstr "przed treścią"
91
+
92
+ #: ../includes/settings.php:68
93
+ msgid "after the content"
94
+ msgstr "po treści"
95
+
96
+ #: ../includes/settings.php:69
97
+ msgid "manual"
98
+ msgstr "ręcznie"
99
+
100
+ #: ../includes/settings.php:73
101
+ msgid "icon"
102
+ msgstr "ikona"
103
+
104
+ #: ../includes/settings.php:74
105
+ msgid "label"
106
+ msgstr "etykieta"
107
+
108
+ #: ../includes/settings.php:79
109
+ msgid "General"
110
+ msgstr "Ogólne"
111
+
112
+ #: ../includes/settings.php:85
113
+ msgid "Display"
114
+ msgstr "Wyświetlanie"
115
+
116
+ #: ../includes/settings.php:149 ../includes/settings.php:150
117
+ #: ../includes/settings.php:167 ../includes/settings.php:180
118
+ msgid "Post Views Counter"
119
+ msgstr "Licznik odwiedzin"
120
+
121
+ #: ../includes/settings.php:182
122
+ msgid "Need support?"
123
+ msgstr "Potrzebujesz pomocy?"
124
+
125
+ #: ../includes/settings.php:183
126
+ msgid ""
127
+ "If you are having problems with this plugin, please talk about them in the"
128
+ msgstr "Jeśli masz jakieś problemy z tą wtyczką, powiedz o nich"
129
+
130
+ #: ../includes/settings.php:183
131
+ msgid "Support forum"
132
+ msgstr "Forum pomocy"
133
+
134
+ #: ../includes/settings.php:185
135
+ msgid "Do you like this plugin?"
136
+ msgstr "Lubisz tę wtyczkę?"
137
+
138
+ #: ../includes/settings.php:186
139
+ msgid "Rate it 5"
140
+ msgstr "Oceń ją na 5"
141
+
142
+ #: ../includes/settings.php:186
143
+ msgid "on WordPress.org"
144
+ msgstr "na WordPress.org"
145
+
146
+ #: ../includes/settings.php:187
147
+ msgid "Blog about it & link to the"
148
+ msgstr "Napisz o niej i dodaj link"
149
+
150
+ #: ../includes/settings.php:187
151
+ msgid "plugin page"
152
+ msgstr "do strony wtyczki"
153
+
154
+ #: ../includes/settings.php:188
155
+ msgid "Check out our other"
156
+ msgstr "Sprawdż nasze inne"
157
+
158
+ #: ../includes/settings.php:188
159
+ msgid "WordPress plugins"
160
+ msgstr "wtyczki do WordPressa"
161
+
162
+ #: ../includes/settings.php:191
163
+ msgid "Created by"
164
+ msgstr "Stworzone przez"
165
+
166
+ #: ../includes/settings.php:207
167
+ msgid "Reset to defaults"
168
+ msgstr "Resetuj do domyślnych"
169
+
170
+ #: ../includes/settings.php:225
171
+ msgid "General settings"
172
+ msgstr "Ustawienia ogólne"
173
+
174
+ #: ../includes/settings.php:226
175
+ msgid "Post Types Count"
176
+ msgstr "Własne typy wpisów"
177
+
178
+ #: ../includes/settings.php:227
179
+ msgid "Counter Mode"
180
+ msgstr "Tryb pracy licznika"
181
+
182
+ #: ../includes/settings.php:228
183
+ msgid "Post Views Column"
184
+ msgstr "Kolumna z liczbą odwiedzin"
185
+
186
+ #: ../includes/settings.php:229
187
+ msgid "Time Between Counts"
188
+ msgstr "Czas między zliczaniem"
189
+
190
+ #: ../includes/settings.php:230
191
+ msgid "Reset Data"
192
+ msgstr "Resetowanie danych"
193
+
194
+ #: ../includes/settings.php:231
195
+ msgid "Exclude Visitors"
196
+ msgstr "Wykluczanie odwiedzających"
197
+
198
+ #: ../includes/settings.php:232
199
+ msgid "Exclude IPs"
200
+ msgstr "Wykluczanie IP"
201
+
202
+ #: ../includes/settings.php:233
203
+ msgid "WP-PostViews"
204
+ msgstr "WP-PostViews"
205
+
206
+ #: ../includes/settings.php:234
207
+ msgid "Deactivation"
208
+ msgstr "Deaktywacja wtyczki"
209
+
210
+ #: ../includes/settings.php:238
211
+ msgid "Display settings"
212
+ msgstr "Ustawienia wyświetlania"
213
+
214
+ #: ../includes/settings.php:239
215
+ msgid "Post Views Label"
216
+ msgstr "Etykieta licznika"
217
+
218
+ #: ../includes/settings.php:240
219
+ msgid "Post Types Display"
220
+ msgstr "Wyświetlanie licznika"
221
+
222
+ #: ../includes/settings.php:241
223
+ msgid "Restrict Display"
224
+ msgstr "Ograniczenia wyświetlania"
225
+
226
+ #: ../includes/settings.php:242
227
+ msgid "Position"
228
+ msgstr "Pozycja"
229
+
230
+ #: ../includes/settings.php:243
231
+ msgid "Display Style"
232
+ msgstr "Styl wyświetlania"
233
+
234
+ #: ../includes/settings.php:244
235
+ msgid "Icon Class"
236
+ msgstr "Klasa ikony"
237
+
238
+ #: ../includes/settings.php:258
239
+ msgid "Enter the label for the post views counter field."
240
+ msgstr "Wpisz etykietę jaka będzie wyświetlana w liczniku odwiedzin wpisu."
241
+
242
+ #: ../includes/settings.php:272
243
+ msgid "Select post types"
244
+ msgstr "Wybierz typy wpisów"
245
+
246
+ #: ../includes/settings.php:283
247
+ msgid "Select post types for which post views will be counted."
248
+ msgstr "Wybierz typy wpisów dla których będzie włączone zliczanie."
249
+
250
+ #: ../includes/settings.php:297 ../includes/settings.php:423
251
+ #: ../includes/settings.php:599
252
+ msgid "Select groups"
253
+ msgstr "Wybierz grupy"
254
+
255
+ #: ../includes/settings.php:308
256
+ msgid "Select post types for which post views will be displayed."
257
+ msgstr "Wybierz typy wpisów dla których licznik będzie wyświetlony."
258
+
259
+ #: ../includes/settings.php:332
260
+ msgid ""
261
+ "Select the method of collecting post views data. If you are using any of the "
262
+ "caching plugins select Javascript."
263
+ msgstr ""
264
+ "Wybierz metodę gromadzenia danych. Jeśli używaż jakiejkolwiek wtyczki do "
265
+ "cachowania wybierz Javascript."
266
+
267
+ #: ../includes/settings.php:357
268
+ msgid ""
269
+ "Enable to display post views count column for each of the selected post "
270
+ "types."
271
+ msgstr "Włącz aby wyświetlić kolumnę z liczbą odsłon."
272
+
273
+ #: ../includes/settings.php:383
274
+ msgid "Enter the time between single user visit count."
275
+ msgstr "Określ czas pomiędzy zliczaniem wizyt poszczególnego użytkownika."
276
+
277
+ #: ../includes/settings.php:409
278
+ msgid ""
279
+ "Delete single day post views data older than specified above. Enter 0 "
280
+ "(number zero) if you want to preserve your data regardless of its age."
281
+ msgstr ""
282
+ "Usuwanie dziennych danych o liczbie wpisów po określonym powyżej czasie. "
283
+ "Wpisz 0 jeśli chcesz przetrzymywać te dane bez ograniczeń."
284
+
285
+ #: ../includes/settings.php:435 ../includes/settings.php:614
286
+ msgid "Select user roles"
287
+ msgstr "Wybierz role użytkowników"
288
+
289
+ #: ../includes/settings.php:447
290
+ msgid "Select the type of visitors to be excluded from post views count."
291
+ msgstr "Wybierz typy użytkowników wyłączonych z działania licznika."
292
+
293
+ #: ../includes/settings.php:466 ../includes/settings.php:475
294
+ msgid "Remove"
295
+ msgstr "Usuń"
296
+
297
+ #: ../includes/settings.php:475
298
+ msgid "Add new"
299
+ msgstr "Dodaj nowy"
300
+
301
+ #: ../includes/settings.php:475
302
+ msgid "Add my current IP"
303
+ msgstr "Dodaj mój aktualny IP"
304
+
305
+ #: ../includes/settings.php:477
306
+ msgid "Enter the IP addresses to be excluded from post views count."
307
+ msgstr "Wpisz adresy IP, któe mają być wyłączone z działania licznika."
308
+
309
+ #: ../includes/settings.php:491
310
+ msgid "Import"
311
+ msgstr "Importuj"
312
+
313
+ #: ../includes/settings.php:493
314
+ msgid "Import post views data from WP-PostViews plugin."
315
+ msgstr ""
316
+
317
+ #: ../includes/settings.php:494
318
+ #, fuzzy
319
+ msgid "Override existing Post Views Counter data."
320
+ msgstr "Licznik odwiedzin"
321
+
322
+ #: ../includes/settings.php:519
323
+ msgid "Enable to delete all plugin data on deactivation."
324
+ msgstr "Włącz aby usunąć wszystkie dane wtyczki podczas deaktywacji"
325
+
326
+ #: ../includes/settings.php:544
327
+ msgid ""
328
+ "Select where would you like to display the post views counter. Use [post-"
329
+ "views] shortcode for manual display."
330
+ msgstr ""
331
+ "Wybierz w którym miejscu chcesz wyświetlać licznik odwiedzin. Użyj skrótu "
332
+ "[post-views] aby wyświetlić licznik ręcznie."
333
+
334
+ #: ../includes/settings.php:569
335
+ msgid "Choose how to display the post views counter."
336
+ msgstr "Wybierz w jaki sposób chcesz wyświetlać licznik."
337
+
338
+ #: ../includes/settings.php:585
339
+ #, php-format
340
+ msgid ""
341
+ "Enter the post views icon class. Any of the <a href=\"%s\" target=\"_blank"
342
+ "\">Dashicons</a> classes are available."
343
+ msgstr ""
344
+
345
+ #: ../includes/settings.php:626
346
+ msgid "Use it to hide the post views counter from selected type of visitors."
347
+ msgstr ""
348
+ "Użyj tego aby ograniczyć wyświetlanie licznika do określonych typów "
349
+ "użytkowników."
350
+
351
+ #: ../includes/settings.php:661
352
+ msgid "WP-PostViews data imported succesfully."
353
+ msgstr ""
354
+
355
+ #: ../includes/settings.php:665
356
+ msgid "There was no data to import."
357
+ msgstr ""
358
+
359
+ #: ../includes/settings.php:827
360
+ msgid "General settings restored to defaults."
361
+ msgstr "Ustawienia zostały przywrócone do domyślnych."
362
+
363
+ #: ../includes/settings.php:833
364
+ msgid "Display settings restored to defaults."
365
+ msgstr "Ustawienia wyświetlania została przywrócone do domyślnych."
366
+
367
+ #: ../includes/settings.php:854
368
+ msgid "Support"
369
+ msgstr "Forum pomocy"
370
+
371
+ #: ../includes/widgets.php:38 ../includes/widgets.php:49
372
+ msgid "Most Viewed Posts"
373
+ msgstr "Najczęściej oglądane wpisy"
374
+
375
+ #: ../includes/widgets.php:40
376
+ msgid "Displays a list of the most viewed posts"
377
+ msgstr "Wyświetla listę najczęściej oglądanych wpisów"
378
+
379
+ #: ../includes/widgets.php:57
380
+ msgid "No Posts found"
381
+ msgstr "Brak wpisów"
382
+
383
+ #: ../includes/widgets.php:61
384
+ msgid "Ascending"
385
+ msgstr "Rosnąco"
386
+
387
+ #: ../includes/widgets.php:62
388
+ msgid "Descending"
389
+ msgstr "Malejąco"
390
+
391
+ #: ../includes/widgets.php:105
392
+ msgid "Title"
393
+ msgstr "Tytuł"
394
+
395
+ #: ../includes/widgets.php:109
396
+ msgid "Post types"
397
+ msgstr "Typy wpisów"
398
+
399
+ #: ../includes/widgets.php:123
400
+ msgid "Number of posts to show"
401
+ msgstr "Liczba wpisów do wyświetlenia"
402
+
403
+ #: ../includes/widgets.php:127
404
+ msgid "No posts message"
405
+ msgstr "Treść braku wpisów"
406
+
407
+ #: ../includes/widgets.php:131
408
+ msgid "Order"
409
+ msgstr "Kolejność"
410
+
411
+ #: ../includes/widgets.php:144
412
+ msgid "Display post views?"
413
+ msgstr "Wyświetlanie liczby odsłon?"
414
+
415
+ #: ../includes/widgets.php:146
416
+ msgid "Display post excerpt?"
417
+ msgstr "Wyświetlanie wypisu?"
418
+
419
+ #: ../includes/widgets.php:148
420
+ msgid "Display post thumbnail?"
421
+ msgstr "WYświetlanie miniatury?"
422
+
423
+ #: ../includes/widgets.php:151
424
+ msgid "Thumbnail size"
425
+ msgstr "WIelkość miniatury"
426
+
427
+ #: ../post-views-counter.php:251
428
+ msgid "Are you sure you want to reset these settings to defaults?"
429
+ msgstr "Czy jesteś pewny, że chcesz zresetować ustawienia do domyślnych?"
430
+
431
+ #: ../post-views-counter.php:285
432
+ msgid "Settings"
433
+ msgstr "Ustawienia"
434
+
435
+ #~ msgid "text"
436
+ #~ msgstr "tekst"
437
+
438
+ #~ msgid "Enable if you would like the post views counter link to the post."
439
+ #~ msgstr "Włącz jeśli chcesz aby liczba odwiedzin była linkiem do wpisu."
440
+
441
+ #~ msgid "Top"
442
+ #~ msgstr "Na górze"
443
+
444
+ #~ msgid "Bottom"
445
+ #~ msgstr "Na dole"
446
+
447
+ #~ msgid "None"
448
+ #~ msgstr "Brak"
449
+
450
+ #~ msgid "WordPress"
451
+ #~ msgstr "WordPress"
452
+
453
+ #~ msgid "Bootstrap"
454
+ #~ msgstr "Bootstrap"
455
+
456
+ #~ msgid "Custom link"
457
+ #~ msgstr "Własny link"
458
+
459
+ #~ msgid "Page link"
460
+ #~ msgstr "Link do strony"
461
+
462
+ #~ msgid "Text color"
463
+ #~ msgstr "Kolor tekstu"
464
+
465
+ #~ msgid "Bar color"
466
+ #~ msgstr "Kolor tła"
467
+
468
+ #~ msgid "1 day"
469
+ #~ msgstr "1 dzień"
470
+
471
+ #~ msgid "1 month"
472
+ #~ msgstr "1 miesiąc"
473
+
474
+ #~ msgid "6 months"
475
+ #~ msgstr "6 miesięcy"
476
+
477
+ #~ msgid "infinity"
478
+ #~ msgstr "W nieskończoność"
479
+
480
+ #~ msgid "Fade"
481
+ #~ msgstr "Zanikanie"
482
+
483
+ #~ msgid "Slide"
484
+ #~ msgstr "Przesuwanie"
485
+
486
+ #~ msgid "Cookie Notice"
487
+ #~ msgstr "Ciasteczka"
488
+
489
+ #~ msgid "Configuration"
490
+ #~ msgstr "Konfiguracja"
491
+
492
+ #~ msgid "Message"
493
+ #~ msgstr "Wiadomość"
494
+
495
+ #~ msgid "Button text"
496
+ #~ msgstr "Tekst przycisku"
497
+
498
+ #~ msgid "More info"
499
+ #~ msgstr "Więcej informacji"
500
+
501
+ #~ msgid "Cookie expiry"
502
+ #~ msgstr "Wygasanie cookie"
503
+
504
+ #~ msgid "Design"
505
+ #~ msgstr "Wygląd"
506
+
507
+ #~ msgid "Hide animation"
508
+ #~ msgstr "Ukrywanie animacji"
509
+
510
+ #~ msgid "Button style"
511
+ #~ msgstr "Styl przycisku"
512
+
513
+ #~ msgid "Colors"
514
+ #~ msgstr "Kolorystyka"
515
+
516
+ #~ msgid "Enter the cookie notice message."
517
+ #~ msgstr "Wpisz treść informacji o ciasteczkach."
518
+
519
+ #~ msgid "The text to show on the button when cookies have not been accepted"
520
+ #~ msgstr ""
521
+ #~ "Tekst przycisku, który będzie wyświetlany gdy ciasteczka nie zostały "
522
+ #~ "jeszcze zaakceptowane."
523
+
524
+ #~ msgid "Enable or Disable Read more button."
525
+ #~ msgstr "Włącz lub wyłącz przycisk z linkiem do dodatkowych informacji."
526
+
527
+ #~ msgid "Select where to redirect user for more information about cookies."
528
+ #~ msgstr ""
529
+ #~ "Wybierz dokąd przekierować użytkownika aby uzyskał więcej informacji o "
530
+ #~ "ciasteczkach."
531
+
532
+ #~ msgid "-- select page --"
533
+ #~ msgstr "-- wybierz stronę --"
534
+
535
+ #~ msgid "Select from one of your site's pages"
536
+ #~ msgstr "Wybierz jedną z istniejących stron."
537
+
538
+ #~ msgid "Enter the full URL starting with http://"
539
+ #~ msgstr "Podaj pełny adres URL zaczynający się od http://"
540
+
541
+ #~ msgid "The ammount of time that cookie should be stored for."
542
+ #~ msgstr "Okres czasu przez jaki będzie przechowywane ciasteczko."
543
+
544
+ #~ msgid "Select location for your cookie notice."
545
+ #~ msgstr "Wybierz pozycję wiadomości o ciasteczkach."
546
+
547
+ #~ msgid "Cookie notice acceptance animation."
548
+ #~ msgstr "Animacja po akceptacji ciasteczek."
549
+
550
+ #~ msgid "Choose buttons style."
551
+ #~ msgstr "Wybierz styl dla przycisków."
552
+
553
+ #~ msgid ""
554
+ #~ "We use cookies to ensure that we give you the best experience on our "
555
+ #~ "website. If you continue to use this site we will assume that you are "
556
+ #~ "happy with it."
557
+ #~ msgstr ""
558
+ #~ "Ta strona korzysta z ciasteczek aby świadczyć usługi na najwyższym "
559
+ #~ "poziomie. Dalsze korzystanie ze strony oznacza, że zgadzasz się na ich "
560
+ #~ "użycie."
561
+
562
+ #~ msgid "Ok"
563
+ #~ msgstr "Zamknij"
564
+
565
+ #~ msgid "Read more"
566
+ #~ msgstr "Dowiedz się więcej"
567
+
568
+ #~ msgid "Widgets"
569
+ #~ msgstr "Widgety"
570
+
571
+ #~ msgid "Pages"
572
+ #~ msgstr "Strony"
573
+
574
+ #~ msgid "Custom Post Type Archives"
575
+ #~ msgstr "Archiwa własnych typów wpisów"
576
+
577
+ #~ msgid "Categories"
578
+ #~ msgstr "Kategorie"
579
+
580
+ #~ msgid "Taxonomies"
581
+ #~ msgstr "Taksonomie"
582
+
583
+ #~ msgid "Others"
584
+ #~ msgstr "Inne"
585
+
586
+ #~ msgid "Users"
587
+ #~ msgstr "Użytkownicy"
588
+
589
+ #~ msgid "Languages"
590
+ #~ msgstr "Języki"
591
+
592
+ #~ msgid "Front Page"
593
+ #~ msgstr "Strona główna"
594
+
595
+ #~ msgid "Blog Page"
596
+ #~ msgstr "Strona z wpisami"
597
+
598
+ #~ msgid "Single Posts"
599
+ #~ msgstr "Pojedyncze wpisy"
600
+
601
+ #~ msgid "Sticky Posts"
602
+ #~ msgstr "Wpisy przyklejone"
603
+
604
+ #~ msgid "Author Archive"
605
+ #~ msgstr "Archiwum autora"
606
+
607
+ #~ msgid "Date Archive"
608
+ #~ msgstr "Archiwum daty"
609
+
610
+ #~ msgid "404 Page"
611
+ #~ msgstr "Strona błędów 404"
612
+
613
+ #~ msgid "Search Page"
614
+ #~ msgstr "Strona wyszukiwania"
615
+
616
+ #~ msgid "Logged out users"
617
+ #~ msgstr "Wylogowani użytkownicy"
618
+
619
+ #~ msgid ""
620
+ #~ "Use this settings to manage access to widgets page and to restrict "
621
+ #~ "availability of certain widgets, sidebars and widgets options to site "
622
+ #~ "administrators only."
623
+ #~ msgstr ""
624
+ #~ "Użyj tych ustawień aby określić kto może mieć dostęp do widgetów, jakie "
625
+ #~ "widgety, panele boczne i ustawienia widgetów są dostępne dla użytkowników "
626
+ #~ "a jakie tylko dla administratorów."
627
+
628
+ #~ msgid "Restrict Users"
629
+ #~ msgstr "Ograniczenia użytkowników"
630
+
631
+ #~ msgid "Select user roles restricted to manage widgets."
632
+ #~ msgstr "Wybierz role użytkowników, którzy mogą zarządzać widgetami."
633
+
634
+ #~ msgid "Restrict Sidebars"
635
+ #~ msgstr "Ograniczenia paneli bocznych"
636
+
637
+ #~ msgid "Select which sidebars will be restricted to admins only."
638
+ #~ msgstr ""
639
+ #~ "Wybierz panele boczne, które będą dostępne tylko dla administratorów."
640
+
641
+ #~ msgid "Restrict Widgets"
642
+ #~ msgstr "Ograniczenia widgetów"
643
+
644
+ #~ msgid "Select which widgets will be restricted to admins only."
645
+ #~ msgstr "Wybierz widgety, któe będą dostępne tylko dla administratorów."
646
+
647
+ #~ msgid "Restrict Widget Options"
648
+ #~ msgstr "Ograniczenia opcji widgetów"
649
+
650
+ #~ msgid "Select which widget options will be restricted to admins only."
651
+ #~ msgstr ""
652
+ #~ "Wybierz które opcje widgetów, będą dostępne tylko dla administratorów."
653
+
654
+ #~ msgid "Restrict Option Groups"
655
+ #~ msgstr "Ograniczenia grup opcji"
656
+
657
+ #~ msgid "Single %s"
658
+ #~ msgstr "Pojedyncze %s"
659
+
660
+ #~ msgid "%s Archive"
661
+ #~ msgstr "Archiwum %s"
662
+
663
+ #~ msgid "Display / Hide Widget"
664
+ #~ msgstr "Wyświetl / Ukryj widget"
665
+
666
+ #~ msgid "Display widget on selected"
667
+ #~ msgstr "Wyświetl widget na wybranych stronach"
668
+
669
+ #~ msgid "Hide widget on selected"
670
+ #~ msgstr "Ukryj widget na wybranych stronach"
languages/post-views-counter.pot ADDED
@@ -0,0 +1,424 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Post Views Counter\n"
4
+ "POT-Creation-Date: 2014-07-03 01:05+0100\n"
5
+ "PO-Revision-Date: 2014-07-03 01:05+0100\n"
6
+ "Last-Translator: Bartosz Arendt <info@dfactory.eu>\n"
7
+ "Language-Team: dFactory <info@dfactory.eu>\n"
8
+ "Language: en\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.6.5\n"
13
+ "X-Poedit-KeywordsList: gettext;gettext_noop;__;_e;esc_attr__;esc_attr_e;"
14
+ "esc_html__;esc_html_e\n"
15
+ "X-Poedit-Basepath: .\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "X-Poedit-SearchPath-0: ..\n"
19
+
20
+ #: ../includes/columns.php:113 ../includes/columns.php:121
21
+ msgid "Post Views"
22
+ msgstr ""
23
+
24
+ #: ../includes/cron.php:40
25
+ msgid "Post Views Counter reset daily counts interval"
26
+ msgstr ""
27
+
28
+ #: ../includes/functions.php:114
29
+ msgid "No Posts"
30
+ msgstr ""
31
+
32
+ #: ../includes/settings.php:41
33
+ msgid "Enable"
34
+ msgstr ""
35
+
36
+ #: ../includes/settings.php:42
37
+ msgid "Disable"
38
+ msgstr ""
39
+
40
+ #: ../includes/settings.php:46
41
+ msgid "PHP"
42
+ msgstr ""
43
+
44
+ #: ../includes/settings.php:47
45
+ msgid "JavaScript"
46
+ msgstr ""
47
+
48
+ #: ../includes/settings.php:51
49
+ msgid "minutes"
50
+ msgstr ""
51
+
52
+ #: ../includes/settings.php:52
53
+ msgid "hours"
54
+ msgstr ""
55
+
56
+ #: ../includes/settings.php:53
57
+ msgid "days"
58
+ msgstr ""
59
+
60
+ #: ../includes/settings.php:54
61
+ msgid "weeks"
62
+ msgstr ""
63
+
64
+ #: ../includes/settings.php:55
65
+ msgid "months"
66
+ msgstr ""
67
+
68
+ #: ../includes/settings.php:56
69
+ msgid "years"
70
+ msgstr ""
71
+
72
+ #: ../includes/settings.php:60
73
+ msgid "robots"
74
+ msgstr ""
75
+
76
+ #: ../includes/settings.php:61
77
+ msgid "logged in users"
78
+ msgstr ""
79
+
80
+ #: ../includes/settings.php:62
81
+ msgid "guests"
82
+ msgstr ""
83
+
84
+ #: ../includes/settings.php:63
85
+ msgid "selected user roles"
86
+ msgstr ""
87
+
88
+ #: ../includes/settings.php:67
89
+ msgid "before the content"
90
+ msgstr ""
91
+
92
+ #: ../includes/settings.php:68
93
+ msgid "after the content"
94
+ msgstr ""
95
+
96
+ #: ../includes/settings.php:69
97
+ msgid "manual"
98
+ msgstr ""
99
+
100
+ #: ../includes/settings.php:73
101
+ msgid "icon"
102
+ msgstr ""
103
+
104
+ #: ../includes/settings.php:74
105
+ msgid "label"
106
+ msgstr ""
107
+
108
+ #: ../includes/settings.php:79
109
+ msgid "General"
110
+ msgstr ""
111
+
112
+ #: ../includes/settings.php:85
113
+ msgid "Display"
114
+ msgstr ""
115
+
116
+ #: ../includes/settings.php:149 ../includes/settings.php:150
117
+ #: ../includes/settings.php:167 ../includes/settings.php:180
118
+ msgid "Post Views Counter"
119
+ msgstr ""
120
+
121
+ #: ../includes/settings.php:182
122
+ msgid "Need support?"
123
+ msgstr ""
124
+
125
+ #: ../includes/settings.php:183
126
+ msgid ""
127
+ "If you are having problems with this plugin, please talk about them in the"
128
+ msgstr ""
129
+
130
+ #: ../includes/settings.php:183
131
+ msgid "Support forum"
132
+ msgstr ""
133
+
134
+ #: ../includes/settings.php:185
135
+ msgid "Do you like this plugin?"
136
+ msgstr ""
137
+
138
+ #: ../includes/settings.php:186
139
+ msgid "Rate it 5"
140
+ msgstr ""
141
+
142
+ #: ../includes/settings.php:186
143
+ msgid "on WordPress.org"
144
+ msgstr ""
145
+
146
+ #: ../includes/settings.php:187
147
+ msgid "Blog about it & link to the"
148
+ msgstr ""
149
+
150
+ #: ../includes/settings.php:187
151
+ msgid "plugin page"
152
+ msgstr ""
153
+
154
+ #: ../includes/settings.php:188
155
+ msgid "Check out our other"
156
+ msgstr ""
157
+
158
+ #: ../includes/settings.php:188
159
+ msgid "WordPress plugins"
160
+ msgstr ""
161
+
162
+ #: ../includes/settings.php:191
163
+ msgid "Created by"
164
+ msgstr ""
165
+
166
+ #: ../includes/settings.php:207
167
+ msgid "Reset to defaults"
168
+ msgstr ""
169
+
170
+ #: ../includes/settings.php:225
171
+ msgid "General settings"
172
+ msgstr ""
173
+
174
+ #: ../includes/settings.php:226
175
+ msgid "Post Types Count"
176
+ msgstr ""
177
+
178
+ #: ../includes/settings.php:227
179
+ msgid "Counter Mode"
180
+ msgstr ""
181
+
182
+ #: ../includes/settings.php:228
183
+ msgid "Post Views Column"
184
+ msgstr ""
185
+
186
+ #: ../includes/settings.php:229
187
+ msgid "Time Between Counts"
188
+ msgstr ""
189
+
190
+ #: ../includes/settings.php:230
191
+ msgid "Reset Data"
192
+ msgstr ""
193
+
194
+ #: ../includes/settings.php:231
195
+ msgid "Exclude Visitors"
196
+ msgstr ""
197
+
198
+ #: ../includes/settings.php:232
199
+ msgid "Exclude IPs"
200
+ msgstr ""
201
+
202
+ #: ../includes/settings.php:233
203
+ msgid "WP-PostViews"
204
+ msgstr ""
205
+
206
+ #: ../includes/settings.php:234
207
+ msgid "Deactivation"
208
+ msgstr ""
209
+
210
+ #: ../includes/settings.php:238
211
+ msgid "Display settings"
212
+ msgstr ""
213
+
214
+ #: ../includes/settings.php:239
215
+ msgid "Post Views Label"
216
+ msgstr ""
217
+
218
+ #: ../includes/settings.php:240
219
+ msgid "Post Types Display"
220
+ msgstr ""
221
+
222
+ #: ../includes/settings.php:241
223
+ msgid "Restrict Display"
224
+ msgstr ""
225
+
226
+ #: ../includes/settings.php:242
227
+ msgid "Position"
228
+ msgstr ""
229
+
230
+ #: ../includes/settings.php:243
231
+ msgid "Display Style"
232
+ msgstr ""
233
+
234
+ #: ../includes/settings.php:244
235
+ msgid "Icon Class"
236
+ msgstr ""
237
+
238
+ #: ../includes/settings.php:258
239
+ msgid "Enter the label for the post views counter field."
240
+ msgstr ""
241
+
242
+ #: ../includes/settings.php:272
243
+ msgid "Select post types"
244
+ msgstr ""
245
+
246
+ #: ../includes/settings.php:283
247
+ msgid "Select post types for which post views will be counted."
248
+ msgstr ""
249
+
250
+ #: ../includes/settings.php:297 ../includes/settings.php:423
251
+ #: ../includes/settings.php:599
252
+ msgid "Select groups"
253
+ msgstr ""
254
+
255
+ #: ../includes/settings.php:308
256
+ msgid "Select post types for which post views will be displayed."
257
+ msgstr ""
258
+
259
+ #: ../includes/settings.php:332
260
+ msgid ""
261
+ "Select the method of collecting post views data. If you are using any of the "
262
+ "caching plugins select Javascript."
263
+ msgstr ""
264
+
265
+ #: ../includes/settings.php:357
266
+ msgid ""
267
+ "Enable to display post views count column for each of the selected post "
268
+ "types."
269
+ msgstr ""
270
+
271
+ #: ../includes/settings.php:383
272
+ msgid "Enter the time between single user visit count."
273
+ msgstr ""
274
+
275
+ #: ../includes/settings.php:409
276
+ msgid ""
277
+ "Delete single day post views data older than specified above. Enter 0 "
278
+ "(number zero) if you want to preserve your data regardless of its age."
279
+ msgstr ""
280
+
281
+ #: ../includes/settings.php:435 ../includes/settings.php:614
282
+ msgid "Select user roles"
283
+ msgstr ""
284
+
285
+ #: ../includes/settings.php:447
286
+ msgid "Select the type of visitors to be excluded from post views count."
287
+ msgstr ""
288
+
289
+ #: ../includes/settings.php:466 ../includes/settings.php:475
290
+ msgid "Remove"
291
+ msgstr ""
292
+
293
+ #: ../includes/settings.php:475
294
+ msgid "Add new"
295
+ msgstr ""
296
+
297
+ #: ../includes/settings.php:475
298
+ msgid "Add my current IP"
299
+ msgstr ""
300
+
301
+ #: ../includes/settings.php:477
302
+ msgid "Enter the IP addresses to be excluded from post views count."
303
+ msgstr ""
304
+
305
+ #: ../includes/settings.php:491
306
+ msgid "Import"
307
+ msgstr ""
308
+
309
+ #: ../includes/settings.php:493
310
+ msgid "Import post views data from WP-PostViews plugin."
311
+ msgstr ""
312
+
313
+ #: ../includes/settings.php:494
314
+ msgid "Override existing Post Views Counter data."
315
+ msgstr ""
316
+
317
+ #: ../includes/settings.php:519
318
+ msgid "Enable to delete all plugin data on deactivation."
319
+ msgstr ""
320
+
321
+ #: ../includes/settings.php:544
322
+ msgid ""
323
+ "Select where would you like to display the post views counter. Use [post-"
324
+ "views] shortcode for manual display."
325
+ msgstr ""
326
+
327
+ #: ../includes/settings.php:569
328
+ msgid "Choose how to display the post views counter."
329
+ msgstr ""
330
+
331
+ #: ../includes/settings.php:585
332
+ #, php-format
333
+ msgid ""
334
+ "Enter the post views icon class. Any of the <a href=\"%s\" target=\"_blank"
335
+ "\">Dashicons</a> classes are available."
336
+ msgstr ""
337
+
338
+ #: ../includes/settings.php:626
339
+ msgid "Use it to hide the post views counter from selected type of visitors."
340
+ msgstr ""
341
+
342
+ #: ../includes/settings.php:661
343
+ msgid "WP-PostViews data imported succesfully."
344
+ msgstr ""
345
+
346
+ #: ../includes/settings.php:665
347
+ msgid "There was no data to import."
348
+ msgstr ""
349
+
350
+ #: ../includes/settings.php:827
351
+ msgid "General settings restored to defaults."
352
+ msgstr ""
353
+
354
+ #: ../includes/settings.php:833
355
+ msgid "Display settings restored to defaults."
356
+ msgstr ""
357
+
358
+ #: ../includes/settings.php:854
359
+ msgid "Support"
360
+ msgstr ""
361
+
362
+ #: ../includes/widgets.php:38 ../includes/widgets.php:49
363
+ msgid "Most Viewed Posts"
364
+ msgstr ""
365
+
366
+ #: ../includes/widgets.php:40
367
+ msgid "Displays a list of the most viewed posts"
368
+ msgstr ""
369
+
370
+ #: ../includes/widgets.php:57
371
+ msgid "No Posts found"
372
+ msgstr ""
373
+
374
+ #: ../includes/widgets.php:61
375
+ msgid "Ascending"
376
+ msgstr ""
377
+
378
+ #: ../includes/widgets.php:62
379
+ msgid "Descending"
380
+ msgstr ""
381
+
382
+ #: ../includes/widgets.php:105
383
+ msgid "Title"
384
+ msgstr ""
385
+
386
+ #: ../includes/widgets.php:109
387
+ msgid "Post types"
388
+ msgstr ""
389
+
390
+ #: ../includes/widgets.php:123
391
+ msgid "Number of posts to show"
392
+ msgstr ""
393
+
394
+ #: ../includes/widgets.php:127
395
+ msgid "No posts message"
396
+ msgstr ""
397
+
398
+ #: ../includes/widgets.php:131
399
+ msgid "Order"
400
+ msgstr ""
401
+
402
+ #: ../includes/widgets.php:144
403
+ msgid "Display post views?"
404
+ msgstr ""
405
+
406
+ #: ../includes/widgets.php:146
407
+ msgid "Display post excerpt?"
408
+ msgstr ""
409
+
410
+ #: ../includes/widgets.php:148
411
+ msgid "Display post thumbnail?"
412
+ msgstr ""
413
+
414
+ #: ../includes/widgets.php:151
415
+ msgid "Thumbnail size"
416
+ msgstr ""
417
+
418
+ #: ../post-views-counter.php:251
419
+ msgid "Are you sure you want to reset these settings to defaults?"
420
+ msgstr ""
421
+
422
+ #: ../post-views-counter.php:285
423
+ msgid "Settings"
424
+ msgstr ""
post-views-counter.php ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Post Views Counter
4
+ Description: Forget WP-PostViews. Display how many times a post, page or custom post type had been viewed in a simple, fast and reliable way.
5
+ Version: 1.0.0
6
+ Author: dFactory
7
+ Author URI: http://www.dfactory.eu/
8
+ Plugin URI: http://www.dfactory.eu/plugins/post-views-counter/
9
+ License: MIT License
10
+ License URI: http://opensource.org/licenses/MIT
11
+ Text Domain: post-views-counter
12
+ Domain Path: /languages
13
+
14
+ Post Views Counter
15
+ Copyright (C) 2014, Digital Factory - info@digitalfactory.pl
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+
25
+ if(!defined('ABSPATH')) exit;
26
+
27
+ define('POST_VIEWS_COUNTER_URL', plugins_url('', __FILE__));
28
+ define('POST_VIEWS_COUNTER_PATH', plugin_dir_path(__FILE__));
29
+ define('POST_VIEWS_COUNTER_REL_PATH', dirname(plugin_basename(__FILE__)).'/');
30
+
31
+ include_once(POST_VIEWS_COUNTER_PATH.'includes/update.php');
32
+ include_once(POST_VIEWS_COUNTER_PATH.'includes/settings.php');
33
+ include_once(POST_VIEWS_COUNTER_PATH.'includes/query.php');
34
+ include_once(POST_VIEWS_COUNTER_PATH.'includes/cron.php');
35
+ include_once(POST_VIEWS_COUNTER_PATH.'includes/counter.php');
36
+ include_once(POST_VIEWS_COUNTER_PATH.'includes/columns.php');
37
+ include_once(POST_VIEWS_COUNTER_PATH.'includes/frontend.php');
38
+ include_once(POST_VIEWS_COUNTER_PATH.'includes/widgets.php');
39
+
40
+
41
+ class Post_Views_Counter
42
+ {
43
+ private static $_instance;
44
+ private $instances;
45
+ private $options;
46
+ private $defaults = array(
47
+ 'general' => array(
48
+ 'post_types_count' => array('post'),
49
+ 'counter_mode' => 'php',
50
+ 'post_views_column' => true,
51
+ 'time_between_counts' => array(
52
+ 'number' => 24,
53
+ 'type' => 'hours'
54
+ ),
55
+ 'reset_counts' => array(
56
+ 'number' => 30,
57
+ 'type' => 'days'
58
+ ),
59
+ 'exclude' => array(
60
+ 'groups' => array(),
61
+ 'roles' => array()
62
+ ),
63
+ 'exclude_ips' => array(),
64
+ 'deactivation_delete' => false,
65
+ 'cron_run' => true,
66
+ 'cron_update' => true
67
+ ),
68
+ 'display' => array(
69
+ 'label' => 'Post Views:',
70
+ 'post_types_display' => array('post'),
71
+ 'restrict_display' => array(
72
+ 'groups' => array(),
73
+ 'roles' => array()
74
+ ),
75
+ 'position' => 'after',
76
+ 'display_style' => array(
77
+ 'icon' => true,
78
+ 'text' => true
79
+ ),
80
+ 'link_to_post' => true,
81
+ 'icon_class' => 'dashicons-visibility'
82
+ ),
83
+ 'version' => '1.0.0'
84
+ );
85
+
86
+
87
+ public static function instance()
88
+ {
89
+ if(self::$_instance === null)
90
+ self::$_instance = new self();
91
+
92
+ return self::$_instance;
93
+ }
94
+
95
+
96
+ private function __clone() {}
97
+ private function __wakeup() {}
98
+
99
+
100
+ private function __construct()
101
+ {
102
+ register_activation_hook(__FILE__, array(&$this, 'activation'));
103
+ register_deactivation_hook(__FILE__, array(&$this, 'deactivation'));
104
+
105
+ // settings
106
+ $this->options = array(
107
+ 'general' => array_merge($this->defaults['general'], get_option('post_views_counter_settings_general', $this->defaults['general'])),
108
+ 'display' => array_merge($this->defaults['display'], get_option('post_views_counter_settings_display', $this->defaults['display']))
109
+ );
110
+
111
+ // actions
112
+ add_action('plugins_loaded', array(&$this, 'load_textdomain'));
113
+ add_action('admin_enqueue_scripts', array(&$this, 'admin_scripts_styles'));
114
+ add_action('wp', array(&$this, 'load_pluggable_functions'), 10);
115
+
116
+ // filters
117
+ add_filter('plugin_action_links', array(&$this, 'plugin_settings_link'), 10, 2);
118
+ }
119
+
120
+
121
+ /**
122
+ * Execution of plugin activation function
123
+ */
124
+ public function activation()
125
+ {
126
+ global $wpdb, $charset_collate;
127
+
128
+ // required for dbdelta
129
+ require_once(ABSPATH.'wp-admin/includes/upgrade.php');
130
+
131
+ // creates post views table
132
+ dbDelta('
133
+ CREATE TABLE IF NOT EXISTS '.$wpdb->prefix.'post_views (
134
+ id bigint unsigned NOT NULL,
135
+ type tinyint(1) unsigned NOT NULL,
136
+ period varchar(8) NOT NULL,
137
+ count bigint unsigned NOT NULL,
138
+ PRIMARY KEY (type, period, id),
139
+ UNIQUE INDEX id_period (id, period) USING BTREE,
140
+ INDEX type_period_count (type, period, count) USING BTREE
141
+ ) '.$charset_collate.';'
142
+ );
143
+
144
+ // adds default options
145
+ add_option('post_views_counter_settings_general', $this->defaults['general'], '', 'no');
146
+ add_option('post_views_counter_settings_display', $this->defaults['display'], '', 'no');
147
+ add_option('post_views_counter_version', $this->defaults['version'], '', 'no');
148
+ }
149
+
150
+
151
+ /**
152
+ * Execution of plugin deactivation function
153
+ */
154
+ public function deactivation()
155
+ {
156
+ // deletes default options
157
+ if($this->options['general']['deactivation_delete'])
158
+ {
159
+ delete_option('post_views_counter_settings_general');
160
+ delete_option('post_views_counter_settings_display');
161
+ }
162
+
163
+ // removes schedule
164
+ wp_clear_scheduled_hook('pvc_reset_counts');
165
+ remove_action('pvc_reset_counts', array(Post_Views_Counter()->get_instance('cron'), 'reset_counts'));
166
+ }
167
+
168
+
169
+ /**
170
+ * Loads text domain
171
+ */
172
+ public function load_textdomain()
173
+ {
174
+ load_plugin_textdomain('post-views-counter', false, POST_VIEWS_COUNTER_REL_PATH.'languages/');
175
+ }
176
+
177
+
178
+ /**
179
+ * Load pluggable template functions
180
+ */
181
+ public function load_pluggable_functions()
182
+ {
183
+ include_once(POST_VIEWS_COUNTER_PATH.'includes/functions.php');
184
+ }
185
+
186
+
187
+ /**
188
+ * Sets instance of class
189
+ */
190
+ public function add_instance($name, $instance)
191
+ {
192
+ $this->instances[$name] = $instance;
193
+ }
194
+
195
+
196
+ /**
197
+ * Gets instance of class
198
+ */
199
+ public function get_instance($name)
200
+ {
201
+ if(in_array($name, array('counter', 'settings'), true))
202
+ return $this->instances[$name];
203
+ }
204
+
205
+
206
+ /**
207
+ * Gets allowed attribute
208
+ */
209
+ public function get_attribute($attribute)
210
+ {
211
+ if(in_array($attribute, array('options', 'defaults'), true))
212
+ {
213
+ switch(func_num_args())
214
+ {
215
+ case 1:
216
+ return $this->{$attribute};
217
+
218
+ case 2:
219
+ return $this->{$attribute}[func_get_arg(1)];
220
+
221
+ case 3:
222
+ return $this->{$attribute}[func_get_arg(1)][func_get_arg(2)];
223
+
224
+ case 4:
225
+ return $this->{$attribute}[func_get_arg(1)][func_get_arg(2)][func_get_arg(3)];
226
+ }
227
+ }
228
+ else
229
+ return false;
230
+ }
231
+
232
+
233
+ /**
234
+ * Equeues admin scripts and styles
235
+ */
236
+ public function admin_scripts_styles($page)
237
+ {
238
+ // loads only for settings page
239
+ if($page === 'settings_page_post-views-counter')
240
+ {
241
+ wp_register_script(
242
+ 'post-views-counter-admin-chosen',
243
+ POST_VIEWS_COUNTER_URL.'/assets/chosen/chosen.jquery.min.js',
244
+ array('jquery')
245
+ );
246
+
247
+ wp_register_script(
248
+ 'post-views-counter-admin',
249
+ POST_VIEWS_COUNTER_URL.'/js/admin.js',
250
+ array('jquery', 'post-views-counter-admin-chosen')
251
+ );
252
+
253
+ wp_enqueue_script('post-views-counter-admin-chosen');
254
+ wp_enqueue_script('post-views-counter-admin');
255
+
256
+ wp_localize_script(
257
+ 'post-views-counter-admin',
258
+ 'pvcArgsSettings',
259
+ array(
260
+ 'resetToDefaults' => __('Are you sure you want to reset these settings to defaults?', 'post-views-counter')
261
+ )
262
+ );
263
+
264
+ wp_register_style(
265
+ 'post-views-counter-admin',
266
+ POST_VIEWS_COUNTER_URL.'/css/admin.css'
267
+ );
268
+
269
+ wp_register_style(
270
+ 'post-views-counter-chosen',
271
+ POST_VIEWS_COUNTER_URL.'/assets/chosen/chosen.min.css'
272
+ );
273
+
274
+ wp_enqueue_style('post-views-counter-chosen');
275
+ wp_enqueue_style('post-views-counter-admin');
276
+ }
277
+ }
278
+
279
+
280
+ /**
281
+ * Adds link to settings page
282
+ */
283
+ public function plugin_settings_link($links, $file)
284
+ {
285
+ if(!is_admin() || !current_user_can('manage_options'))
286
+ return $links;
287
+
288
+ static $plugin;
289
+
290
+ $plugin = plugin_basename(__FILE__);
291
+
292
+ if($file == $plugin)
293
+ {
294
+ $settings_link = sprintf('<a href="%s">%s</a>', admin_url('options-general.php').'?page=post-views-counter', __('Settings', 'post-views-counter'));
295
+
296
+ array_unshift($links, $settings_link);
297
+ }
298
+
299
+ return $links;
300
+ }
301
+ }
302
+
303
+
304
+ function Post_Views_Counter()
305
+ {
306
+ static $instance;
307
+
308
+ // first call to instance() initializes the plugin
309
+ if($instance === null || !($instance instanceof Post_Views_Counter))
310
+ $instance = Post_Views_Counter::instance();
311
+
312
+ return $instance;
313
+ }
314
+
315
+
316
+ Post_Views_Counter();
317
+ ?>
readme.txt ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Post Views Counter ===
2
+ Contributors: dfactory
3
+ Donate link: http://www.dfactory.eu/
4
+ Tags: counter, hits, postviews, post views, views, count
5
+ Requires at least: 3.8.0
6
+ Tested up to: 3.9.1
7
+ Stable tag: 1.0.0
8
+ License: MIT License
9
+ License URI: http://opensource.org/licenses/MIT
10
+
11
+ Forget WP-PostViews. Display how many times a post, page or custom post type had been viewed in a simple, fast and reliable way.
12
+
13
+ == Description ==
14
+
15
+ [Post Views Counter](http://www.dfactory.eu/plugins/post-views-counter/) allows you to display how many times a post, page or custom post type had been viewed with this simple, fast and easy to use plugin.
16
+
17
+ For more information, check out plugin page at [dFactory](http://www.dfactory.eu/) or plugin [support forum](http://www.dfactory.eu/support/forum/post-views-counter/).
18
+
19
+ = Features include: =
20
+
21
+ * Option to select post types for which post views will be counted and displayed.
22
+ * 2 methods of collecting post views data: PHP and Javascript, for greater flexibility
23
+ * Option to set time between counts
24
+ * Excluding counts from visitors: bots, logged in users, selected user roles
25
+ * Excluding users by IPs
26
+ * Restricting display by user roles
27
+ * One-click data import from WP-PostViews
28
+ * Post views display position, automatic or manual via shortcode
29
+ * W3 Cache/WP SuperCache compatible
30
+ * WPML and Polylang compatible
31
+ * .pot file for translations included
32
+
33
+ = Translations: =
34
+ * Polish - by Bartosz Arendt
35
+
36
+
37
+ == Installation ==
38
+
39
+ 1. Install Post Views Counter either via the WordPress.org plugin directory, or by uploading the files to your server
40
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
41
+ 3. Go to the Post Views Counter settings and set your options.
42
+
43
+ == Frequently Asked Questions ==
44
+
45
+ No questions yet.
46
+
47
+ == Screenshots ==
48
+
49
+ 1. screenshot-1.png
50
+ 2. screenshot-2.png
51
+
52
+ == Changelog ==
53
+
54
+ = 1.0.0 =
55
+ Initial release
56
+
57
+ == Upgrade Notice ==
58
+
59
+
60
+ = 1.0.0 =
61
+ Initial release