diff --git a/wp-content/plugins/bp-dedication/dedication.php b/wp-content/plugins/bp-dedication/dedication.php index f43923f..5c056f1 100644 --- a/wp-content/plugins/bp-dedication/dedication.php +++ b/wp-content/plugins/bp-dedication/dedication.php @@ -2,28 +2,28 @@ function bp_dedication_add_js() { global $bp; - - if ($bp->current_action == BP_DEDICATION_SLUG || ( isset($bp->action_variables[1]) && $bp->action_variables[1] == BP_DEDICATION_SLUG )) { + if (bp_is_dedication_component() && bp_is_current_action('new-dedication')) { + wp_enqueue_script('jquery-validate-js', plugins_url("includes/js/jquery.validate.min.js", __FILE__), array('jquery')); wp_enqueue_script('jquery-autocomplete-js', plugins_url("includes/js/jquery.autocomplete-min.js", __FILE__), array('jquery')); - /* wp_enqueue_script('invite-anyone-autocomplete-js', WP_PLUGIN_URL . '/invite-anyone/group-invites/jquery.autocomplete/jquery.autocomplete-min.js', array('jquery')); - wp_register_script('invite-anyone-js', WP_PLUGIN_URL . '/invite-anyone/group-invites/group-invites-js.js', array('invite-anyone-autocomplete-js')); - wp_enqueue_script('invite-anyone-js'); */ + wp_enqueue_script('jquery-jyoutube-js', plugins_url("includes/js/jquery.jyoutube.js", __FILE__), array('jquery')); + wp_register_script('dedication-js', plugins_url("includes/js/dedication-script.js", __FILE__), array('jquery-autocomplete-js', 'jquery-jyoutube-js')); + + wp_localize_script('dedication-js', 'script_vars', array( + 'source_url' => plugins_url("includes/bp-dedication-search-members.php", __FILE__) + ) + ); + + wp_enqueue_script('dedication-js'); } } add_action('wp_head', 'bp_dedication_add_js', 1); -function bp_dedication_css() { +function bp_dedication_add_css() { global $bp; - - if ($bp->current_action == BP_DEDICATION_SLUG || ( isset($bp->action_variables[1]) && $bp->action_variables[1] == BP_DEDICATION_SLUG )) { - /* $style_url = WP_PLUGIN_URL . '/invite-anyone/group-invites/group-invites-css.css'; - $style_file = WP_PLUGIN_DIR . '/invite-anyone/group-invites/group-invites-css.css'; - - if (file_exists($style_file)) { - wp_register_style('invite-anyone-group-invites-style', $style_url); - wp_enqueue_style('invite-anyone-group-invites-style'); - } */ + if (bp_is_dedication_component() && bp_is_current_action('new-dedication')) { + wp_register_style('bp-dedication-style', plugins_url("includes/css/bp-dedication.css", __FILE__)); + wp_enqueue_style('bp-dedication-style'); } } @@ -82,15 +82,17 @@ class BP_Dedication extends BP_Component { // Files to include $includes = array( - 'includes/create-dedication.php', + 'includes/bp-dedication-create-dedication.php', 'includes/bp-dedication-screens.php', 'includes/bp-dedication-activity.php', - 'includes/bp-example-functions.php', + 'includes/bp-dedication-functions.php', + 'includes/bp-dedication-classes.php', + 'includes/bp-dedication-ajax.php', /* 'includes/bp-example-filters.php', - 'includes/bp-example-classes.php', + 'includes/bp-example-template.php', - + 'includes/bp-example-notifications.php', 'includes/bp-example-widgets.php', 'includes/bp-example-cssjs.php', @@ -113,8 +115,8 @@ class BP_Dedication extends BP_Component { 'default_subnav_slug' => 'my-dedications' ); - $dedication_link = trailingslashit(bp_loggedin_user_domain() . bp_get_dedication_slug()); - + $dedication_link = trailingslashit(bp_displayed_user_domain() . bp_get_dedication_slug()); + // Add a few subnav items under the main Example tab $sub_nav[] = array( 'name' => __('My dedications', 'bp-dedication'), @@ -135,15 +137,16 @@ class BP_Dedication extends BP_Component { 'position' => 20 ); - // Add the subnav items to the friends nav item - $sub_nav[] = array( - 'name' => __('New dedication', 'bp-dedication'), - 'slug' => 'new-dedication', - 'parent_url' => $dedication_link, - 'parent_slug' => bp_get_dedication_slug(), - 'screen_function' => 'bp_dedication_new_dedication', - 'position' => 30 - ); + if (bp_displayed_user_id() == bp_loggedin_user_id()) { + $sub_nav[] = array( + 'name' => __('New dedication', 'bp-dedication'), + 'slug' => 'new-dedication', + 'parent_url' => $dedication_link, + 'parent_slug' => bp_get_dedication_slug(), + 'screen_function' => 'bp_dedication_new_dedication', + 'position' => 30 + ); + } parent::setup_nav($main_nav, $sub_nav); //parent::setup_nav( $main_nav ); diff --git a/wp-content/plugins/bp-dedication/functions.php b/wp-content/plugins/bp-dedication/functions.php index 79245b7..ef71f2a 100644 --- a/wp-content/plugins/bp-dedication/functions.php +++ b/wp-content/plugins/bp-dedication/functions.php @@ -18,7 +18,7 @@ function bp_dedication_get_dedications_from_user( $user_id ) { $args = array( 'numberposts' => -1, - 'category' => 'dedication', + 'category' => get_cat_id('dedication'), 'author' => $user_id ); $posts_array = get_posts( $args ); diff --git a/wp-content/plugins/bp-dedication/includes/bp-dedication-ajax.php b/wp-content/plugins/bp-dedication/includes/bp-dedication-ajax.php new file mode 100644 index 0000000..c610fc7 --- /dev/null +++ b/wp-content/plugins/bp-dedication/includes/bp-dedication-ajax.php @@ -0,0 +1,109 @@ + $_REQUEST['query'], + 'data' => array(), + 'suggestions' => array() + ); + + $users = bp_dedication_members_query( $_REQUEST['query'] ); + + if ( $users ) { + $suggestions = array(); + $data = array(); + + foreach ( $users as $user ) { + $suggestions[] = $user->display_name . ' (' . $user->user_login . ')'; + $data[] = $user->ID; + } + + $return['suggestions'] = $suggestions; + $return['data'] = $data; + } + + echo json_encode( $return ); +} +add_action( 'wp_ajax_bp_dedication_autocomplete_ajax_handler', 'bp_dedication_ajax_autocomplete_results' ); + + +function bp_dedication_ajax_add_user() { + global $bp; + + //check_ajax_referer( 'groups_invite_uninvite_user' ); + + if ( !$_POST['friend_id'] || !$_POST['friend_action'] ) + return false; + + if ( 'add' == $_POST['friend_action'] ) { + + $user = new BP_Core_User( $_POST['friend_id'] ); + + echo '
  • '; + echo bp_core_fetch_avatar( array( 'item_id' => $user->id ) ); + echo '

    ' . bp_core_get_userlink( $user->id ) . '

    '; + echo '
    + ' . __( 'Remove', 'bp_dedication' ) . ' +
    '; + echo '
  • '; + + } else if ( 'delete' == $_POST['friend_action'] ) { + return true; + } else { + return false; + } +} +add_action( 'wp_ajax_bp_dedication_add_user_ajax_handler', 'bp_dedication_ajax_add_user' ); + + +function bp_dedication_members_query( $search_terms = false ) { + // Get a list of group members to be excluded from the main query + $group_members = array(); + $args = array( + 'exclude_admins_mods' => false + ); + if ( $search_terms ) + $args['search'] = $search_terms; + + $group_members[] = bp_loggedin_user_id(); + + // Now do a user query + // Pass a null blog id so that the capabilities check is skipped. For BP blog_id doesn't + // matter anyway + $user_query = new Bp_Dedication_User_Query( array( 'blog_id' => NULL, 'exclude' => $group_members, 'search' => $search_terms ) ); + + return $user_query->results; +} + +//$oldURL = dirname(__FILE__); +//$newURL = str_replace(DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'dedication-from-site', '', $oldURL); +// +//require_once( $newURL . DIRECTORY_SEPARATOR . 'wp-load.php'); +//global $wpdb; +// +//var_dump($_REQUEST); +// +//// if the 'term' variable is not sent with the request, exit +//if (!isset($_REQUEST['term'])) +// exit; +// +//$data = array(); +// +//$wp_user_search = $wpdb->get_results("SELECT ID, display_name, user_email FROM $wpdb->users ORDER BY ID"); +//foreach ($wp_user_search as $userid) { +// $user_id = (int) $userid->ID; +// $display_name = stripslashes($userid->display_name); +// $user_email = stripslashes($userid->user_email); +// +// $data[] = array( +// 'label' => $display_name . ' (' . $user_email . ')', +// 'value' => $user_id +// ); +//} +//// jQuery wants JSON data +//echo json_encode($data); +//flush(); + + diff --git a/wp-content/plugins/bp-dedication/includes/bp-dedication-classes.php b/wp-content/plugins/bp-dedication/includes/bp-dedication-classes.php new file mode 100644 index 0000000..d30979c --- /dev/null +++ b/wp-content/plugins/bp-dedication/includes/bp-dedication-classes.php @@ -0,0 +1,50 @@ +query_where .= ' AND user_status = 0'; + } + + /** + * @see WP_User_Query::get_search_sql() + */ + function get_search_sql($string, $cols, $wild = false) { + $string = esc_sql($string); + + // Always search all columns + $cols = array( + 'user_email', + 'user_login', + 'user_nicename', + 'user_url', + 'display_name' + ); + + // Always do 'both' for trailing_wild + $wild = 'both'; + + $searches = array(); + $leading_wild = ( 'leading' == $wild || 'both' == $wild ) ? '%' : ''; + $trailing_wild = ( 'trailing' == $wild || 'both' == $wild ) ? '%' : ''; + foreach ($cols as $col) { + if ('ID' == $col) + $searches[] = "$col = '$string'"; + else + $searches[] = "$col LIKE '$leading_wild" . like_escape($string) . "$trailing_wild'"; + } + + return ' AND (' . implode(' OR ', $searches) . ') AND user_status = 0'; + } + +} + +?> diff --git a/wp-content/plugins/bp-dedication/includes/create-dedication.php b/wp-content/plugins/bp-dedication/includes/bp-dedication-create-dedication.php similarity index 86% rename from wp-content/plugins/bp-dedication/includes/create-dedication.php rename to wp-content/plugins/bp-dedication/includes/bp-dedication-create-dedication.php index 3cedc1c..5a2a51b 100644 --- a/wp-content/plugins/bp-dedication/includes/create-dedication.php +++ b/wp-content/plugins/bp-dedication/includes/bp-dedication-create-dedication.php @@ -1,4 +1,5 @@ +

    + displayed_user->id ); + if (!locate_template( 'dedications/single/my-dedications.php', true )) { + die(); + } /** * For security reasons, we MUST use the wp_nonce_url() function on any actions. * This will stop naughty people from tricking users into performing actions without their * knowledge or intent. */ - $send_link = wp_nonce_url( $bp->displayed_user->domain . $bp->current_component . '/screen-one/send-h5', 'bp_example_send_high_five' ); - ?> -

    -

    high-five!', 'bp-example' ), $bp->displayed_user->fullname, $send_link ) ?>

    - - -

    - - - - - - - - -
      post_title, $dedication->ID ); ?>
    - - displayed_user->domain . $bp->current_component . '/screen-one/send-h5', 'bp_example_send_high_five' ); + } function bp_dedication_dedications_to_me() { @@ -66,42 +51,20 @@ function bp_dedication_dedications_to_me() { add_action( 'bp_template_title', 'bp_dedication_dedications_to_me_title' ); add_action( 'bp_template_content', 'bp_dedication_dedications_to_me_content' ); - bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) ); + bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'dedications/index' ) ); } function bp_dedication_dedications_to_me_title() { - _e( 'Dedicated 2u', 'bp-dedication' ); + ?> +

    + displayed_user->id ); - - /** - * For security reasons, we MUST use the wp_nonce_url() function on any actions. - * This will stop naughty people from tricking users into performing actions without their - * knowledge or intent. - */ - $send_link = wp_nonce_url( $bp->displayed_user->domain . $bp->current_component . '/screen-one/send-h5', 'bp_example_send_high_five' ); - ?> -

    -

    high-five!', 'bp-example' ), $bp->displayed_user->fullname, $send_link ) ?>

    - - -

    - - - - - - - - -
      post_title, $dedication->ID ); ?>
    - - +

    + ' + value); + alert(data); + } + + var options = { + minLength: 1, + serviceUrl: ajaxurl, + width: 300, + delimiter: /(,|;)\s*/, + onSelect: ia_on_autocomplete_select, + deferRequestBy: 0, //miliseconds + params: { + action: 'bp_dedication_autocomplete_ajax_handler' + }, + noCache: true //set to true, to disable caching + }; + + j("#dedicate_to_input").autocomplete(options); + + var url = ''; + + j('#video_url').change(function(){ + // Check for empty input field + if(j('#video_url').val() != ''){ + // Get youtube video's thumbnail url + // using jYoutube jQuery plugin + url = j.jYoutube(j('#video_url').val()); + + // Now append this image to
    + j('#thumbs').html(j('')); + } + }); + + j("#user-list li a.remove").live("click", function() { + var friend_id = j(this).prop('id'); + + friend_id = friend_id.split('-'); + friend_id = friend_id[1]; + + j.post( ajaxurl, { + action: 'bp_dedication_add_user_ajax_handler', + 'friend_action': 'remove', + 'cookie': encodeURIComponent(document.cookie), + //'_wpnonce': j("input#_wpnonce_invite_uninvite_user").val(), + 'friend_id': friend_id + }, + function(response) + { + friendIDs = j('#friend_ids').val().split(','); + friendIDs.splice(j.inArray(friend_id, friendIDs),1); + j('#friend_ids').val(friendIDs.toString()); + + j('#user-list li#uid-' + friend_id).remove(); + }); + + return false; + }); + +}); + +function ia_on_autocomplete_select( value, data ) { + var j = jQuery; + var friendIDs; + + // Check the right checkbox + //j('#invite-anyone-member-list input#f-' + data).prop('checked',true); + + j('#dedicate_to_input').addClass('loading'); + + j.post( ajaxurl, { + action: 'bp_dedication_add_user_ajax_handler', + 'friend_action': 'add', + 'cookie': encodeURIComponent(document.cookie), + //'_wpnonce': j("input#_wpnonce_invite_uninvite_user").val(), + 'friend_id': data + }, + function(response) + { + friendIDs = j('#friend_ids').val().split(','); + friendIDs.push(data); + j('#friend_ids').val(friendIDs.toString()); + + j('#user-list').append(response); + j('#dedicate_to_input').removeClass('loading'); + }); + + // Remove the value from the send-to-input box + j('#dedicate_to_input').val(''); +} \ No newline at end of file diff --git a/wp-content/plugins/bp-dedication/includes/js/jquery.jyoutube.js.js b/wp-content/plugins/bp-dedication/includes/js/jquery.jyoutube.js.js new file mode 100644 index 0000000..5df814b --- /dev/null +++ b/wp-content/plugins/bp-dedication/includes/js/jquery.jyoutube.js.js @@ -0,0 +1,33 @@ +/* + * jYoutube 1.0 - YouTube video image getter plugin for jQuery + * + * Copyright (c) 2009 jQuery Howto + * + * Licensed under the GPL license: + * http://www.gnu.org/licenses/gpl.html + * + * Plugin home & Author URL: + * http://jquery-howto.blogspot.com + * + */ +(function($){ + $.extend({ + jYoutube: function( url, size ){ + if(url === null){ return ""; } + + size = (size === null) ? "big" : size; + var vid; + var results; + + results = url.match("[\\?&]v=([^&#]*)"); + + vid = ( results === null ) ? url : results[1]; + + if(size == "small"){ + return "http://img.youtube.com/vi/"+vid+"/2.jpg"; + }else { + return "http://img.youtube.com/vi/"+vid+"/0.jpg"; + } + } + }) +})(jQuery); \ No newline at end of file diff --git a/wp-content/plugins/bp-dedication/includes/js/jquery.validate.min.js b/wp-content/plugins/bp-dedication/includes/js/jquery.validate.min.js new file mode 100644 index 0000000..edd6452 --- /dev/null +++ b/wp-content/plugins/bp-dedication/includes/js/jquery.validate.min.js @@ -0,0 +1,51 @@ +/** + * jQuery Validation Plugin 1.9.0 + * + * http://bassistance.de/jquery-plugins/jquery-plugin-validation/ + * http://docs.jquery.com/Plugins/Validation + * + * Copyright (c) 2006 - 2011 Jörn Zaefferer + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + */ +(function(c){c.extend(c.fn,{validate:function(a){if(this.length){var b=c.data(this[0],"validator");if(b)return b;this.attr("novalidate","novalidate");b=new c.validator(a,this[0]);c.data(this[0],"validator",b);if(b.settings.onsubmit){a=this.find("input, button");a.filter(".cancel").click(function(){b.cancelSubmit=true});b.settings.submitHandler&&a.filter(":submit").click(function(){b.submitButton=this});this.submit(function(d){function e(){if(b.settings.submitHandler){if(b.submitButton)var f=c("").attr("name", +b.submitButton.name).val(b.submitButton.value).appendTo(b.currentForm);b.settings.submitHandler.call(b,b.currentForm);b.submitButton&&f.remove();return false}return true}b.settings.debug&&d.preventDefault();if(b.cancelSubmit){b.cancelSubmit=false;return e()}if(b.form()){if(b.pendingRequest){b.formSubmitted=true;return false}return e()}else{b.focusInvalid();return false}})}return b}else a&&a.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing")},valid:function(){if(c(this[0]).is("form"))return this.validate().form(); +else{var a=true,b=c(this[0].form).validate();this.each(function(){a&=b.element(this)});return a}},removeAttrs:function(a){var b={},d=this;c.each(a.split(/\s/),function(e,f){b[f]=d.attr(f);d.removeAttr(f)});return b},rules:function(a,b){var d=this[0];if(a){var e=c.data(d.form,"validator").settings,f=e.rules,g=c.validator.staticRules(d);switch(a){case "add":c.extend(g,c.validator.normalizeRule(b));f[d.name]=g;if(b.messages)e.messages[d.name]=c.extend(e.messages[d.name],b.messages);break;case "remove":if(!b){delete f[d.name]; +return g}var h={};c.each(b.split(/\s/),function(j,i){h[i]=g[i];delete g[i]});return h}}d=c.validator.normalizeRules(c.extend({},c.validator.metadataRules(d),c.validator.classRules(d),c.validator.attributeRules(d),c.validator.staticRules(d)),d);if(d.required){e=d.required;delete d.required;d=c.extend({required:e},d)}return d}});c.extend(c.expr[":"],{blank:function(a){return!c.trim(""+a.value)},filled:function(a){return!!c.trim(""+a.value)},unchecked:function(a){return!a.checked}});c.validator=function(a, +b){this.settings=c.extend(true,{},c.validator.defaults,a);this.currentForm=b;this.init()};c.validator.format=function(a,b){if(arguments.length==1)return function(){var d=c.makeArray(arguments);d.unshift(a);return c.validator.format.apply(this,d)};if(arguments.length>2&&b.constructor!=Array)b=c.makeArray(arguments).slice(1);if(b.constructor!=Array)b=[b];c.each(b,function(d,e){a=a.replace(RegExp("\\{"+d+"\\}","g"),e)});return a};c.extend(c.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error", +validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:c([]),errorLabelContainer:c([]),onsubmit:true,ignore:":hidden",ignoreTitle:false,onfocusin:function(a){this.lastActive=a;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass);this.addWrapper(this.errorsFor(a)).hide()}},onfocusout:function(a){if(!this.checkable(a)&&(a.name in this.submitted||!this.optional(a)))this.element(a)}, +onkeyup:function(a){if(a.name in this.submitted||a==this.lastElement)this.element(a)},onclick:function(a){if(a.name in this.submitted)this.element(a);else a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).addClass(b).removeClass(d):c(a).addClass(b).removeClass(d)},unhighlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).removeClass(b).addClass(d):c(a).removeClass(b).addClass(d)}},setDefaults:function(a){c.extend(c.validator.defaults, +a)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:c.validator.format("Please enter no more than {0} characters."), +minlength:c.validator.format("Please enter at least {0} characters."),rangelength:c.validator.format("Please enter a value between {0} and {1} characters long."),range:c.validator.format("Please enter a value between {0} and {1}."),max:c.validator.format("Please enter a value less than or equal to {0}."),min:c.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){function a(e){var f=c.data(this[0].form,"validator"),g="on"+e.type.replace(/^validate/, +"");f.settings[g]&&f.settings[g].call(f,this[0],e)}this.labelContainer=c(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||c(this.currentForm);this.containers=c(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var b=this.groups={};c.each(this.settings.groups,function(e,f){c.each(f.split(/\s/),function(g,h){b[h]=e})});var d= +this.settings.rules;c.each(d,function(e,f){d[e]=c.validator.normalizeRule(f)});c(this.currentForm).validateDelegate("[type='text'], [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",a).validateDelegate("[type='radio'], [type='checkbox'], select, option","click", +a);this.settings.invalidHandler&&c(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){this.checkForm();c.extend(this.submitted,this.errorMap);this.invalid=c.extend({},this.errorMap);this.valid()||c(this.currentForm).triggerHandler("invalid-form",[this]);this.showErrors();return this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(a){this.lastElement= +a=this.validationTargetFor(this.clean(a));this.prepareElement(a);this.currentElements=c(a);var b=this.check(a);if(b)delete this.invalid[a.name];else this.invalid[a.name]=true;if(!this.numberOfInvalids())this.toHide=this.toHide.add(this.containers);this.showErrors();return b},showErrors:function(a){if(a){c.extend(this.errorMap,a);this.errorList=[];for(var b in a)this.errorList.push({message:a[b],element:this.findByName(b)[0]});this.successList=c.grep(this.successList,function(d){return!(d.name in a)})}this.settings.showErrors? +this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){c.fn.resetForm&&c(this.currentForm).resetForm();this.submitted={};this.lastElement=null;this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b=0,d;for(d in a)b++;return b},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return this.size()== +0},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{c(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(a){}},findLastActive:function(){var a=this.lastActive;return a&&c.grep(this.errorList,function(b){return b.element.name==a.name}).length==1&&a},elements:function(){var a=this,b={};return c(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&& +a.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in b||!a.objectLength(c(this).rules()))return false;return b[this.name]=true})},clean:function(a){return c(a)[0]},errors:function(){return c(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext)},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=c([]);this.toHide=c([]);this.currentElements=c([])},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers)}, +prepareElement:function(a){this.reset();this.toHide=this.errorsFor(a)},check:function(a){a=this.validationTargetFor(this.clean(a));var b=c(a).rules(),d=false,e;for(e in b){var f={method:e,parameters:b[e]};try{var g=c.validator.methods[e].call(this,a.value.replace(/\r/g,""),a,f.parameters);if(g=="dependency-mismatch")d=true;else{d=false;if(g=="pending"){this.toHide=this.toHide.not(this.errorsFor(a));return}if(!g){this.formatAndAdd(a,f);return false}}}catch(h){this.settings.debug&&window.console&&console.log("exception occured when checking element "+ +a.id+", check the '"+f.method+"' method",h);throw h;}}if(!d){this.objectLength(b)&&this.successList.push(a);return true}},customMetaMessage:function(a,b){if(c.metadata){var d=this.settings.meta?c(a).metadata()[this.settings.meta]:c(a).metadata();return d&&d.messages&&d.messages[b]}},customMessage:function(a,b){var d=this.settings.messages[a];return d&&(d.constructor==String?d:d[b])},findDefined:function(){for(var a=0;aWarning: No message defined for "+a.name+"")},formatAndAdd:function(a,b){var d=this.defaultMessage(a,b.method),e=/\$?\{(\d+)\}/g;if(typeof d=="function")d=d.call(this,b.parameters,a);else if(e.test(d))d=jQuery.format(d.replace(e,"{$1}"),b.parameters);this.errorList.push({message:d,element:a});this.errorMap[a.name]=d;this.submitted[a.name]= +d},addWrapper:function(a){if(this.settings.wrapper)a=a.add(a.parent(this.settings.wrapper));return a},defaultShowErrors:function(){for(var a=0;this.errorList[a];a++){var b=this.errorList[a];this.settings.highlight&&this.settings.highlight.call(this,b.element,this.settings.errorClass,this.settings.validClass);this.showLabel(b.element,b.message)}if(this.errorList.length)this.toShow=this.toShow.add(this.containers);if(this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]); +if(this.settings.unhighlight){a=0;for(b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass)}this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return c(this.errorList).map(function(){return this.element})},showLabel:function(a,b){var d=this.errorsFor(a);if(d.length){d.removeClass(this.settings.validClass).addClass(this.settings.errorClass); +d.attr("generated")&&d.html(b)}else{d=c("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(a),generated:true}).addClass(this.settings.errorClass).html(b||"");if(this.settings.wrapper)d=d.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();this.labelContainer.append(d).length||(this.settings.errorPlacement?this.settings.errorPlacement(d,c(a)):d.insertAfter(a))}if(!b&&this.settings.success){d.text("");typeof this.settings.success=="string"?d.addClass(this.settings.success):this.settings.success(d)}this.toShow= +this.toShow.add(d)},errorsFor:function(a){var b=this.idOrName(a);return this.errors().filter(function(){return c(this).attr("for")==b})},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(a){if(this.checkable(a))a=this.findByName(a.name).not(this.settings.ignore)[0];return a},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(a){var b=this.currentForm;return c(document.getElementsByName(a)).map(function(d, +e){return e.form==b&&e.name==a&&e||null})},getLength:function(a,b){switch(b.nodeName.toLowerCase()){case "select":return c("option:selected",b).length;case "input":if(this.checkable(b))return this.findByName(b.name).filter(":checked").length}return a.length},depend:function(a,b){return this.dependTypes[typeof a]?this.dependTypes[typeof a](a,b):true},dependTypes:{"boolean":function(a){return a},string:function(a,b){return!!c(a,b.form).length},"function":function(a,b){return a(b)}},optional:function(a){return!c.validator.methods.required.call(this, +c.trim(a.value),a)&&"dependency-mismatch"},startRequest:function(a){if(!this.pending[a.name]){this.pendingRequest++;this.pending[a.name]=true}},stopRequest:function(a,b){this.pendingRequest--;if(this.pendingRequest<0)this.pendingRequest=0;delete this.pending[a.name];if(b&&this.pendingRequest==0&&this.formSubmitted&&this.form()){c(this.currentForm).submit();this.formSubmitted=false}else if(!b&&this.pendingRequest==0&&this.formSubmitted){c(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted= +false}},previousValue:function(a){return c.data(a,"previousValue")||c.data(a,"previousValue",{old:null,valid:true,message:this.defaultMessage(a,"remote")})}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(a,b){a.constructor==String?this.classRuleSettings[a]=b:c.extend(this.classRuleSettings, +a)},classRules:function(a){var b={};(a=c(a).attr("class"))&&c.each(a.split(" "),function(){this in c.validator.classRuleSettings&&c.extend(b,c.validator.classRuleSettings[this])});return b},attributeRules:function(a){var b={};a=c(a);for(var d in c.validator.methods){var e;if(e=d==="required"&&typeof c.fn.prop==="function"?a.prop(d):a.attr(d))b[d]=e;else if(a[0].getAttribute("type")===d)b[d]=true}b.maxlength&&/-1|2147483647|524288/.test(b.maxlength)&&delete b.maxlength;return b},metadataRules:function(a){if(!c.metadata)return{}; +var b=c.data(a.form,"validator").settings.meta;return b?c(a).metadata()[b]:c(a).metadata()},staticRules:function(a){var b={},d=c.data(a.form,"validator");if(d.settings.rules)b=c.validator.normalizeRule(d.settings.rules[a.name])||{};return b},normalizeRules:function(a,b){c.each(a,function(d,e){if(e===false)delete a[d];else if(e.param||e.depends){var f=true;switch(typeof e.depends){case "string":f=!!c(e.depends,b.form).length;break;case "function":f=e.depends.call(b,b)}if(f)a[d]=e.param!==undefined? +e.param:true;else delete a[d]}});c.each(a,function(d,e){a[d]=c.isFunction(e)?e(b):e});c.each(["minlength","maxlength","min","max"],function(){if(a[this])a[this]=Number(a[this])});c.each(["rangelength","range"],function(){if(a[this])a[this]=[Number(a[this][0]),Number(a[this][1])]});if(c.validator.autoCreateRanges){if(a.min&&a.max){a.range=[a.min,a.max];delete a.min;delete a.max}if(a.minlength&&a.maxlength){a.rangelength=[a.minlength,a.maxlength];delete a.minlength;delete a.maxlength}}a.messages&&delete a.messages; +return a},normalizeRule:function(a){if(typeof a=="string"){var b={};c.each(a.split(/\s/),function(){b[this]=true});a=b}return a},addMethod:function(a,b,d){c.validator.methods[a]=b;c.validator.messages[a]=d!=undefined?d:c.validator.messages[a];b.length<3&&c.validator.addClassRules(a,c.validator.normalizeRule(a))},methods:{required:function(a,b,d){if(!this.depend(d,b))return"dependency-mismatch";switch(b.nodeName.toLowerCase()){case "select":return(a=c(b).val())&&a.length>0;case "input":if(this.checkable(b))return this.getLength(a, +b)>0;default:return c.trim(a).length>0}},remote:function(a,b,d){if(this.optional(b))return"dependency-mismatch";var e=this.previousValue(b);this.settings.messages[b.name]||(this.settings.messages[b.name]={});e.originalMessage=this.settings.messages[b.name].remote;this.settings.messages[b.name].remote=e.message;d=typeof d=="string"&&{url:d}||d;if(this.pending[b.name])return"pending";if(e.old===a)return e.valid;e.old=a;var f=this;this.startRequest(b);var g={};g[b.name]=a;c.ajax(c.extend(true,{url:d, +mode:"abort",port:"validate"+b.name,dataType:"json",data:g,success:function(h){f.settings.messages[b.name].remote=e.originalMessage;var j=h===true;if(j){var i=f.formSubmitted;f.prepareElement(b);f.formSubmitted=i;f.successList.push(b);f.showErrors()}else{i={};h=h||f.defaultMessage(b,"remote");i[b.name]=e.message=c.isFunction(h)?h(a):h;f.showErrors(i)}e.valid=j;f.stopRequest(b,j)}},d));return"pending"},minlength:function(a,b,d){return this.optional(b)||this.getLength(c.trim(a),b)>=d},maxlength:function(a, +b,d){return this.optional(b)||this.getLength(c.trim(a),b)<=d},rangelength:function(a,b,d){a=this.getLength(c.trim(a),b);return this.optional(b)||a>=d[0]&&a<=d[1]},min:function(a,b,d){return this.optional(b)||a>=d},max:function(a,b,d){return this.optional(b)||a<=d},range:function(a,b,d){return this.optional(b)||a>=d[0]&&a<=d[1]},email:function(a,b){return this.optional(b)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(a)}, +url:function(a,b){return this.optional(b)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)}, +date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a))},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(a)},number:function(a,b){return this.optional(b)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},creditcard:function(a,b){if(this.optional(b))return"dependency-mismatch";if(/[^0-9 -]+/.test(a))return false;var d=0,e=0,f=false;a=a.replace(/\D/g,"");for(var g=a.length-1;g>= +0;g--){e=a.charAt(g);e=parseInt(e,10);if(f)if((e*=2)>9)e-=9;d+=e;f=!f}return d%10==0},accept:function(a,b,d){d=typeof d=="string"?d.replace(/,/g,"|"):"png|jpe?g|gif";return this.optional(b)||a.match(RegExp(".("+d+")$","i"))},equalTo:function(a,b,d){d=c(d).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){c(b).valid()});return a==d.val()}}});c.format=c.validator.format})(jQuery); +(function(c){var a={};if(c.ajaxPrefilter)c.ajaxPrefilter(function(d,e,f){e=d.port;if(d.mode=="abort"){a[e]&&a[e].abort();a[e]=f}});else{var b=c.ajax;c.ajax=function(d){var e=("port"in d?d:c.ajaxSettings).port;if(("mode"in d?d:c.ajaxSettings).mode=="abort"){a[e]&&a[e].abort();return a[e]=b.apply(this,arguments)}return b.apply(this,arguments)}}})(jQuery); +(function(c){!jQuery.event.special.focusin&&!jQuery.event.special.focusout&&document.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.handle.call(this,e)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)},handler:function(e){arguments[0]=c.event.fix(e);arguments[0].type=b;return c.event.handle.apply(this,arguments)}}});c.extend(c.fn,{validateDelegate:function(a, +b,d){return this.bind(b,function(e){var f=c(e.target);if(f.is(a))return d.apply(f,arguments)})}})})(jQuery); diff --git a/wp-content/plugins/dedication-from-site/dedication-from-site.class.php b/wp-content/plugins/dedication-from-site/dedication-from-site.class.php new file mode 100644 index 0000000..d471c53 --- /dev/null +++ b/wp-content/plugins/dedication-from-site/dedication-from-site.class.php @@ -0,0 +1,515 @@ +form_id = $id; + $this->linktext = $linktext; + $this->popup = $popup; + $this->cat = $cat; + + register_activation_hook( __FILE__, array($this,'install') ); + + // add pfs_domain for translation + load_plugin_textdomain('pfs_domain'); + + // add pfs_options group & apply validation filter, add settings fields & section + add_action('admin_init', array($this, 'admin_init') ); + + // add js & css + add_action( 'get_header', array($this,'includes') ); + + // add admin page & options + add_action( 'admin_menu', array($this, 'show_settings') ); + + // add shortcode support + add_shortcode( 'post-from-site', array($this, 'shortcode') ); + + // add admin menu item. Probably not going to happen. + //add_action( 'admin_bar_menu', array($this, 'add_admin_link'), 1000 ); + } + + public function install(){ + //nothing here yet, as there's really nothing to 'install' that isn't covered by __construct + } + + /** + * Add options to databases with defaults + */ + public function show_settings() { + add_options_page('Dedication From Site', 'Dedication From Site', 'manage_options', 'pfs', array($this, 'settings') ); + + if (!get_option("pfs_options")) { + $options= array( 0 => array() ); + $options[0]['default_author'] = ''; + $options[0]['allow_image'] = true; + $options[0]['wp_image_size'] = 'medium'; + + $options[0]['post_status'] = 'publish'; + $options[0]['post_type'] = 'post'; + $options[0]['comment_status'] = 'open'; + $options[0]['post_category'] = ''; + $options[0]['taxonomy'] = array(); + + $options[0]['enable_captcha'] = false; + $options[0]['allow_anon'] = false; + $options['recaptcha_public_key'] = ''; + $options['recaptcha_private_key'] = ''; + add_option ("pfs_options", $options) ; + } + } + + /** + * What to display in the admin menu + */ + public function settings() { ?> +
    +

    + +
    + + + + + +
    + +
    + Create new user?', array($this, 'setting_default_author'), 'pfs', 'pfs_users'); + add_settings_field('pfs_enable_captcha', 'Enable Recaptcha for not logged in users? (recommended)', array($this, 'setting_enable_captcha'), 'pfs', 'pfs_users'); + add_settings_field('pfs_recaptcha_public_key', 'Recaptcha API public key:', array($this, 'setting_recaptcha_public_key'), 'pfs', 'pfs_users'); + add_settings_field('pfs_recaptcha_private_key', 'Recaptcha API private key:', array($this, 'setting_recaptcha_private_key'), 'pfs', 'pfs_users'); + + add_settings_section('pfs_post', 'Post Creation Settings', array($this, 'setting_section_post'), 'pfs'); + add_settings_field('pfs_post_status', 'Post status:', array($this, 'setting_post_status'), 'pfs', 'pfs_post'); + add_settings_field('pfs_post_type', 'Post type:
    Custom Post Types supported!', array($this, 'setting_post_type'), 'pfs', 'pfs_post'); + add_settings_field('pfs_comment_status', 'Comment status:', array($this, 'setting_comment_status'), 'pfs', 'pfs_post'); + add_settings_field('pfs_taxonomy', 'Allowed taxonomies:', array($this, 'setting_taxonomy'), 'pfs', 'pfs_post'); + add_settings_field('pfs_post_category', 'Post category:', array($this, 'setting_category'), 'pfs', 'pfs_post'); + + add_settings_section('pfs_image', 'Image Upload Settings', array($this, 'setting_section_image'), 'pfs'); + add_settings_field('pfs_allow_image', 'Allow users to upload an image?', array($this, 'setting_allow_image'), 'pfs', 'pfs_image'); + add_settings_field('pfs_wp_image_size', 'Image size setting to use:', array($this, 'setting_wp_image_size'), 'pfs', 'pfs_image'); + + + } + function setting_section_users() { + echo '

    By default, all logged-in users can use the post-from-site interface to create a post.

    '; + } + function setting_allow_anon() { + $options = get_option('pfs_options'); + $options = $options[0]; + echo ""; + } + function setting_default_author() { + $options = get_option('pfs_options'); + $options = $options[0]; + /* listing of authors */ + wp_dropdown_users( array( + 'blog_id' => get_current_blog_id(), + 'name' => 'pfs_options[0][default_author]', + 'id' => 'pfs_default_author', + 'selected' => $options['default_author'] + ) ); + } + function setting_enable_captcha() { + $options = get_option('pfs_options'); + $options = $options[0]; + echo ""; + } + function setting_recaptcha_public_key() { + $options = get_option('pfs_options'); + echo ""; + } + function setting_recaptcha_private_key() { + $options = get_option('pfs_options'); + echo ""; + } + + function setting_section_post() { + echo '

    Settings for posts created by Post From Site. Defaults to a published Post with comments open, and no taxonomies.

    '; + } + function setting_post_status() { + $options = get_option('pfs_options'); + $options = $options[0]; + echo ""; + } + function setting_post_type() { + $options = get_option('pfs_options'); + $options = $options[0]; + echo ""; + } + function setting_comment_status() { + $options = get_option('pfs_options'); + $options = $options[0]; + echo ""; + } + function setting_taxonomy() { + $options = get_option('pfs_options'); + $options = $options[0]; + $taxonomies = get_taxonomies(array( 'public' => true ),'object'); + echo "
      "; + foreach ($taxonomies as $taxonomy ) { + echo '
    • '; + } + echo "
    "; + } + function setting_category() { + $options = get_option('pfs_options'); + $options = $options[0]; + $categories = get_categories(array( 'public' => true ),'object'); + + echo ""; + } + + function setting_section_image() { + echo '

    Main description of this section here.

    '; + } + function setting_allow_image() { + $options = get_option('pfs_options'); + $options = $options[0]; + echo ""; + } + function setting_wp_image_size() { + $options = get_option('pfs_options'); + $options = $options[0]; + $sizes = get_intermediate_image_sizes(); + echo ""; + } + + /** + * Sanitize and validate input. + * @param array $input an array to sanitize + * @return array a valid array. + */ + public function validate($input) { + $ok = array('publish','pending','draft'); + $users = array(); + $user_objs = get_users( array( + 'blog_id' => $GLOBALS['blog_id'], + 'fields' => array( 'ID', 'user_login' ) + ) ); + foreach ( $user_objs as $u ){ + $users[] = $u->ID; + } + + foreach ($input as $i => $val) { + if (is_array($val)){ + $input[$i]['allow_anon'] = array_key_exists('allow_anon',$val); + $input[$i]['default_author'] = (in_array($val['default_author'], $users)) ? $val['default_author'] : 'anon' ; + $input[$i]['enable_captcha'] = array_key_exists('enable_captcha',$val); + + $input[$i]['post_status'] = (in_array($val['post_status'],$ok) ? $val['post_status'] : 'pending'); + $input[$i]['post_type'] = (post_type_exists($val['post_type']) ? $val['post_type'] : 'post'); + $input[$i]['comment_status'] = ($val['comment_status'] == 'open' ? 'open' : 'closed'); + if ( array_key_exists('taxonomy',$val) ){ + foreach ( $input[$i]['taxonomy'] as $j => $tax) { + if (!taxonomy_exists($tax)) { + unset($input[$i]['taxonomy'][$j]); + } + } + } + + $input[$i]['allow_image'] = array_key_exists('allow_image', $val); + $input[$i]['wp_image_size'] = (in_array($val['wp_image_size'],get_intermediate_image_sizes())) ? $val['wp_image_size'] : 'medium'; + } + } + $input['recaptcha_public_key'] = urlencode($input['recaptcha_public_key']); + $input['recaptcha_private_key'] = urlencode($input['recaptcha_private_key']); + return $input; + } + + /** + * Add javascript and css to header files. + */ + public function includes(){ + if (is_page(array(1054, 'new-dedication'))) { + wp_enqueue_script( 'jquery-autocomplete-js', plugins_url("includes/jquery.autocomplete-min.js",__FILE__), array( 'jquery' ) ); + wp_enqueue_script( 'jquery-multi-upload', plugins_url("includes/jquery.MultiFile.pack.js",__FILE__), array('jquery','jquery-form') ); + wp_enqueue_script( 'pfs-script', plugins_url("includes/pfs-script.js",__FILE__) ); + + wp_localize_script('pfs-script', 'pfs_script_vars', array( + 'source_url' => plugins_url("search.php",__FILE__) + ) + ); + + wp_enqueue_style( 'pfs-min-style', plugins_url("includes/minimal.css",__FILE__) ); + $theme_css = apply_filters( 'pfs_theme_css', plugins_url("includes/twentyeleven.css",__FILE__) ); + wp_enqueue_style( 'pfs-style', $theme_css ); + } + } + + /** + * Add shortcode support. + * @param $atts shortcode attributes, cat, link, and popup + * cat is the category to post to, link is the display text of the link, + * and popup decides whether it's an inline form (false) or a popup box (true). + */ + function shortcode($atts, $content=null, $code="") { + $a = shortcode_atts( array( + 'link' => 'quick post', + 'popup' => false, + 'cat' => '' + ), $atts ); + $pfs = new DedicationFromSite(0, $a['link'], $a['popup'], $a['cat']); + return $pfs->get_form(); + } + + /** + * Add a link to show the form from the admin bar + function add_admin_link() { + global $wp_admin_bar, $wpdb; + if ( !is_super_admin() || !is_admin_bar_showing() ) + return; + $this->popup = false; + $form = "".$this->get_form(); + / * Add the main siteadmin menu item * / + $wp_admin_bar->add_menu( array( 'id' => 'post_from_site', 'title' => __( 'Write a Post', 'pfs_domain' ), 'href' => FALSE ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'post_from_site', 'title' => $form, 'href' => FALSE ) ); + } */ + + /** + * Creates link and postbox (initially hidden with display:none), calls pfs_submit on form-submission. Echos the form. + * @param string $cat Category ID for posting specifically to one category. Default is '', which allows user to choose from allowed categories. + * @param string $linktext Link text for post link. Default is set in admin settings, any text here will override that. + * @param bool $popup Whether the box should be a 'modal-style' popup or always display + */ + public function form(){ + echo $this->get_form(); + } + + /** + * Creates link and postbox (initially hidden with display:none), calls pfs_submit on form-submission. Returns the form. + * @param string $cat Category ID for posting specifically to one category. Default is '', which allows user to choose from allowed categories. + * @param string $linktext Link text for post link. Default is set in admin settings, any text here will override that. + * @param bool $popup Whether the box should be a 'modal-style' popup or always display + */ + public function get_form(){ + $linktext = $this->linktext; + $cat = $this->cat; + $popup = $this->popup; + $id = $this->form_id; + $pfs_options = get_option('pfs_options'); + $options = $pfs_options[0]; + + + /*$from_user_link = bp_get_loggedin_user_link(); + $from_user_username = bp_loggedin_user_username(); + bp_loggedin_user_fullname()*/ + $from_flag = gp_get_the_flag(bp_loggedin_user_id()); + + + if (''==$linktext) $linktext = apply_filters( 'pfs_default_link_text', __('Click to post.','pfs_domain') ); + $idtext = $cat.sanitize_html_class($linktext); + + $out = ''; + + $out .= "
    \n"; + $out .= "\n"; + $out .= "\n"; + $out .= "\n"; + $out .= apply_filters( 'pfs_form_start', '', $idtext ); + + // from + $out .= ""; + $out .= "
    " . $from_flag . "" . bp_get_loggedin_user_username() . "
    "; + //$out .= "\n"; + + // to + $out .= ""; + $out .= "\n"; + + $out .= " \n"; + + if (!current_user_can('publish_posts') && $options['allow_anon']){ //if not logged in/able to publish posts, and anon posting allowed, show name/email + $out .= " "; + $out .= " \n"; + } + //$out .= "\n"; + + if ( array_key_exists('taxonomy',$options) ){ + foreach ($options['taxonomy'] as $i => $tax){ + //if ($tax != 'category' || empty($cat)){ + $out .= $this->get_taxonomy_list($tax); + //} + } + } + if ($options['allow_image']) { + $out .= ""; + /*$out .= ""; + $out .= "";*/ + $out .= "
    \n"; + } + $out .= "
    \n"; + if ($options['enable_captcha'] && !current_user_can('publish_posts') && $options['allow_anon'] ){ + if ( !empty($pfs_options['recaptcha_public_key']) ) { + require_once('recaptchalib.php'); + $publickey = $pfs_options['recaptcha_public_key']; // you got this from the signup page + $out .= recaptcha_get_html($publickey); + } else { + return ""; + } + } + $out .= apply_filters( 'pfs_before_submit', '', $idtext ); + $out .= "\n"; + $out .= apply_filters( 'pfs_form_end', '', $idtext ); + $out .= "\n
    \n"; + $out .= apply_filters( 'pfs_after_form', '', $idtext ); + } else { + $out .= apply_filters( 'pfs_alert_login', "

    You must be logged in to post.

    " ); + } + $out .= "
    \n\n"; + return $out; + } + + /** + * return the categories + * @param string $excluded Categories which are excluded + */ + public function get_taxonomy_list( $taxonomy ){ + $terms = get_terms($taxonomy, array( + 'hide_empty' => 0 + )); + if (!$terms || empty($terms)) return ''; + //preg_match_all('/\s*
    ");c.mouseover(j(f));c.click(k(f));this.container.append(c)}this.enabled=true;this.container.show()}},processResponse:function(b){var a;try{a=eval("("+b+")")}catch(c){return}if(!d.isArray(a.data))a.data=[];if(!this.options.noCache){this.cachedResponse[a.query]= a;a.suggestions.length===0&&this.badQueries.push(a.query)}if(a.query===this.getQuery(this.currentValue)){this.suggestions=a.suggestions;this.data=a.data;this.suggest()}},activate:function(b){var a,c;a=this.container.children();this.selectedIndex!==-1&&a.length>this.selectedIndex&&d(a.get(this.selectedIndex)).removeClass();this.selectedIndex=b;if(this.selectedIndex!==-1&&a.length>this.selectedIndex){c=a.get(this.selectedIndex);d(c).addClass("selected")}return c},deactivate:function(b,a){b.className= "";if(this.selectedIndex===a)this.selectedIndex=-1},select:function(b){var a;if(a=this.suggestions[b]){this.el.val(a);if(this.options.autoSubmit){a=this.el.parents("form");a.length>0&&a.get(0).submit()}this.ignoreValueChange=true;this.hide();this.onSelect(b)}},moveUp:function(){if(this.selectedIndex!==-1)if(this.selectedIndex===0){this.container.children().get(0).className="";this.selectedIndex=-1;this.el.val(this.currentValue)}else this.adjustScroll(this.selectedIndex-1)},moveDown:function(){this.selectedIndex!== this.suggestions.length-1&&this.adjustScroll(this.selectedIndex+1)},adjustScroll:function(b){var a,c,e;a=this.activate(b).offsetTop;c=this.container.scrollTop();e=c+this.options.maxHeight-25;if(ae&&this.container.scrollTop(a-this.options.maxHeight+25);this.el.val(this.getValue(this.suggestions[b]))},onSelect:function(b){var a,c;a=this.options.onSelect;c=this.suggestions[b];b=this.data[b];this.el.val(this.getValue(c));d.isFunction(a)&&a(c,b,this.el)},getValue:function(b){var a, c;a=this.options.delimiter;if(!a)return b;c=this.currentValue;a=c.split(a);if(a.length===1)return b;return c.substr(0,c.length-a[a.length-1].length)+b}}})(jQuery); \ No newline at end of file diff --git a/wp-content/plugins/bp-dedication/includes/js/jquery.autocomplete.js b/wp-content/plugins/dedication-from-site/includes/jquery.autocomplete.js similarity index 100% rename from wp-content/plugins/bp-dedication/includes/js/jquery.autocomplete.js rename to wp-content/plugins/dedication-from-site/includes/jquery.autocomplete.js diff --git a/wp-content/plugins/bp-dedication/includes/css/minimal.css b/wp-content/plugins/dedication-from-site/includes/minimal.css similarity index 100% rename from wp-content/plugins/bp-dedication/includes/css/minimal.css rename to wp-content/plugins/dedication-from-site/includes/minimal.css diff --git a/wp-content/plugins/bp-dedication/includes/js/pfs-script.bak.js b/wp-content/plugins/dedication-from-site/includes/pfs-script.bak.js similarity index 100% rename from wp-content/plugins/bp-dedication/includes/js/pfs-script.bak.js rename to wp-content/plugins/dedication-from-site/includes/pfs-script.bak.js diff --git a/wp-content/plugins/bp-dedication/includes/js/pfs-script.js b/wp-content/plugins/dedication-from-site/includes/pfs-script.js similarity index 100% rename from wp-content/plugins/bp-dedication/includes/js/pfs-script.js rename to wp-content/plugins/dedication-from-site/includes/pfs-script.js diff --git a/wp-content/plugins/bp-dedication/includes/css/twentyeleven.css b/wp-content/plugins/dedication-from-site/includes/twentyeleven.css similarity index 100% rename from wp-content/plugins/bp-dedication/includes/css/twentyeleven.css rename to wp-content/plugins/dedication-from-site/includes/twentyeleven.css diff --git a/wp-content/plugins/dedication-from-site/pfs-submit.php b/wp-content/plugins/dedication-from-site/pfs-submit.php new file mode 100644 index 0000000..1442280 --- /dev/null +++ b/wp-content/plugins/dedication-from-site/pfs-submit.php @@ -0,0 +1,202 @@ +".print_r($pfs_data, true)."\n"; + echo "
    ".print_r($pfs_files, true)."
    \n"; + + $title = $pfs_data['title']; + $postcontent = $pfs_data['postcontent']; + + $name = (array_key_exists('name',$pfs_data)) ? esc_html($pfs_data['name'],array()) : ''; + $email = (array_key_exists('email',$pfs_data)) ? sanitize_email($pfs_data['email']) : ''; + + $taxonomies = array(); + + $imgAllowed = 0; + $result = Array( + 'image'=>"", + 'error'=>"", + 'success'=>"", + 'post'=>"" + ); + $success = False; + $upload = False; + + if ( !current_user_can('publish_posts') && $pfs_options['allow_anon'] && $pfs_options['enable_captcha'] ){ + require_once('recaptchalib.php'); + $privatekey = $pfs_options_arr['recaptcha_private_key']; + $resp = recaptcha_check_answer ($privatekey, + $_SERVER["REMOTE_ADDR"], + $_POST["recaptcha_challenge_field"], + $_POST["recaptcha_response_field"]); + } + if ( !current_user_can('publish_posts') && $pfs_options['allow_anon'] && $pfs_options['enable_captcha'] && !$resp->is_valid ) { + // What happens when the CAPTCHA was entered incorrectly + $result['error'] = printf(__("Incorrect reCAPTCHA: %s",'pfs_domain'), $resp->error); + } else { + //echo "
    ".print_r($pfs_files['image']['name'], true)."
    \n"; + if (array_key_exists('image',$pfs_files)) { + /* play with the image */ + switch (True) { + case (1 < count($pfs_files['image']['name'])): + // multiple file upload + $result['image'] = "multiple"; + $file = $pfs_files['image']; + for ( $i = 0; $i < count($file['tmp_name']); $i++ ){ + if( ''!=$file['tmp_name'][$i] ){ + $imgAllowed = (getimagesize($file['tmp_name'][$i])) ? True : (''==$file['name'][$i]); + if ($imgAllowed){ + $upload[$i+1] = upload_image(array('name'=>$pfs_files["image"]["name"][$i], 'tmp_name'=>$pfs_files["image"]["tmp_name"][$i])); + if (False === $upload[$i+1]){ + $result['error'] = __("There was an error uploading the image.",'pfs_domain'); + } else { + $success[$i+1] = True; + } + } else { + $result['error'] = __("Incorrect filetype. Only images (.gif, .png, .jpg, .jpeg) are allowed.",'pfs_domain'); + } + } + } + break; + case ((1 == count($pfs_files['image']['name'])) && ('' != $pfs_files['image']['name'][0]) ): + // single file upload + $file = $pfs_files['image']; + $result['image'] = 'single'; + $imgAllowed = (getimagesize($file['tmp_name'][0])) ? True : (''==$file['name'][0]); + if ($imgAllowed){ + $upload[1] = upload_image( array( 'name'=>$file["name"][0], 'tmp_name'=>$file["tmp_name"][0] ) ); + //echo "
    ".print_r($upload, true)."
    \n"; + if (False === $upload[1]){ + $result['error'] = __("There was an error uploading the image.",'pfs_domain'); + } else { + $success[1] = True; + } + } else { + $result['error'] = __("Incorrect filetype. Only images (.gif, .png, .jpg, .jpeg) are allowed.",'pfs_domain'); + } + break; + default: + $result['image'] = 'none'; + } + } + if ( '' != $result['error'] ) return $result; // fail if the image upload failed. + + //echo "
    ".print_r($upload, true)."
    \n"; + //echo "
    ".print_r($success, true)."
    \n"; + + /* manipulate $pfs_data into proper post array */ + $has_content_things = ($title != ''); + if ( !current_user_can('publish_posts') && $pfs_options['allow_anon'] ) $has_content_things = $has_content_things && ($name != '') && is_email($email); + + if ( $has_content_things ) { + $content = $postcontent; + if ( !current_user_can('publish_posts') && $pfs_options['allow_anon'] ) $content .= apply_filters('pfs_submittedby_text',"

    Submitted by $name

    "); + if ( is_user_logged_in() ){ + global $user_ID; + get_currentuserinfo(); + } + if (is_array($success)){ + foreach(array_keys($success) as $i){ + $imgtag = "[!--image$i--]"; + if (False === strpos($content,$imgtag)) $content .= "\n\n$imgtag"; + $content = str_replace($imgtag, wp_get_attachment_link( $upload[$i], $pfs_options['wp_image_size']), $content); + } + } + //if any [!--image#--] tags remain, they are invalid and should just be deleted. + $content = preg_replace('/\[\!--image\d*--\]/','',$content); + + // $terms[{tax name}] = array(term1, term2, etc) + if ( array_key_exists('terms',$pfs_data) ) { + foreach ($pfs_data['terms'] as $taxon => $terms){ + if ( !is_taxonomy_hierarchical($taxon) ) { + $pfs_data['terms'][$taxon] = implode(',',$terms); + } + } + } + + $postarr = array(); + $postarr['post_title'] = $title; + $postarr['post_content'] = apply_filters('comment_text', $content); + $postarr['comment_status'] = $pfs_options['comment_status']; + $postarr['post_status'] = $pfs_options['post_status']; + $postarr['post_author'] = ( is_user_logged_in() ) ? $user_ID : $pfs_options['default_author']; + $postarr['tax_input'] = (array_key_exists('terms',$pfs_data)) ? $pfs_data['terms'] : array(); + $postarr['post_type'] = $pfs_options['post_type']; + echo "
    ".print_r($postarr, true)."
    \n"; + $post_id = wp_insert_post($postarr); + + if (0 == $post_id) { + $result['error'] = __("Unable to insert post- unknown error.",'pfs_domain'); + } else { + $result['success'] = __("Post added, please wait to return to the previous page.",'pfs_domain'); + $result['post'] = $post_id; + } + } else { + $result['error'] = __("You've left a field empty. All fields are required",'pfs_domain'); + } + } + return $result; +} + +/** + * Upload images + */ +function upload_image($image){ + $file = wp_upload_bits( $image["name"], null, file_get_contents($image["tmp_name"])); + //echo "
    ";
    +    //var_dump($file);
    +    //echo "
    \n"; + if (false === $file['error']) { + $wp_filetype = wp_check_filetype(basename($file['file']), null ); + $attachment = array( + 'post_mime_type' => $wp_filetype['type'], + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($file['file'])), + 'post_content' => '', + 'post_status' => 'inherit' + ); + $attach_id = wp_insert_attachment( $attachment, $file['file'] ); + // you must first include the image.php file + // for the function wp_generate_attachment_metadata() to work + require_once(ABSPATH . "wp-admin" . '/includes/image.php'); + $attach_data = wp_generate_attachment_metadata( $attach_id, $file['file'] ); + wp_update_attachment_metadata( $attach_id, $attach_data ); + return $attach_id; + } else { + //TODO: er, error handling? + return false; + } +} + +var_dump($_POST); + + +if (!empty($_POST)){ + $pfs = pfs_submit($_POST,$_FILES); + echo json_encode($pfs); + echo "
    ".print_r($pfs, true)."
    \n"; +} else { + /* TODO: translate following */ + _e('You should not be seeing this page, something went wrong.','pfs_domain'); + echo "" . __('Go home?','pfs_domain') . ""; +} + +//get_footer(); +?> diff --git a/wp-content/plugins/dedication-from-site/pfs-widget.php b/wp-content/plugins/dedication-from-site/pfs-widget.php new file mode 100644 index 0000000..c9b3535 --- /dev/null +++ b/wp-content/plugins/dedication-from-site/pfs-widget.php @@ -0,0 +1,82 @@ + "Place a link on your site to pop up a 'write post' box.")); + } + + /** @see WP_Widget::widget */ + function widget($args, $instance) { + extract( $args ); + $title = apply_filters('widget_title', $instance['title']); + $category = $instance['category']; + $link = apply_filters('widget_title', $instance['link']); + $popup = $instance['popup']; + echo $before_widget; + if ( $title ) echo $before_title . $title . $after_title; + echo ""; + echo $after_widget; + } + + /** @see WP_Widget::update */ + function update($new_instance, $old_instance) { + $instance = $old_instance; + $instance['title'] = strip_tags($new_instance['title']); + $instance['category'] = strip_tags($new_instance['category']); + $instance['link'] = strip_tags($new_instance['link']); + $instance['popup'] = (isset($new_instance['popup'])) ? 'true' : false; + return $instance; + } + + /** @see WP_Widget::form */ + function form($instance) { + if ( $instance ) { + $title = esc_attr($instance['title']); + $category = esc_attr($instance['category']); + $link = esc_attr($instance['link']); + $popup = $instance['popup']; + } else { + $title = ''; + $category = ''; + $link = ''; + $popup = 0; + } + ?> +

    +

    +

    +

    + \ No newline at end of file diff --git a/wp-content/plugins/dedication-from-site/readme.txt b/wp-content/plugins/dedication-from-site/readme.txt new file mode 100644 index 0000000..605780f --- /dev/null +++ b/wp-content/plugins/dedication-from-site/readme.txt @@ -0,0 +1,88 @@ +=== Plugin Name === +Contributors: ryelle +Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=YB5AWJMBLCCVC&lc=US&item_name=redradar%2enet¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted +Tags: quick post, frontend, insert post, post, Post, custom post type +Requires at least: 3.2 +Tested up to: 3.3.1 +Stable tag: 3.0.1 + +Write a post without leaving your site! + +== Description == + +Add an interface on your site to write a post (or page, or anything), without having to go into the admin section. Also allows for 'anonymous' posting (not logged in users, still asks for name/email) with a recaptcha. This makes Post From Site a perfect plugin for your user reviews, a suggestion box, or even a very basic forum site. + +After install, you can display a form on your site via a widget, shortcode, or PHP code in your theme. See [this page for further documentation](http://me.redradar.net/category/plugins/post-from-site/). + +== Upgrade Notice == + +If you're updating from 2.0.3 or below, you'll need to resave your settings before it will work correctly (a lot of things were changed in 3.0). + +== Installation == + +1. Unzip `pfs.zip` +1. Upload all files to the `/wp-content/plugins/post-from-site` directory +1. Activate the plugin through the 'Plugins' menu in WordPress + += Use your choice of include: = +1. Add a widget in the [Widgets section](http://codex.wordpress.org/Appearance_Widgets_Screen) +2. Add a shortcode to a page/post/CPT + * Post From Site's basic shortcode is `[post-from-site]`. It has three options: `popup` defines whether the form will show on the site, or only after clicking a link (defaults to false, not a popup). `link` defines that link's text (defaults to 'quick post'). `cat` restricts the post to a specific category (defaults to none). +3. Add PHP code to your template files. + * `form(); ?>` will output the form. You can pass the same variables as in the shortcode. + +== Changelog == += 3.0.1 = +* Added the post_from_site function back for compatability + += 3.0 = +* Rewrote code (again) into a class. +* Added Custom Post Type functionality, along with support for all taxonomies. +* Added widget functionality +* Added actions and filters to allow extension +* Images are uploaded correctly to gallery, and included image size is customizable + += 2.0.3 = +* Fixed the call to the non-existent 'pfs-widget.php'. + += 2.0.2 = +* Fixed an issue with headers +* Changed the `div` tag back to an `a` tag. + += 2.0.1 = +* Compatibility with 3.0 + += 2.0.0 = +* scrapped a lot of code, most of it never made a release +* moved over to strictly using jQuery +* multiple file upload support +* submits using ajax, then refreshes page, so you can see you addition immediately +* also gets rid of the double-post if you refresh the page +* default style has been changed + += 1.9.0 = +* fixes double posting; +* better image support; +* introduction of '[!--image--]' tag; +* existing category/tag dropdown with multiple selection; +* ability to create new categories/tags; +* other minor adjustments + += 1.7.0 = +* addition of tags +* bugfixes + += 1.6.x = +* Initial releases + +== Frequently Asked Questions == + += The popup won't show up / I'm redirected to a white page on submit = + +Check that you have the javascript and css files in the plugin's folder (`post-from-site`). A problem with the first version of this plugin was that the plugin was looking for the files in the wrong directory. For other people it was also a problem with my code assuming a Linux filestructure, so on Windows servers it broke. 2.0.0+ shouldn't have this problem, as I'm using a different method of calling other files. + +[ask a question](http://wordpress.org/tags/post-from-site?forum_id=10)? + +== Screenshots == + +1. Post From Site in action (default 'twentyeleven' theme): inserted onto a sticky post using the shortcode. diff --git a/wp-content/plugins/dedication-from-site/recaptchalib.php b/wp-content/plugins/dedication-from-site/recaptchalib.php new file mode 100644 index 0000000..32c4f4d --- /dev/null +++ b/wp-content/plugins/dedication-from-site/recaptchalib.php @@ -0,0 +1,277 @@ + $value ) + $req .= $key . '=' . urlencode( stripslashes($value) ) . '&'; + + // Cut the last '&' + $req=substr($req,0,strlen($req)-1); + return $req; +} + + + +/** + * Submits an HTTP POST to a reCAPTCHA server + * @param string $host + * @param string $path + * @param array $data + * @param int port + * @return array response + */ +function _recaptcha_http_post($host, $path, $data, $port = 80) { + + $req = _recaptcha_qsencode ($data); + + $http_request = "POST $path HTTP/1.0\r\n"; + $http_request .= "Host: $host\r\n"; + $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; + $http_request .= "Content-Length: " . strlen($req) . "\r\n"; + $http_request .= "User-Agent: reCAPTCHA/PHP\r\n"; + $http_request .= "\r\n"; + $http_request .= $req; + + $response = ''; + if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { + die ('Could not open socket'); + } + + fwrite($fs, $http_request); + + while ( !feof($fs) ) + $response .= fgets($fs, 1160); // One TCP-IP packet + fclose($fs); + $response = explode("\r\n\r\n", $response, 2); + + return $response; +} + + + +/** + * Gets the challenge HTML (javascript and non-javascript version). + * This is called from the browser, and the resulting reCAPTCHA HTML widget + * is embedded within the HTML form it was called from. + * @param string $pubkey A public key for reCAPTCHA + * @param string $error The error given by reCAPTCHA (optional, default is null) + * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false) + + * @return string - The HTML to be embedded in the user's form. + */ +function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) +{ + if ($pubkey == null || $pubkey == '') { + die ("To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create"); + } + + if ($use_ssl) { + $server = RECAPTCHA_API_SECURE_SERVER; + } else { + $server = RECAPTCHA_API_SERVER; + } + + $errorpart = ""; + if ($error) { + $errorpart = "&error=" . $error; + } + return ' + + '; +} + + + + +/** + * A ReCaptchaResponse is returned from recaptcha_check_answer() + */ +class ReCaptchaResponse { + var $is_valid; + var $error; +} + + +/** + * Calls an HTTP POST function to verify if the user's guess was correct + * @param string $privkey + * @param string $remoteip + * @param string $challenge + * @param string $response + * @param array $extra_params an array of extra variables to post to the server + * @return ReCaptchaResponse + */ +function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array()) +{ + if ($privkey == null || $privkey == '') { + die ("To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create"); + } + + if ($remoteip == null || $remoteip == '') { + die ("For security reasons, you must pass the remote ip to reCAPTCHA"); + } + + + + //discard spam submissions + if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) { + $recaptcha_response = new ReCaptchaResponse(); + $recaptcha_response->is_valid = false; + $recaptcha_response->error = 'incorrect-captcha-sol'; + return $recaptcha_response; + } + + $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", + array ( + 'privatekey' => $privkey, + 'remoteip' => $remoteip, + 'challenge' => $challenge, + 'response' => $response + ) + $extra_params + ); + + $answers = explode ("\n", $response [1]); + $recaptcha_response = new ReCaptchaResponse(); + + if (trim ($answers [0]) == 'true') { + $recaptcha_response->is_valid = true; + } + else { + $recaptcha_response->is_valid = false; + $recaptcha_response->error = $answers [1]; + } + return $recaptcha_response; + +} + +/** + * gets a URL where the user can sign up for reCAPTCHA. If your application + * has a configuration page where you enter a key, you should provide a link + * using this function. + * @param string $domain The domain where the page is hosted + * @param string $appname The name of your application + */ +function recaptcha_get_signup_url ($domain = null, $appname = null) { + return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname)); +} + +function _recaptcha_aes_pad($val) { + $block_size = 16; + $numpad = $block_size - (strlen ($val) % $block_size); + return str_pad($val, strlen ($val) + $numpad, chr($numpad)); +} + +/* Mailhide related code */ + +function _recaptcha_aes_encrypt($val,$ky) { + if (! function_exists ("mcrypt_encrypt")) { + die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed."); + } + $mode=MCRYPT_MODE_CBC; + $enc=MCRYPT_RIJNDAEL_128; + $val=_recaptcha_aes_pad($val); + return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); +} + + +function _recaptcha_mailhide_urlbase64 ($x) { + return strtr(base64_encode ($x), '+/', '-_'); +} + +/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */ +function recaptcha_mailhide_url($pubkey, $privkey, $email) { + if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) { + die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " . + "you can do so at http://www.google.com/recaptcha/mailhide/apikey"); + } + + + $ky = pack('H*', $privkey); + $cryptmail = _recaptcha_aes_encrypt ($email, $ky); + + return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail); +} + +/** + * gets the parts of the email to expose to the user. + * eg, given johndoe@example,com return ["john", "example.com"]. + * the email is then displayed as john...@example.com + */ +function _recaptcha_mailhide_email_parts ($email) { + $arr = preg_split("/@/", $email ); + + if (strlen ($arr[0]) <= 4) { + $arr[0] = substr ($arr[0], 0, 1); + } else if (strlen ($arr[0]) <= 6) { + $arr[0] = substr ($arr[0], 0, 3); + } else { + $arr[0] = substr ($arr[0], 0, 4); + } + return $arr; +} + +/** + * Gets html to display an email address given a public an private key. + * to get a key, go to: + * + * http://www.google.com/recaptcha/mailhide/apikey + */ +function recaptcha_mailhide_html($pubkey, $privkey, $email) { + $emailparts = _recaptcha_mailhide_email_parts ($email); + $url = recaptcha_mailhide_url ($pubkey, $privkey, $email); + + return htmlentities($emailparts[0]) . "...@" . htmlentities ($emailparts [1]); + +} + + +?> diff --git a/wp-content/plugins/dedication-from-site/screenshot-1.png b/wp-content/plugins/dedication-from-site/screenshot-1.png new file mode 100644 index 0000000..d7fb2d9 Binary files /dev/null and b/wp-content/plugins/dedication-from-site/screenshot-1.png differ diff --git a/wp-content/plugins/dedication-from-site/search.php b/wp-content/plugins/dedication-from-site/search.php new file mode 100644 index 0000000..f5ca7d0 --- /dev/null +++ b/wp-content/plugins/dedication-from-site/search.php @@ -0,0 +1,48 @@ +get_results("SELECT ID, display_name, user_email FROM $wpdb->users ORDER BY ID"); +foreach ($wp_user_search as $userid) { + $user_id = (int) $userid->ID; + $display_name = stripslashes($userid->display_name); + $user_email = stripslashes($userid->user_email); + + $data[] = array( + 'label' => $display_name . ' (' . $user_email . ')', + 'value' => $user_id + ); +} +// jQuery wants JSON data +echo json_encode($data); +flush(); + + +//// connect to the database server and select the appropriate database for use +//$dblink = mysql_connect('server', 'username', 'password') or die(mysql_error()); +//mysql_select_db('database_name'); +//// query the database table for zip codes that match 'term' +//$rs = mysql_query('select zip, city, state from zipcode where zip like "' . mysql_real_escape_string($_REQUEST['term']) . '%" order by zip asc limit 0,10', $dblink); +//// loop through each zipcode returned and format the response for jQuery +// +//if ($rs && mysql_num_rows($rs)) { +// while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) { +// $data[] = array( +// 'label' => $row['zip'] . ', ' . $row['city'] . ' ' . $row['state'], +// 'value' => $row['zip'] +// ); +// } +//} +//// jQuery wants JSON data +//echo json_encode($data); +//flush(); diff --git a/wp-content/plugins/invite-anyone/invite-anyone.php b/wp-content/plugins/invite-anyone/invite-anyone.php index 9d2115a..9d51ad1 100644 --- a/wp-content/plugins/invite-anyone/invite-anyone.php +++ b/wp-content/plugins/invite-anyone/invite-anyone.php @@ -19,7 +19,7 @@ register_activation_hook( __FILE__, 'invite_anyone_activation' ); function invite_anyone_init() { require( dirname( __FILE__ ) . '/functions.php' ); - + if ( function_exists( 'bp_is_active' ) ) { if ( bp_is_active( 'groups' ) ) require( dirname( __FILE__ ) . '/group-invites/group-invites.php' ); diff --git a/wp-content/plugins/youtube-to-wp-post/readme.txt b/wp-content/plugins/youtube-to-wp-post/readme.txt deleted file mode 100644 index b8990b6..0000000 --- a/wp-content/plugins/youtube-to-wp-post/readme.txt +++ /dev/null @@ -1,53 +0,0 @@ -=== Youtube to WP Post === -Contributors: Robin -Tags: youtube ,wp-post,youtube-post,youtube-wp-post,youtubetopost -Donate link: -Requires at least: 3.0 -Tested up to: 3.3 -Stable tag: 1.0 -License: GPLv2 or later - -This plugin creates posts based on the data fetched from the youtube from its id. - -== Description == - -This plugin accepts url of youtube and fetches title , description and the thumbnail of the youtube video , then creates a post in wp with the title , description and featured image fetched from youtube sites. - - - -== Installation == - -Follow Following steps - -1.Upload the FOLDER 'wp-youtube' to the /wp-content/plugins/ - -2.Activate the plugin 'WP YouTube' through the 'Plugins' menu in admin - -3.Go to 'YouTube To Post' - -== Changelog == - -1.0 updated files - -== Frequently Asked Questions == - -= How to use this plugin? = - -Go to YouTube To Post menu at admin panel -Enter the youtube url (Seperate url in new line) -Click on submit button -See the post section . - -Enjoy - -= How to get help? = -mail me at: robingupta0512@gmail.com - -== Screenshots == -1. main section of plugin. -2. after entering the details. -3. after submission of form. - -== Upgrade Notice == - -= 1.0 = has updated files diff --git a/wp-content/plugins/youtube-to-wp-post/screenshot-1.jpg b/wp-content/plugins/youtube-to-wp-post/screenshot-1.jpg deleted file mode 100644 index 2e8a054..0000000 Binary files a/wp-content/plugins/youtube-to-wp-post/screenshot-1.jpg and /dev/null differ diff --git a/wp-content/plugins/youtube-to-wp-post/screenshot-2.jpg b/wp-content/plugins/youtube-to-wp-post/screenshot-2.jpg deleted file mode 100644 index 3ac0d48..0000000 Binary files a/wp-content/plugins/youtube-to-wp-post/screenshot-2.jpg and /dev/null differ diff --git a/wp-content/plugins/youtube-to-wp-post/screenshot-3.jpg b/wp-content/plugins/youtube-to-wp-post/screenshot-3.jpg deleted file mode 100644 index 05bcf55..0000000 Binary files a/wp-content/plugins/youtube-to-wp-post/screenshot-3.jpg and /dev/null differ diff --git a/wp-content/plugins/youtube-to-wp-post/youtube-post.php b/wp-content/plugins/youtube-to-wp-post/youtube-post.php deleted file mode 100644 index 1250ec7..0000000 --- a/wp-content/plugins/youtube-to-wp-post/youtube-post.php +++ /dev/null @@ -1,87 +0,0 @@ - \ No newline at end of file diff --git a/wp-content/plugins/youtube-to-wp-post/yp-admin.php b/wp-content/plugins/youtube-to-wp-post/yp-admin.php deleted file mode 100644 index fdc87ea..0000000 --- a/wp-content/plugins/youtube-to-wp-post/yp-admin.php +++ /dev/null @@ -1,193 +0,0 @@ -

    '.__('Please enter video URL\'s.',"mu").'

    '; - else { - $youTubeURLS = array_filter(explode("\n",$_REQUEST['videoURLs'])); - - foreach($youTubeURLS as $yt){ - $vedioID = getVideoID($yt); - if(checkYoutubeId($vedioID) == 1){ - $xml = getVideoDetails($vedioID); - if($xml->title != 'YouTube Videos') { - // load up the array - $videoDetails[$i]['videoURL'] = $yt; - $videoDetails[$i]['title'] = $xml->title; - $videoDetails[$i]['description'] = $xml->content; - $videoDetails[$i++]['thumbnail'] = "http://i.ytimg.com/vi/".$vedioID."/0.jpg"; - } - } - } - } - if(empty($videoDetails) && !empty($_REQUEST['videoURLs'])) - echo '

    '.__('Please enter valid video URL\'s.',"mu").'

    '; -} - - -if(isset($_REQUEST['submitPostData']) && $_REQUEST['submitPostData'] ){ - - $totalCount = count($_REQUEST['muTitle']); - $postCount = 0; - for($i=1;$i<=$totalCount;$i++){ - if(@in_array($i,$_REQUEST['muCheckBox'])){ - $postTitle = trim($_REQUEST['muTitle'][$i]); - $youTubeURL = trim($_REQUEST['muVideoURL'][$i]); - $postDescription = trim($_REQUEST['description'][$i]); - $postContent = $postDescription; - $postTags = $_REQUEST['muTags'][$i]; - $postCategories = @implode(',',$_REQUEST['mucategories'][$i]); - $postThumbnail = $_REQUEST['muThumbnail'][$i]; - - - $post = array( - 'post_title' => wp_strip_all_tags($postTitle), - 'post_content' => $postContent, - 'post_category' => @explode(',',$postCategories), - 'tags_input' => $postTags, - 'post_status' => 'publish', - 'post_author' => 1, - 'post_type' => 'post' - ); - - $post_id = wp_insert_post($post); - $postCount++; - - $imageurl = $postThumbnail; - $imageurl = stripslashes($imageurl); - $uploads = wp_upload_dir(); - - $filename = wp_unique_filename( $uploads['path'], basename($imageurl), $unique_filename_callback = null ); - $wp_filetype = wp_check_filetype($filename, null ); - $fullpathfilename = $uploads['path'] . "/" . $filename; - - try { - if ( !substr_count($wp_filetype['type'], "image") ) { - throw new Exception( basename($imageurl) . ' is not a valid image. ' . $wp_filetype['type'] . '' ); - } - - $image_string = fetch_image($imageurl); - $fileSaved = file_put_contents($uploads['path'] . "/" . $filename, $image_string); - if ( !$fileSaved ) { - throw new Exception("The file cannot be saved."); - } - - $attachment = array( - 'post_mime_type' => $wp_filetype['type'], - 'post_title' => preg_replace('/\.[^.]+$/', '', $filename), - 'post_content' => '', - 'post_status' => 'inherit', - 'guid' => $uploads['url'] . "/" . $filename - ); - $attach_id = wp_insert_attachment( $attachment, $fullpathfilename, $post_id ); - if ( !$attach_id ) { - throw new Exception("Failed to save record into database."); - } - require_once(ABSPATH . "wp-admin" . '/includes/image.php'); - $attach_data = wp_generate_attachment_metadata( $attach_id, $fullpathfilename ); - wp_update_attachment_metadata( $attach_id, $attach_data ); - update_post_meta($post_id,'_thumbnail_id',$attach_id); - - } catch (Exception $e) { - $error = '

    ' . $e->getMessage() . '

    '; - } - - } - } - if($postCount > 0) - echo '

    '.__('Post(s) Added Successfully.',"mu").'

    '; -?> - - -
    -

    - -
    Paste youtube url's here (Each url in different line)
    -
    -
    -
    -
    - - - - -
    -

    " name="submitYouTubeURLS" />

    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    - -
    - - - - - - - - - - - - - - - > - - - - - - - - - - - - -
    -

    " name="submitPostData" />

    -
    - - -
    \ No newline at end of file diff --git a/wp-content/themes/score/dedication/index.php b/wp-content/themes/score/dedication/index.php deleted file mode 100644 index 9332f7a..0000000 --- a/wp-content/themes/score/dedication/index.php +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - -
    -
    - - - - - -

    - - - - - - - - - - - - - - - - - - - -
    - - - -
    - - - - - - - - - -
    -
    - - - - - diff --git a/wp-content/themes/score/dedication/new-dedication.php b/wp-content/themes/score/dedication/new-dedication.php deleted file mode 100644 index 50d05f7..0000000 --- a/wp-content/themes/score/dedication/new-dedication.php +++ /dev/null @@ -1,92 +0,0 @@ - -
    -
    - -
    - -

    -
    -
      -
    • - - - -
    • -
    • - - This dedication is private. -
    • -
    • - - -
    • -
    • - - - -
    • -
    • - - -
    • -
    - -

    - -
    -
      - -
    - - -
    - -
    -

    -
    - - - - -
      - - - - -
    • - - -

      - - - - -
      - - - -
      -
    • - - - -
    - - - - - -
    - - - - - -
    - -
    - - -
    \ No newline at end of file diff --git a/wp-content/themes/score/dedications/index.php b/wp-content/themes/score/dedications/index.php new file mode 100644 index 0000000..537d4ce --- /dev/null +++ b/wp-content/themes/score/dedications/index.php @@ -0,0 +1,62 @@ + + + + + + + +
    +
    + + +
    + +
    + +
    + +
    + +
    + + + + + +

    + + + + + +
    + + + +
    +
    + + + diff --git a/wp-content/themes/score/dedications/single/dedicated-2-me.php b/wp-content/themes/score/dedications/single/dedicated-2-me.php new file mode 100644 index 0000000..9480458 --- /dev/null +++ b/wp-content/themes/score/dedications/single/dedicated-2-me.php @@ -0,0 +1,40 @@ +displayed_user->id ); +?> + + + + + + + +
    > + + +
    thumbnail-no-wrap"> + + + <?php if (get_post_meta(get_post_thumbnail_id(), '_wp_attachment_image_alt', true)) {
+                echo get_post_meta(get_post_thumbnail_id(), '_wp_attachment_image_alt', true);
+            } else {
+                echo get_the_title();
+            } ?> + +
    + + + + +
    +

    + + TO: +
    + + +
    + + + diff --git a/wp-content/themes/score/dedications/single/my-dedications.php b/wp-content/themes/score/dedications/single/my-dedications.php new file mode 100644 index 0000000..4647b52 --- /dev/null +++ b/wp-content/themes/score/dedications/single/my-dedications.php @@ -0,0 +1,40 @@ +displayed_user->id); +?> + + + + + + + +
    > + + +
    thumbnail-no-wrap"> + + + <?php if (get_post_meta(get_post_thumbnail_id(), '_wp_attachment_image_alt', true)) {
+                echo get_post_meta(get_post_thumbnail_id(), '_wp_attachment_image_alt', true);
+            } else {
+                echo get_the_title();
+            } ?> + +
    + + + + +
    +

    + + TO: +
    + + +
    + + + diff --git a/wp-content/themes/score/dedications/single/new-dedication.php b/wp-content/themes/score/dedications/single/new-dedication.php new file mode 100644 index 0000000..d3ed3ee --- /dev/null +++ b/wp-content/themes/score/dedications/single/new-dedication.php @@ -0,0 +1,74 @@ + + + + +

    +
    + +
    +
      +
    1. + + + This dedication is private. +
    2. +
    3. + + +
        +
      • + + +
      • +
      + +
    4. +
    5. + + +
    6. +
    7. + + +
    8. +
    9. + + +
    10. + + + +
      +
        + < ? php bp_new_dedication_invite_member_list() ? > +
      + + < ? php wp_nonce_field('groups_invite_uninvite_user', '_wpnonce_invite_uninvite_user') ? > +
      + */ + ?> +
    +
    +
    +
    +
    +
      +
      + +
      +
      + +
      + + + + +
      + + + + +
      \ No newline at end of file diff --git a/wp-content/themes/score/functions.php b/wp-content/themes/score/functions.php index 1da81d5..67c786d 100644 --- a/wp-content/themes/score/functions.php +++ b/wp-content/themes/score/functions.php @@ -184,9 +184,9 @@ function gp_enqueue_scripts() { if (!is_admin()) { wp_enqueue_script('jquery'); - //wp_enqueue_script('jqueryui'); + wp_enqueue_script('jqueryui'); - wp_enqueue_script('jqueryui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js', array('jquery')); + //wp_enqueue_script('jqueryui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js', array('jquery')); if (is_singular()) wp_enqueue_script('comment-reply'); diff --git a/wp-content/themes/score/header.php b/wp-content/themes/score/header.php index 136aeee..77eeeca 100644 --- a/wp-content/themes/score/header.php +++ b/wp-content/themes/score/header.php @@ -57,9 +57,9 @@ @@ -111,6 +111,5 @@ -
      \ No newline at end of file diff --git a/wp-content/themes/score/loop-dedication-data.php b/wp-content/themes/score/loop-dedication-data.php index f96bf42..0fd466c 100644 --- a/wp-content/themes/score/loop-dedication-data.php +++ b/wp-content/themes/score/loop-dedication-data.php @@ -1,6 +1,6 @@ ID, 'ghostpool_post_type', true); diff --git a/wp-content/themes/score/members/single/home.php b/wp-content/themes/score/members/single/home.php index e71e103..37b67bc 100644 --- a/wp-content/themes/score/members/single/home.php +++ b/wp-content/themes/score/members/single/home.php @@ -15,13 +15,11 @@
      - - - + + +