Changeset 1004461
- Timestamp:
- 10/09/2014 12:41:02 PM (11 years ago)
- Location:
- copify/trunk
- Files:
-
- 6 edited
-
Lib/CopifyWordpress.php (modified) (7 diffs)
-
Test/Lib/CopifyWordpressTest.php (modified) (2 diffs)
-
Views/CopifyViewJob.php (modified) (3 diffs)
-
copify.php (modified) (1 diff)
-
css/Copify.css (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
copify/trunk/Lib/CopifyWordpress.php
r1004398 r1004461 12 12 * Plugin version 13 13 */ 14 protected $version = '1.0. 7';14 protected $version = '1.0.8'; 15 15 16 16 /** … … 252 252 try { 253 253 if (empty($_POST)) { 254 throw new Exceptio on('POST request required');254 throw new Exception('POST request required'); 255 255 } 256 256 // Initialise Copify API class … … 406 406 try { 407 407 if (empty($_POST)) { 408 throw new Exceptio on('POST request required');408 throw new Exception('POST request required'); 409 409 } 410 410 // Initialise Copify API class … … 412 412 // Get the job id from the post data 413 413 $job_id = $_POST['job_id']; 414 $post_type = $_POST['post_type']; 415 if (!in_array($post_type, array('post', 'page'))) { 416 throw new Exception('Post type must be either post or page'); 417 } 414 418 // Get the job record from API 415 419 $job = $this->Api->jobsView($job_id); … … 420 424 'post_content' => $job['copy'], 421 425 'post_status' => 'draft', 422 //'post_type' => [ 'post' | 'page' | 'link' | 'nav_menu_item' | 'custom_post_type' ]426 'post_type' => $post_type, 423 427 ); 424 428 $this->CopifyAddToPosts($job_id, $newPost); … … 426 430 // Build the success response 427 431 $response['status'] = 'success'; 428 $response['response'] = $result;429 $response['message'] = ' Job Moved to drafts';432 $response['response'] = true; 433 $response['message'] = 'Order moved to drafts'; 430 434 return $this->outputJson($response); 431 435 } … … 451 455 try { 452 456 if (empty($_POST)) { 453 throw new Exceptio on('POST request required');457 throw new Exception('POST request required'); 454 458 } 455 459 // Get the thingy -
copify/trunk/Test/Lib/CopifyWordpressTest.php
r1004398 r1004461 236 236 $this->CopifyWordpress = $this->getMock('CopifyWordpress', array('wordpress', 'outputJson', 'setheader')); 237 237 $version = $this->CopifyWordpress->getVersion(); 238 $this->assertEquals('1.0. 7', $version);238 $this->assertEquals('1.0.8', $version); 239 239 $mockVal = array( 240 240 'CopifyEmail' => 'foo@bar.com', … … 1466 1466 $this->assertEquals($expected, $result); 1467 1467 } 1468 1469 /** 1470 * Tests that CopifyMoveToDrafts does the correct stuff when the job isn't already in the database 1471 * 1472 * @author Chris Green 1473 **/ 1474 public function testCopifyMoveToDraftNotExist() { 1475 // Mock a load of stuff 1476 $_POST['job_id'] = '186'; 1477 $_POST['post_type'] = 'post'; 1478 $this->CopifyWordpress = $this->getMock('CopifyWordpress', array('wordpress', 'outputJson', 'CopifySetApiClass', 'CopifyJobIdExists', 'CopifyAddToPosts')); 1479 $this->CopifyWordpress->Api = $this->getMock('Api', array('jobsView'), array('foo@bar.com', '324532452345324')); 1480 // Job we want to post 1481 $job = array( 1482 'id' => 186, 1483 'name' => 'order name', 1484 'copy' => 'some copy' 1485 ); 1486 // The post 1487 $new_post = array( 1488 'post_title' => 'order name', 1489 'post_content' => 'some copy', 1490 'post_status' => 'draft', 1491 'post_type' => 'post' 1492 ); 1493 // Correct response 1494 $response = array( 1495 'status' => 'success', 1496 'message' => 'Order moved to drafts', 1497 'response' => true, 1498 ); 1499 1500 $this->CopifyWordpress->expects($this->once()) 1501 ->method('CopifySetApiClass'); 1502 1503 $this->CopifyWordpress->Api->expects($this->once()) 1504 ->method('jobsView') 1505 ->with($this->equalTo('186')) 1506 ->will($this->returnValue($job)); 1507 1508 $this->CopifyWordpress->expects($this->once()) 1509 ->method('CopifyJobIdExists') 1510 ->with($this->equalTo('186')) 1511 ->will($this->returnValue(false)); // Job doesn't exist in db 1512 1513 $this->CopifyWordpress->expects($this->once()) 1514 ->method('CopifyAddToPosts') 1515 ->with($this->equalTo(186), $this->equalTo($new_post)); 1516 1517 $this->CopifyWordpress->expects($this->once()) 1518 ->method('outputJson') 1519 ->with($this->equalTo($response)); 1520 1521 $this->CopifyWordpress->CopifyMoveToDrafts(); 1522 } 1523 1524 /** 1525 * Tests that CopifyMoveToDrafts returns correct JSON when there is no POST data 1526 * 1527 * @author Chris Green 1528 **/ 1529 public function testCopifyMoveToDraftNoPost() { 1530 // Mock a load of stuff 1531 $_POST = array(); 1532 $this->CopifyWordpress = $this->getMock('CopifyWordpress', array('wordpress', 'outputJson', 'CopifySetApiClass', 'CopifyJobIdExists', 'CopifyAddToPosts')); 1533 $this->CopifyWordpress->Api = $this->getMock('Api', array('jobsView'), array('foo@bar.com', '324532452345324')); 1534 // Correct response 1535 $response = array( 1536 'status' => 'error', 1537 'message' => 'POST request required', 1538 'response' => '', 1539 ); 1540 1541 $this->CopifyWordpress->expects($this->once()) 1542 ->method('outputJson') 1543 ->with($this->equalTo($response)); 1544 1545 $this->CopifyWordpress->CopifyMoveToDrafts(); 1546 } 1547 1548 /** 1549 * Tests that CopifyMoveToDrafts returns correct JSON when the post type is incorrect 1550 * 1551 * @author Chris Green 1552 **/ 1553 public function testCopifyMoveToDraftWrongPostType() { 1554 // Mock a load of stuff 1555 $_POST['job_id'] = 186; 1556 $_POST['post_type'] = 'hello'; 1557 $this->CopifyWordpress = $this->getMock('CopifyWordpress', array('wordpress', 'outputJson', 'CopifySetApiClass', 'CopifyJobIdExists', 'CopifyAddToPosts')); 1558 $this->CopifyWordpress->Api = $this->getMock('Api', array('jobsView'), array('foo@bar.com', '324532452345324')); 1559 // Correct response 1560 $response = array( 1561 'status' => 'error', 1562 'message' => 'Post type must be either post or page', 1563 'response' => '', 1564 ); 1565 1566 $this->CopifyWordpress->expects($this->once()) 1567 ->method('outputJson') 1568 ->with($this->equalTo($response)); 1569 1570 $this->CopifyWordpress->CopifyMoveToDrafts(); 1571 } 1468 1572 1469 1573 } -
copify/trunk/Views/CopifyViewJob.php
r1004398 r1004461 150 150 <?php if (!empty($job['copy']) && $job['job_status_id'] == 4 && !$CopifyJobIsPostAlready) : ?> 151 151 <span class="CopifyButton CopifyGreen CopifyMoveToDrafts">Move to Wordpress</span> 152 <form style="display:none;"> 153 <input type="hidden" id="CopifyApproveJobIdHidden" value="<?php echo $job['id']; ?>" name="job_id"> 152 <form id="CopifyDraftsForm" style="display:none;"> 153 <input type="hidden" id="CopifyDraftsJobIdHidden" value="<?php echo $job['id']; ?>" name="job_id"> 154 <input type="hidden" id="CopifyDraftsPostTypeHidden" value="post" name="post_type"> 154 155 </form> 155 <span class="CopifyConfirmSaving" id="CopifyConfirmSaving" style="display:none;"> </span> 156 <!--<span class="CopifyConfirmSaving" id="CopifyConfirmSaving" style="display:none;"> </span>--> 157 158 <!-- Modal --> 159 <div id="CopifyDraftsModal" class="modal" style="display:none;"> 160 <div class="modal-header"> 161 <button data-dismiss="modal" class="close" type="button">×</button> 162 <h3>Move to...</h3> 163 </div> 164 <div class="modal-body"> 165 <select id="CopifyDraftsPostTypeSelect" class="CopifyDraftsPostTypeSelect"> 166 <option value="post">Posts</option> 167 <option value="page">Pages</option> 168 </select> 169 </div> 170 <div class="modal-footer"> 171 <span data-dismiss="modal" class="CopifyButton" >Cancel</span> 172 <span class="CopifyButton CopifyGreen" id="CopifyConfirmToDrafts">Move to Drafts</span> 173 <span class="CopifyConfirmSaving" id="CopifyConfirmSaving" style="display:none;"> </span> 174 </div> 175 </div> 156 176 <?php endif; ?> 157 177 … … 431 451 }); 432 452 453 // Show move to drafts modal 454 jQuery('.CopifyMoveToDrafts').click(function() { 455 jQuery('#CopifyDraftsModal').modal({ 456 show: true 457 }); 458 }); 459 460 // Set the post type and css 461 jQuery('#CopifyDraftsPostTypeSelect').change(function() { 462 var post_type = jQuery(this).val(); 463 jQuery('#CopifyDraftsPostTypeHidden').attr('value', post_type); 464 }); 465 433 466 // Move an already approved job to drafts 434 jQuery(' .CopifyMoveToDrafts').click(function() {467 jQuery('#CopifyConfirmToDrafts').click(function() { 435 468 436 469 jQuery(this).hide(); 437 470 jQuery('#CopifyConfirmSaving').show(); 438 439 var job_id = jQuery('#CopifyApproveJobIdHidden').val(); 471 472 var job_id = jQuery('#CopifyDraftsJobIdHidden').val(); 473 var post_type = jQuery('#CopifyDraftsPostTypeHidden').val(); 440 474 441 475 var job = { 442 476 job_id: job_id, 477 post_type: post_type, 443 478 action: 'CopifyMoveToDrafts' 444 479 }; … … 451 486 if(data.status == 'success') { 452 487 // OK 488 jQuery('#CopifyConfirmToDrafts').hide(); 489 jQuery('#CopifyConfirmSaving').hide(); 453 490 window.location.href = window.location.href + '&flashMessage=Order+moved+to+Drafts'; 454 491 } else { -
copify/trunk/copify.php
r1004398 r1004461 4 4 Plugin URI: https://github.com/copify/copify-wordpress 5 5 Description: Automatically publish unique, relevant content every week from Copify's team of professional writers. 6 Version: 1.0. 76 Version: 1.0.8 7 7 Author: Rob McVey 8 8 Author URI: http://uk.copify.com/ -
copify/trunk/css/Copify.css
r1004398 r1004461 344 344 } 345 345 346 /* Move to drafts modal and buttons inside */ 347 .CopifyPage #CopifyDraftsModal .modal-body { 348 padding-top: 15px; 349 text-align: center; 350 } 351 352 .CopifyPage .CopifyDraftsPostTypeSelect { 353 width:100%; 354 } 355 346 356 .CopifyPage ::-webkit-input-placeholder { 347 color: #999;357 color: #999; 348 358 font-style:italic; 349 359 } 350 360 .CopifyPage :-moz-placeholder { 351 color: #999;361 color: #999; 352 362 font-style:italic; 353 363 } -
copify/trunk/readme.txt
r1004398 r1004461 1 1 === Copify === 2 Version: 1.0. 72 Version: 1.0.8 3 3 Contributors: robmcvey 4 4 Tags: blog writers, automatic blogging, post writers, auto blogging, content, copywriting, copywriters, blogging, writers, writing, seo … … 39 39 == Changelog == 40 40 41 = 1.0.8 = 42 * When moving an already approved order to drafts, offer selection of "Post" or "Page" 43 44 = 1.0.7 = 45 * Allows user to choose to publish blog with the supplied royalty free image (Blog package customers only) 46 41 47 = 1.0.6 = 42 48 * Fixes issue with other plugins calling methods in wp-admin/includes/plugin.php such as is_plugin_active()
Note: See TracChangeset
for help on using the changeset viewer.