Changeset 1719790
- Timestamp:
- 08/26/2017 12:40:00 PM (8 years ago)
- Location:
- writing-on-github/trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
writing-on-github/trunk/lib/admin.php
r1713007 r1719790 257 257 Writing_On_GitHub::$instance->start_export(); 258 258 } 259 260 259 if ( 'force_export' === $_GET['action'] ) { 261 260 Writing_On_GitHub::$instance->start_export(true); 262 261 } 263 264 262 if ( 'import' === $_GET['action'] ) { 265 263 Writing_On_GitHub::$instance->start_import(); 266 264 } 265 if ( 'force_import' === $_GET['action'] ) { 266 Writing_On_GitHub::$instance->start_import(true); 267 } 267 268 268 269 wp_redirect( admin_url( 'options-general.php?page=writing-on-github' ) ); -
writing-on-github/trunk/lib/controller.php
r1713007 r1719790 91 91 /** 92 92 * Imports posts from the current master branch. 93 * 94 * @return boolean 95 */ 96 public function import_master( $user_id = 0 ) { 93 * @param integer $user_id 94 * @param boolean $force 95 * @return boolean 96 */ 97 public function import_master( $user_id = 0, $force = false ) { 97 98 if ( ! $this->app->semaphore()->is_open() ) { 98 99 return $this->app->response()->error( new WP_Error( … … 110 111 } 111 112 112 $result = $this->app->import()->master( );113 $result = $this->app->import()->master( $force ); 113 114 114 115 $this->app->semaphore()->unlock(); -
writing-on-github/trunk/lib/import.php
r1713007 r1719790 56 56 * import blob by files 57 57 * @param Writing_On_GitHub_File_Info[] $files 58 * @param boolean $force 58 59 * 59 60 * @return true|WP_Error 60 61 */ 61 protected function import_files( $files ) {62 protected function import_files( $files, $force = false ) { 62 63 63 64 $error = true; … … 83 84 $result = $this->delete_post( $blob ); 84 85 } else { 85 $result = $this->import_post( $blob );86 $result = $this->import_post( $blob, $force ); 86 87 } 87 88 } … … 99 100 * Imports the latest commit on the master branch. 100 101 * 102 * @param boolean $force 101 103 * @return string|WP_Error 102 104 */ 103 public function master( ) {105 public function master( $force = false ) { 104 106 $result = $this->app->api()->fetch()->tree_recursive(); 105 107 … … 110 112 111 113 if ( is_array( $result ) ) { 112 $result = $this->import_files( $result );114 $result = $this->import_files( $result, $force ); 113 115 } 114 116 … … 190 192 * Imports a post into wordpress 191 193 * @param Writing_On_GitHub_Blob $blob 194 * @param boolean $force 192 195 * @return WP_Error|bool 193 196 */ 194 protected function import_post( Writing_On_GitHub_Blob $blob ) {195 $post = $this->blob_to_post( $blob );197 protected function import_post( Writing_On_GitHub_Blob $blob, $force = false ) { 198 $post = $this->blob_to_post( $blob, $force ); 196 199 197 200 if ( ! $post instanceof Writing_On_GitHub_Post ) { … … 266 269 * 267 270 * @param Writing_On_GitHub_Blob $blob Blob to transform into a Post. 271 * @param boolean $force 268 272 * 269 273 * @return Writing_On_GitHub_Post|false 270 274 */ 271 protected function blob_to_post( Writing_On_GitHub_Blob $blob ) {275 protected function blob_to_post( Writing_On_GitHub_Blob $blob, $force = false ) { 272 276 $args = array( 'post_content' => $blob->content_import() ); 273 277 $meta = $blob->meta(); … … 305 309 $meta['_wogh_sha'] = $blob->sha(); 306 310 307 if ( $id ) {311 if ( ! $force && $id ) { 308 312 $old_sha = get_post_meta( $id, '_wogh_sha', true ); 309 313 $old_github_path = get_post_meta( $id, '_wogh_github_path', true ); -
writing-on-github/trunk/readme.txt
r1713654 r1719790 7 7 Requires at least: 3.9 8 8 Tested up to: 4.8.1 9 Stable tag: 1. 6.19 Stable tag: 1.7 10 10 License: GPLv2 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 135 135 == Changelog == 136 136 137 = 1.7 = 138 139 * Add an option to force import from github 140 137 141 = 1.6.1 = 138 142 … … 193 197 [1.6]: https://github.com/litefeel/writing-on-github/releases/tag/1.6 194 198 [1.6.1]: https://github.com/litefeel/writing-on-github/releases/tag/1.6.1 199 [1.7]: https://github.com/litefeel/writing-on-github/releases/tag/1.7 -
writing-on-github/trunk/vendor/autoload.php
r1713654 r1719790 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit f09e17fb75429ec5fb15edb97611faf1::getLoader();7 return ComposerAutoloaderInitdceed942811feb8a045169f778363db6::getLoader(); -
writing-on-github/trunk/vendor/composer/autoload_real.php
r1713654 r1719790 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit f09e17fb75429ec5fb15edb97611faf15 class ComposerAutoloaderInitdceed942811feb8a045169f778363db6 6 6 { 7 7 private static $loader; … … 20 20 } 21 21 22 spl_autoload_register(array('ComposerAutoloaderInit f09e17fb75429ec5fb15edb97611faf1', 'loadClassLoader'), true, true);22 spl_autoload_register(array('ComposerAutoloaderInitdceed942811feb8a045169f778363db6', 'loadClassLoader'), true, true); 23 23 self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 24 spl_autoload_unregister(array('ComposerAutoloaderInit f09e17fb75429ec5fb15edb97611faf1', 'loadClassLoader'));24 spl_autoload_unregister(array('ComposerAutoloaderInitdceed942811feb8a045169f778363db6', 'loadClassLoader')); 25 25 26 26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 28 28 require_once __DIR__ . '/autoload_static.php'; 29 29 30 call_user_func(\Composer\Autoload\ComposerStaticInit f09e17fb75429ec5fb15edb97611faf1::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInitdceed942811feb8a045169f778363db6::getInitializer($loader)); 31 31 } else { 32 32 $map = require __DIR__ . '/autoload_namespaces.php'; … … 49 49 50 50 if ($useStaticLoader) { 51 $includeFiles = Composer\Autoload\ComposerStaticInit f09e17fb75429ec5fb15edb97611faf1::$files;51 $includeFiles = Composer\Autoload\ComposerStaticInitdceed942811feb8a045169f778363db6::$files; 52 52 } else { 53 53 $includeFiles = require __DIR__ . '/autoload_files.php'; 54 54 } 55 55 foreach ($includeFiles as $fileIdentifier => $file) { 56 composerRequire f09e17fb75429ec5fb15edb97611faf1($fileIdentifier, $file);56 composerRequiredceed942811feb8a045169f778363db6($fileIdentifier, $file); 57 57 } 58 58 … … 61 61 } 62 62 63 function composerRequire f09e17fb75429ec5fb15edb97611faf1($fileIdentifier, $file)63 function composerRequiredceed942811feb8a045169f778363db6($fileIdentifier, $file) 64 64 { 65 65 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
writing-on-github/trunk/vendor/composer/autoload_static.php
r1713654 r1719790 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit f09e17fb75429ec5fb15edb97611faf17 class ComposerStaticInitdceed942811feb8a045169f778363db6 8 8 { 9 9 public static $files = array ( … … 35 35 { 36 36 return \Closure::bind(function () use ($loader) { 37 $loader->classMap = ComposerStaticInit f09e17fb75429ec5fb15edb97611faf1::$classMap;37 $loader->classMap = ComposerStaticInitdceed942811feb8a045169f778363db6::$classMap; 38 38 39 39 }, null, ClassLoader::class); -
writing-on-github/trunk/views/options.php
r1709881 r1719790 18 18 </tr> 19 19 <tr> 20 <th scope="row"><?php esc_html_e( 'Bulk actions', 'writing-on-github' ); ?></th> 21 <td> 22 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'export' ) ) ); ?>"> 23 <?php esc_html_e( 'Export to GitHub', 'writing-on-github' ); ?> 24 </a> | 25 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'force_export' ) ) ); ?>"> 26 <?php esc_html_e( 'Force export to GitHub', 'writing-on-github' ); ?> 27 </a> | 28 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'import' ) ) ); ?>"> 29 <?php esc_html_e( 'Import from GitHub', 'writing-on-github' ); ?> 30 </a> 31 </td> 20 <th scope="row"><?php esc_html_e( 'Export', 'writing-on-github' ); ?></th> 21 <td> 22 <p><a href="<?php echo esc_url( add_query_arg( array( 'action' => 'export' ) ) ); ?>"> 23 <input type="button" class="button button-secondary" value="<?php esc_html_e( 'Export to GitHub', 'writing-on-github' ); ?>" /> 24 </a></p> 25 <p><a href="<?php echo esc_url( add_query_arg( array( 'action' => 'force_export' ) ) ); ?>"> 26 <input type="button" class="button button-secondary" value="<?php esc_html_e( 'Force export to GitHub', 'writing-on-github' ); ?>" /> 27 </a></p> 28 </td> 29 </tr> 30 <tr> 31 <th scope="row"><?php esc_html_e( 'Import', 'writing-on-github' ); ?></th> 32 <td> 33 <p><a href="<?php echo esc_url( add_query_arg( array( 'action' => 'import' ) ) ); ?>"> 34 <input type="button" class="button button-secondary" value="<?php esc_html_e( 'Import from GitHub', 'writing-on-github' ); ?>" /> 35 </a></p> 36 <p><a href="<?php echo esc_url( add_query_arg( array( 'action' => 'force_import' ) ) ); ?>"> 37 <input type="button" class="button button-secondary" value="<?php esc_html_e( 'Force Import from GitHub', 'writing-on-github' ); ?>" /> 38 </a></p> 39 </td> 40 </tr> 32 41 </table> 33 42 <?php submit_button(); ?> -
writing-on-github/trunk/writing-on-github.php
r1713654 r1719790 4 4 * Plugin URI: https://github.com/litefeel/writing-on-github 5 5 * Description: A WordPress plugin to allow you writing on GitHub (or Jekyll site). 6 * Version: 1. 6.16 * Version: 1.7 7 7 * Author: litefeel 8 8 * Author URI: https://www.litefeel.com … … 133 133 add_action( 'wp_ajax_nopriv_wogh_push_request', array( $this->controller, 'pull_posts' ) ); 134 134 add_action( 'wogh_export', array( $this->controller, 'export_all' ), 10, 2 ); 135 add_action( 'wogh_import', array( $this->controller, 'import_master' ), 10, 1);135 add_action( 'wogh_import', array( $this->controller, 'import_master' ), 10, 2 ); 136 136 add_filter( 'get_edit_post_link', array( $this, 'edit_post_link' ), 10, 3 ); 137 137 … … 218 218 * Sets and kicks off the import cronjob 219 219 */ 220 public function start_import( ) {221 $this->start_cron( 'import' );220 public function start_import( $force = false ) { 221 $this->start_cron( 'import', $force ); 222 222 } 223 223
Note: See TracChangeset
for help on using the changeset viewer.