Changeset 475745
- Timestamp:
- 12/15/2011 07:26:04 AM (14 years ago)
- Location:
- qa/trunk
- Files:
-
- 1 added
- 8 edited
-
. (modified) (1 prop)
-
core/admin.php (modified) (4 diffs)
-
core/core.php (modified) (2 diffs)
-
core/template-tags.php (modified) (4 diffs)
-
default-templates/css/general.css (modified) (2 diffs)
-
default-templates/js/init.js (modified) (1 diff)
-
qa-lite.php (modified) (1 diff)
-
qa.php (added)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
qa/trunk
-
Property
svn:ignore
set to
.komodotools
*.komodoproject
-
Property
svn:ignore
set to
-
qa/trunk/core/admin.php
r380225 r475745 51 51 add_action( 'wp_ajax_qa-get-caps', array( &$this, 'ajax_get_caps' ) ); 52 52 add_action( 'wp_ajax_qa-save', array( &$this, 'ajax_save' ) ); 53 54 add_filter( 'user_has_cap', array(&$this, 'user_has_cap'), 10, 3); 53 55 } 54 56 … … 179 181 // add/remove capabilities 180 182 global $wp_roles; 183 184 $qa_capabilities_set = get_option('qa_capabilties_set', array()); 181 185 182 186 $role = $_POST['roles']; 183 187 184 188 $all_caps = array_keys( $this->capability_map ); 185 $to_add = array_keys( $_POST['capabilities'] ); 189 if (isset($_POST['capabilities'])) { 190 $to_add = array_keys( $_POST['capabilities'] ); 191 } else { 192 $to_add = array(); 193 } 186 194 $to_remove = array_diff( $all_caps, $to_add ); 187 195 … … 199 207 ) 200 208 ); 201 209 210 $qa_capabilities_set[$role] = true; 211 212 update_option( 'qa_capabilties_set', array_unique( $qa_capabilities_set )); 213 202 214 update_option( QA_OPTIONS_NAME, $options ); 203 215 … … 220 232 echo "<p>Rendering of admin template " . QA_PLUGIN_DIR . "ui-admin/{$name}.php failed</p>"; 221 233 } 234 235 function user_has_cap($allcaps, $caps = null, $args = null) { 236 global $current_user, $blog_id, $post; 237 238 $qa_capabilities_set = get_option('qa_capabilties_set', array()); 239 240 $capable = false; 241 242 $qa_cap_set = false; 243 foreach ($current_user->roles as $role) { 244 if (isset($qa_capabilities_set[$role])) { 245 $qa_cap_set = true; 246 } 247 } 248 249 if (!$qa_cap_set && preg_match('/(_question|_questions|_answer|_answers)/i', join($caps, ',')) > 0) { 250 if (in_array('administrator', $current_user->roles)) { 251 foreach ($caps as $cap) { 252 $allcaps[$cap] = 1; 253 } 254 return $allcaps; 255 } 256 257 foreach ($caps as $cap) { 258 $capable = false; 259 260 switch ($cap) { 261 case 'read_questions' or 'read_answers': 262 $capable = true; 263 break; 264 default: 265 if (isset($args[1]) && isset($args[2])) { 266 if (current_user_can(preg_replace('/_question|_answer/i', '_post', $cap), $args[1], $args[2])) { 267 $capable = true; 268 } 269 } else if (isset($args[1])) { 270 if (current_user_can(preg_replace('/_question|_answer/i', '_post', $cap), $args[1])) { 271 $capable = true; 272 } 273 } else if (current_user_can(preg_replace('/_question|_answer/i', '_post', $cap))) { 274 $capable = true; 275 } 276 break; 277 } 278 279 if ($capable) { 280 $allcaps[$cap] = 1; 281 } 282 } 283 } 284 return $allcaps; 285 } 222 286 } 223 287 -
qa/trunk/core/core.php
r384127 r475745 295 295 */ 296 296 function load_default_style() { 297 global $wp_version; 298 297 299 if ( !is_qa_page() ) 298 300 return; … … 304 306 if ( !current_theme_supports( 'qa_script' ) ) { 305 307 if ( is_qa_page( 'ask' ) || is_qa_page( 'edit' ) || is_qa_page( 'single' ) ) { 306 wp_enqueue_style( 'cleditor', QA_PLUGIN_URL . 'default-templates/js/cleditor/jquery.cleditor.css', array(), '1.3.0-l10n' ); 307 308 wp_enqueue_script( 'cleditor', QA_PLUGIN_URL . 'default-templates/js/cleditor/jquery.cleditor.js', array( 'jquery' ), '1.3.0-l10n' ); 308 if (version_compare($wp_version, "3.3", "<")) { 309 wp_enqueue_style( 'cleditor', QA_PLUGIN_URL . 'default-templates/js/cleditor/jquery.cleditor.css', array(), '1.3.0-l10n' ); 310 wp_enqueue_script( 'cleditor', QA_PLUGIN_URL . 'default-templates/js/cleditor/jquery.cleditor.js', array( 'jquery' ), '1.3.0-l10n' ); 311 } 309 312 310 313 wp_enqueue_script( 'suggest' ); -
qa/trunk/core/template-tags.php
r384127 r475745 321 321 322 322 function the_question_form() { 323 global $wp_query ;323 global $wp_query, $wp_version; 324 324 325 325 if ( is_qa_page( 'edit' ) ) { … … 362 362 </table> 363 363 364 <textarea name="question_content"><?php echo esc_textarea( $question->post_content ); ?></textarea> 364 <?php if (version_compare($wp_version, "3.3") >= 0) { ?> 365 <?php wp_editor( $question->post_content, 'question_content', array('media_buttons' => false)); ?> 366 <?php } else { ?> 367 <textarea name="question_content" class="wp32"><?php echo esc_textarea( $question->post_content ); ?></textarea> 368 <?php } ?> 365 369 366 370 <table id="question-taxonomies"> … … 437 441 438 442 function the_answer_form() { 439 global $wp_query ;443 global $wp_query, $wp_version; 440 444 441 445 if ( is_qa_page( 'edit' ) ) { … … 463 467 <input type="hidden" name="answer_id" value="<?php echo esc_attr( $answer->ID ); ?>" /> 464 468 465 <p><textarea name="answer"><?php echo esc_textarea( $answer->post_content ); ?></textarea></p> 469 <?php if (version_compare($wp_version, "3.3") >= 0) { ?> 470 <p><?php wp_editor( $answer->post_content, 'answer', array('media_buttons' => false)); ?></p> 471 <?php } else { ?> 472 <p><textarea name="answer" class="wp32"><?php echo esc_textarea( $answer->post_content ); ?></textarea></p> 473 <?php } ?> 466 474 467 475 <?php the_qa_submit_button(); ?> -
qa/trunk/default-templates/css/general.css
r380225 r475745 158 158 .question-status { 159 159 float: left; 160 height: 38px;160 height: 70px; 161 161 margin-right: 5px; 162 162 padding: 5px; … … 460 460 } 461 461 462 #question-form textarea ,463 #answer-form textarea {462 #question-form textarea.wp32, 463 #answer-form textarea.wp32 { 464 464 width: 600px; 465 465 height: 200px; 466 466 } 467 467 468 #question-form textarea ,469 #answer-form textarea ,468 #question-form textarea.wp32, 469 #answer-form textarea.wp32, 470 470 .cleditorMain { 471 471 margin: 20px 0; -
qa/trunk/default-templates/js/init.js
r384127 r475745 5 5 } 6 6 7 // Add CLEditor 7 // Add CLEditor if needed 8 8 var $editor = $('#question-form, #answer-form').find('textarea'); 9 if ( $editor.length ) {9 if ( $editor.length && $editor.cleditor) { 10 10 $editor.cleditor({ 11 11 width: 616, -
qa/trunk/qa-lite.php
r386642 r475745 1 <?php2 /*3 Plugin Name: Q&A Lite4 Plugin URI: http://premium.wpmudev.org/project/qa-wordpress-questions-and-answers-plugin5 Description: Q&A Lite allows any WordPress site to have a fully featured questions and answers section - just like StackOverflow, Yahoo Answers, Quora and more...6 Author: scribu (Incsub)7 Version: 1.0.18 Author URI: http://premium.wpmudev.org/9 WDP ID: 22410 */11 12 /*13 14 Copyright 2007-2011 Incsub, (http://incsub.com)15 16 This program is free software; you can redistribute it and/or modify17 it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by18 the Free Software Foundation.19 20 This program is distributed in the hope that it will be useful,21 but WITHOUT ANY WARRANTY; without even the implied warranty of22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the23 GNU General Public License for more details.24 25 You should have received a copy of the GNU General Public License26 along with this program; if not, write to the Free Software27 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA28 29 */30 31 // The plugin version32 define( 'QA_VERSION', '1.0.1' );33 34 // The full url to the plugin directory35 define( 'QA_PLUGIN_URL', WP_PLUGIN_URL . '/' . basename( dirname( __FILE__ ) ) . '/' );36 37 // The full path to the plugin directory38 define( 'QA_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . basename( dirname( __FILE__ ) ) . '/' );39 40 // The text domain for strings localization41 define( 'QA_TEXTDOMAIN', 'questions-and-answers' );42 43 // The key for the options array44 define( 'QA_OPTIONS_NAME', 'qa_options' );45 46 // The minimum number of seconds between two user posts47 define( 'QA_FLOOD_SECONDS', 10 );48 49 // Reputation multipliers50 define( 'QA_ANSWER_ACCEPTED', 15 );51 define( 'QA_ANSWER_ACCEPTING', 2 );52 define( 'QA_ANSWER_UP_VOTE', 10 );53 define( 'QA_QUESTION_UP_VOTE', 5 );54 define( 'QA_DOWN_VOTE', -2 );55 define( 'QA_DOWN_VOTE_PENALTY', -1 );56 57 // Pagination58 define( 'QA_ANSWERS_PER_PAGE', 20 );59 60 // Load plugin files61 include_once QA_PLUGIN_DIR . 'core/core.php';62 include_once QA_PLUGIN_DIR . 'core/answers.php';63 include_once QA_PLUGIN_DIR . 'core/edit.php';64 include_once QA_PLUGIN_DIR . 'core/votes.php';65 include_once QA_PLUGIN_DIR . 'core/functions.php';66 include_once QA_PLUGIN_DIR . 'core/template-tags.php';67 include_once QA_PLUGIN_DIR . 'core/widgets.php';68 include_once QA_PLUGIN_DIR . 'core/ajax.php';69 70 if ( is_admin() ) {71 include_once QA_PLUGIN_DIR . 'core/admin.php';72 }73 -
qa/trunk/readme.txt
r394178 r475745 3 3 Tags: questions, answers, community, Q&A, stackoverflow, wordpress-plugins 4 4 Requires at least: 3.1 5 Tested up to: 3. 25 Tested up to: 3.3 6 6 Stable tag: trunk 7 7 … … 72 72 == Changelog == 73 73 74 = 1.0.2 = 75 * Switch frontend WYSIWYG editor to TinyMCE and Quicktags 76 * WordPress 3.3 compatibility 77 74 78 = 1.0.1 = 75 79 * show message when non-logged-in user tries to vote
Note: See TracChangeset
for help on using the changeset viewer.