@@ -9,247 +9,247 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class Writing_On_GitHub_Blob { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Complete blob content. |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 17 | - protected $content; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * Blob sha. |
|
| 21 | - * |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - protected $sha; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Blob path. |
|
| 28 | - * |
|
| 29 | - * @var string |
|
| 30 | - */ |
|
| 31 | - protected $path; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Post id. |
|
| 35 | - * |
|
| 36 | - * @var int |
|
| 37 | - */ |
|
| 38 | - protected $id; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Whether the blob has frontmatter. |
|
| 42 | - * |
|
| 43 | - * @var boolean |
|
| 44 | - */ |
|
| 45 | - protected $frontmatter = false; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * The front matter of github post |
|
| 49 | - * @var string |
|
| 50 | - */ |
|
| 51 | - protected $front_matter = ''; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Content without front matter |
|
| 55 | - * @var string |
|
| 56 | - */ |
|
| 57 | - protected $post_content; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Instantiates a new Blob object. |
|
| 61 | - * |
|
| 62 | - * @param stdClass $data Raw blob data. |
|
| 63 | - */ |
|
| 64 | - public function __construct( stdClass $data ) { |
|
| 65 | - $this->interpret_data( $data ); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - public function id() { |
|
| 69 | - return $this->id; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - public function set_id($id) { |
|
| 73 | - $this->id = $id; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Returns the raw blob content. |
|
| 78 | - * |
|
| 79 | - * @return string |
|
| 80 | - */ |
|
| 81 | - public function content() { |
|
| 82 | - return $this->content; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Set's the blob's content. |
|
| 87 | - * |
|
| 88 | - * @param string $content Raw blob content. |
|
| 89 | - * @param bool $base64 Whether the content is base64 encoded. |
|
| 90 | - * |
|
| 91 | - * @return $this |
|
| 92 | - */ |
|
| 93 | - public function set_content( $content, $base64 = false ) { |
|
| 94 | - if ( $base64 ) { |
|
| 95 | - $content = base64_decode( $content ); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - // remove whitespace from the beginning of content, |
|
| 99 | - // To prevent blank lines before yml |
|
| 100 | - $this->content = ltrim( $content ); |
|
| 101 | - |
|
| 102 | - $this->frontmatter = '---' === substr( $this->content, 0, 3 ); |
|
| 103 | - |
|
| 104 | - return $this; |
|
| 105 | - } |
|
| 106 | - /** |
|
| 107 | - * Returns the blob sha. |
|
| 108 | - * |
|
| 109 | - * @return string |
|
| 110 | - */ |
|
| 111 | - public function sha() { |
|
| 112 | - return $this->sha; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Return's the blob path. |
|
| 117 | - * |
|
| 118 | - * @return string |
|
| 119 | - */ |
|
| 120 | - public function path() { |
|
| 121 | - return $this->path; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Whether the blob has frontmatter. |
|
| 126 | - * |
|
| 127 | - * @return bool |
|
| 128 | - */ |
|
| 129 | - public function has_frontmatter() { |
|
| 130 | - return $this->frontmatter; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * The front matter of github post |
|
| 135 | - * @return string |
|
| 136 | - */ |
|
| 137 | - public function front_matter() { |
|
| 138 | - return $this->front_matter; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Content without front matter |
|
| 143 | - * @return string |
|
| 144 | - */ |
|
| 145 | - public function post_content() { |
|
| 146 | - if ( ! $this->post_content ) { |
|
| 147 | - $this->content_import(); |
|
| 148 | - } |
|
| 149 | - return $this->post_content; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Returns the formatted/filtered blob content used for import. |
|
| 154 | - * |
|
| 155 | - * @return string |
|
| 156 | - */ |
|
| 157 | - public function content_import() { |
|
| 158 | - $this->post_content = $content = $this->content(); |
|
| 159 | - |
|
| 160 | - if ( $this->has_frontmatter() ) { |
|
| 161 | - // Break out content. |
|
| 162 | - preg_match( '/(^---(.*?)---$(\r\n|\n|\r)?)?(.*)/ms', $content, $matches ); |
|
| 163 | - $this->front_matter = $matches[1]; |
|
| 164 | - $this->post_content = $content = array_pop( $matches ); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - if ( function_exists( 'wpmarkdown_markdown_to_html' ) ) { |
|
| 168 | - $content = wpmarkdown_markdown_to_html( $content ); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Filters the content for import. |
|
| 173 | - */ |
|
| 174 | - return apply_filters( 'wogh_content_import', trim( $content ) ); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * Returns the blob meta. |
|
| 179 | - * |
|
| 180 | - * @return array |
|
| 181 | - */ |
|
| 182 | - public function meta() { |
|
| 183 | - $meta = array(); |
|
| 184 | - |
|
| 185 | - if ( $this->has_frontmatter() ) { |
|
| 186 | - // Break out meta, if present. |
|
| 187 | - preg_match( '/(^---(.*?)---$)?(.*)/ms', $this->content(), $matches ); |
|
| 188 | - array_pop( $matches ); |
|
| 189 | - |
|
| 190 | - $meta = spyc_load( $matches[2] ); |
|
| 191 | - if ( 'yes' == get_option('wogh_ignore_author') ) { |
|
| 192 | - unset($meta['author']); |
|
| 193 | - } |
|
| 194 | - // if ( isset( $meta['link'] ) ) { |
|
| 195 | - // $meta['link'] = str_replace( home_url(), '', $meta['link'] ); |
|
| 196 | - // } |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - return $meta; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * Formats the blob into an API call body. |
|
| 204 | - * |
|
| 205 | - * @return stdClass |
|
| 206 | - */ |
|
| 207 | - // public function to_body() { |
|
| 208 | - // $data = new stdClass; |
|
| 209 | - |
|
| 210 | - // $data->mode = '100644'; |
|
| 211 | - // $data->type = 'blob'; |
|
| 212 | - |
|
| 213 | - // $data->path = $this->path(); |
|
| 214 | - |
|
| 215 | - // if ( $this->sha() ) { |
|
| 216 | - // $data->sha = $this->sha(); |
|
| 217 | - // } else { |
|
| 218 | - // $data->content = $this->content(); |
|
| 219 | - // } |
|
| 220 | - |
|
| 221 | - // return $data; |
|
| 222 | - // } |
|
| 223 | - |
|
| 224 | - |
|
| 225 | - /** |
|
| 226 | - * Formats the blob into an API call body. |
|
| 227 | - * |
|
| 228 | - * @return stdClass |
|
| 229 | - */ |
|
| 230 | - public function to_body() { |
|
| 231 | - $data = new stdClass; |
|
| 232 | - |
|
| 233 | - // $data->mode = '100644'; |
|
| 234 | - // $data->type = 'blob'; |
|
| 235 | - |
|
| 236 | - $data->path = $this->path(); |
|
| 237 | - $data->content = base64_encode( $this->content() ); |
|
| 238 | - $data->sha = $this->sha; |
|
| 239 | - |
|
| 240 | - return $data; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Interprets the blob's data into properties. |
|
| 245 | - */ |
|
| 246 | - protected function interpret_data( $data ) { |
|
| 247 | - $this->sha = isset( $data->sha ) ? $data->sha : ''; |
|
| 248 | - $this->path = isset( $data->path ) ? $data->path : ''; |
|
| 249 | - |
|
| 250 | - $this->set_content( |
|
| 251 | - isset( $data->content ) ? $data->content : '', |
|
| 252 | - isset( $data->encoding ) && 'base64' === $data->encoding ? true : false |
|
| 253 | - ); |
|
| 254 | - } |
|
| 12 | + /** |
|
| 13 | + * Complete blob content. |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | + protected $content; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * Blob sha. |
|
| 21 | + * |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + protected $sha; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Blob path. |
|
| 28 | + * |
|
| 29 | + * @var string |
|
| 30 | + */ |
|
| 31 | + protected $path; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Post id. |
|
| 35 | + * |
|
| 36 | + * @var int |
|
| 37 | + */ |
|
| 38 | + protected $id; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Whether the blob has frontmatter. |
|
| 42 | + * |
|
| 43 | + * @var boolean |
|
| 44 | + */ |
|
| 45 | + protected $frontmatter = false; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * The front matter of github post |
|
| 49 | + * @var string |
|
| 50 | + */ |
|
| 51 | + protected $front_matter = ''; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Content without front matter |
|
| 55 | + * @var string |
|
| 56 | + */ |
|
| 57 | + protected $post_content; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Instantiates a new Blob object. |
|
| 61 | + * |
|
| 62 | + * @param stdClass $data Raw blob data. |
|
| 63 | + */ |
|
| 64 | + public function __construct( stdClass $data ) { |
|
| 65 | + $this->interpret_data( $data ); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + public function id() { |
|
| 69 | + return $this->id; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + public function set_id($id) { |
|
| 73 | + $this->id = $id; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Returns the raw blob content. |
|
| 78 | + * |
|
| 79 | + * @return string |
|
| 80 | + */ |
|
| 81 | + public function content() { |
|
| 82 | + return $this->content; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Set's the blob's content. |
|
| 87 | + * |
|
| 88 | + * @param string $content Raw blob content. |
|
| 89 | + * @param bool $base64 Whether the content is base64 encoded. |
|
| 90 | + * |
|
| 91 | + * @return $this |
|
| 92 | + */ |
|
| 93 | + public function set_content( $content, $base64 = false ) { |
|
| 94 | + if ( $base64 ) { |
|
| 95 | + $content = base64_decode( $content ); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + // remove whitespace from the beginning of content, |
|
| 99 | + // To prevent blank lines before yml |
|
| 100 | + $this->content = ltrim( $content ); |
|
| 101 | + |
|
| 102 | + $this->frontmatter = '---' === substr( $this->content, 0, 3 ); |
|
| 103 | + |
|
| 104 | + return $this; |
|
| 105 | + } |
|
| 106 | + /** |
|
| 107 | + * Returns the blob sha. |
|
| 108 | + * |
|
| 109 | + * @return string |
|
| 110 | + */ |
|
| 111 | + public function sha() { |
|
| 112 | + return $this->sha; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Return's the blob path. |
|
| 117 | + * |
|
| 118 | + * @return string |
|
| 119 | + */ |
|
| 120 | + public function path() { |
|
| 121 | + return $this->path; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Whether the blob has frontmatter. |
|
| 126 | + * |
|
| 127 | + * @return bool |
|
| 128 | + */ |
|
| 129 | + public function has_frontmatter() { |
|
| 130 | + return $this->frontmatter; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * The front matter of github post |
|
| 135 | + * @return string |
|
| 136 | + */ |
|
| 137 | + public function front_matter() { |
|
| 138 | + return $this->front_matter; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Content without front matter |
|
| 143 | + * @return string |
|
| 144 | + */ |
|
| 145 | + public function post_content() { |
|
| 146 | + if ( ! $this->post_content ) { |
|
| 147 | + $this->content_import(); |
|
| 148 | + } |
|
| 149 | + return $this->post_content; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Returns the formatted/filtered blob content used for import. |
|
| 154 | + * |
|
| 155 | + * @return string |
|
| 156 | + */ |
|
| 157 | + public function content_import() { |
|
| 158 | + $this->post_content = $content = $this->content(); |
|
| 159 | + |
|
| 160 | + if ( $this->has_frontmatter() ) { |
|
| 161 | + // Break out content. |
|
| 162 | + preg_match( '/(^---(.*?)---$(\r\n|\n|\r)?)?(.*)/ms', $content, $matches ); |
|
| 163 | + $this->front_matter = $matches[1]; |
|
| 164 | + $this->post_content = $content = array_pop( $matches ); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + if ( function_exists( 'wpmarkdown_markdown_to_html' ) ) { |
|
| 168 | + $content = wpmarkdown_markdown_to_html( $content ); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Filters the content for import. |
|
| 173 | + */ |
|
| 174 | + return apply_filters( 'wogh_content_import', trim( $content ) ); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * Returns the blob meta. |
|
| 179 | + * |
|
| 180 | + * @return array |
|
| 181 | + */ |
|
| 182 | + public function meta() { |
|
| 183 | + $meta = array(); |
|
| 184 | + |
|
| 185 | + if ( $this->has_frontmatter() ) { |
|
| 186 | + // Break out meta, if present. |
|
| 187 | + preg_match( '/(^---(.*?)---$)?(.*)/ms', $this->content(), $matches ); |
|
| 188 | + array_pop( $matches ); |
|
| 189 | + |
|
| 190 | + $meta = spyc_load( $matches[2] ); |
|
| 191 | + if ( 'yes' == get_option('wogh_ignore_author') ) { |
|
| 192 | + unset($meta['author']); |
|
| 193 | + } |
|
| 194 | + // if ( isset( $meta['link'] ) ) { |
|
| 195 | + // $meta['link'] = str_replace( home_url(), '', $meta['link'] ); |
|
| 196 | + // } |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + return $meta; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * Formats the blob into an API call body. |
|
| 204 | + * |
|
| 205 | + * @return stdClass |
|
| 206 | + */ |
|
| 207 | + // public function to_body() { |
|
| 208 | + // $data = new stdClass; |
|
| 209 | + |
|
| 210 | + // $data->mode = '100644'; |
|
| 211 | + // $data->type = 'blob'; |
|
| 212 | + |
|
| 213 | + // $data->path = $this->path(); |
|
| 214 | + |
|
| 215 | + // if ( $this->sha() ) { |
|
| 216 | + // $data->sha = $this->sha(); |
|
| 217 | + // } else { |
|
| 218 | + // $data->content = $this->content(); |
|
| 219 | + // } |
|
| 220 | + |
|
| 221 | + // return $data; |
|
| 222 | + // } |
|
| 223 | + |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * Formats the blob into an API call body. |
|
| 227 | + * |
|
| 228 | + * @return stdClass |
|
| 229 | + */ |
|
| 230 | + public function to_body() { |
|
| 231 | + $data = new stdClass; |
|
| 232 | + |
|
| 233 | + // $data->mode = '100644'; |
|
| 234 | + // $data->type = 'blob'; |
|
| 235 | + |
|
| 236 | + $data->path = $this->path(); |
|
| 237 | + $data->content = base64_encode( $this->content() ); |
|
| 238 | + $data->sha = $this->sha; |
|
| 239 | + |
|
| 240 | + return $data; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Interprets the blob's data into properties. |
|
| 245 | + */ |
|
| 246 | + protected function interpret_data( $data ) { |
|
| 247 | + $this->sha = isset( $data->sha ) ? $data->sha : ''; |
|
| 248 | + $this->path = isset( $data->path ) ? $data->path : ''; |
|
| 249 | + |
|
| 250 | + $this->set_content( |
|
| 251 | + isset( $data->content ) ? $data->content : '', |
|
| 252 | + isset( $data->encoding ) && 'base64' === $data->encoding ? true : false |
|
| 253 | + ); |
|
| 254 | + } |
|
| 255 | 255 | } |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @param stdClass $data Raw blob data. |
| 63 | 63 | */ |
| 64 | - public function __construct( stdClass $data ) { |
|
| 65 | - $this->interpret_data( $data ); |
|
| 64 | + public function __construct(stdClass $data) { |
|
| 65 | + $this->interpret_data($data); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public function id() { |
@@ -90,16 +90,16 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return $this |
| 92 | 92 | */ |
| 93 | - public function set_content( $content, $base64 = false ) { |
|
| 94 | - if ( $base64 ) { |
|
| 95 | - $content = base64_decode( $content ); |
|
| 93 | + public function set_content($content, $base64 = false) { |
|
| 94 | + if ($base64) { |
|
| 95 | + $content = base64_decode($content); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // remove whitespace from the beginning of content, |
| 99 | 99 | // To prevent blank lines before yml |
| 100 | - $this->content = ltrim( $content ); |
|
| 100 | + $this->content = ltrim($content); |
|
| 101 | 101 | |
| 102 | - $this->frontmatter = '---' === substr( $this->content, 0, 3 ); |
|
| 102 | + $this->frontmatter = '---' === substr($this->content, 0, 3); |
|
| 103 | 103 | |
| 104 | 104 | return $this; |
| 105 | 105 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @return string |
| 144 | 144 | */ |
| 145 | 145 | public function post_content() { |
| 146 | - if ( ! $this->post_content ) { |
|
| 146 | + if ( ! $this->post_content) { |
|
| 147 | 147 | $this->content_import(); |
| 148 | 148 | } |
| 149 | 149 | return $this->post_content; |
@@ -157,21 +157,21 @@ discard block |
||
| 157 | 157 | public function content_import() { |
| 158 | 158 | $this->post_content = $content = $this->content(); |
| 159 | 159 | |
| 160 | - if ( $this->has_frontmatter() ) { |
|
| 160 | + if ($this->has_frontmatter()) { |
|
| 161 | 161 | // Break out content. |
| 162 | - preg_match( '/(^---(.*?)---$(\r\n|\n|\r)?)?(.*)/ms', $content, $matches ); |
|
| 162 | + preg_match('/(^---(.*?)---$(\r\n|\n|\r)?)?(.*)/ms', $content, $matches); |
|
| 163 | 163 | $this->front_matter = $matches[1]; |
| 164 | - $this->post_content = $content = array_pop( $matches ); |
|
| 164 | + $this->post_content = $content = array_pop($matches); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( function_exists( 'wpmarkdown_markdown_to_html' ) ) { |
|
| 168 | - $content = wpmarkdown_markdown_to_html( $content ); |
|
| 167 | + if (function_exists('wpmarkdown_markdown_to_html')) { |
|
| 168 | + $content = wpmarkdown_markdown_to_html($content); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | 172 | * Filters the content for import. |
| 173 | 173 | */ |
| 174 | - return apply_filters( 'wogh_content_import', trim( $content ) ); |
|
| 174 | + return apply_filters('wogh_content_import', trim($content)); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | public function meta() { |
| 183 | 183 | $meta = array(); |
| 184 | 184 | |
| 185 | - if ( $this->has_frontmatter() ) { |
|
| 185 | + if ($this->has_frontmatter()) { |
|
| 186 | 186 | // Break out meta, if present. |
| 187 | - preg_match( '/(^---(.*?)---$)?(.*)/ms', $this->content(), $matches ); |
|
| 188 | - array_pop( $matches ); |
|
| 187 | + preg_match('/(^---(.*?)---$)?(.*)/ms', $this->content(), $matches); |
|
| 188 | + array_pop($matches); |
|
| 189 | 189 | |
| 190 | - $meta = spyc_load( $matches[2] ); |
|
| 191 | - if ( 'yes' == get_option('wogh_ignore_author') ) { |
|
| 190 | + $meta = spyc_load($matches[2]); |
|
| 191 | + if ('yes' == get_option('wogh_ignore_author')) { |
|
| 192 | 192 | unset($meta['author']); |
| 193 | 193 | } |
| 194 | 194 | // if ( isset( $meta['link'] ) ) { |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | // $data->type = 'blob'; |
| 235 | 235 | |
| 236 | 236 | $data->path = $this->path(); |
| 237 | - $data->content = base64_encode( $this->content() ); |
|
| 237 | + $data->content = base64_encode($this->content()); |
|
| 238 | 238 | $data->sha = $this->sha; |
| 239 | 239 | |
| 240 | 240 | return $data; |
@@ -243,13 +243,13 @@ discard block |
||
| 243 | 243 | /** |
| 244 | 244 | * Interprets the blob's data into properties. |
| 245 | 245 | */ |
| 246 | - protected function interpret_data( $data ) { |
|
| 247 | - $this->sha = isset( $data->sha ) ? $data->sha : ''; |
|
| 248 | - $this->path = isset( $data->path ) ? $data->path : ''; |
|
| 246 | + protected function interpret_data($data) { |
|
| 247 | + $this->sha = isset($data->sha) ? $data->sha : ''; |
|
| 248 | + $this->path = isset($data->path) ? $data->path : ''; |
|
| 249 | 249 | |
| 250 | 250 | $this->set_content( |
| 251 | - isset( $data->content ) ? $data->content : '', |
|
| 252 | - isset( $data->encoding ) && 'base64' === $data->encoding ? true : false |
|
| 251 | + isset($data->content) ? $data->content : '', |
|
| 252 | + isset($data->encoding) && 'base64' === $data->encoding ? true : false |
|
| 253 | 253 | ); |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -8,10 +8,10 @@ discard block |
||
| 8 | 8 | * @return WP_Error |
| 9 | 9 | */ |
| 10 | 10 | function wogh_append_error( $error, $error2 ) { |
| 11 | - if ( is_wp_error( $error ) ) { |
|
| 12 | - $error->add( $error2->get_error_code(), $error2->get_error_message() ); |
|
| 13 | - } |
|
| 14 | - return $error2; |
|
| 11 | + if ( is_wp_error( $error ) ) { |
|
| 12 | + $error->add( $error2->get_error_code(), $error2->get_error_message() ); |
|
| 13 | + } |
|
| 14 | + return $error2; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | * @return bool |
| 22 | 22 | */ |
| 23 | 23 | function wogh_equal_front_matter( $post, $blob ) { |
| 24 | - $str1 = $post->front_matter(); |
|
| 25 | - $str2 = $blob->front_matter(); |
|
| 26 | - return trim($str1) === trim($str2); |
|
| 24 | + $str1 = $post->front_matter(); |
|
| 25 | + $str2 = $blob->front_matter(); |
|
| 26 | + return trim($str1) === trim($str2); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return bool |
| 32 | 32 | */ |
| 33 | 33 | function wogh_is_dont_export_content() { |
| 34 | - return 'yes' === get_option( 'wogh_dont_export_content' ); |
|
| 34 | + return 'yes' === get_option( 'wogh_dont_export_content' ); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | * @return string |
| 42 | 42 | */ |
| 43 | 43 | function wogh_git_sha( $content ) { |
| 44 | - // $header = "blob $len\0" |
|
| 45 | - // sha1($header . $content) |
|
| 46 | - $len = strlen( $content ); |
|
| 47 | - return sha1( "blob $len\0$content" ); |
|
| 44 | + // $header = "blob $len\0" |
|
| 45 | + // sha1($header . $content) |
|
| 46 | + $len = strlen( $content ); |
|
| 47 | + return sha1( "blob $len\0$content" ); |
|
| 48 | 48 | } |
@@ -7,9 +7,9 @@ discard block |
||
| 7 | 7 | * @param WP_Error $error2 |
| 8 | 8 | * @return WP_Error |
| 9 | 9 | */ |
| 10 | -function wogh_append_error( $error, $error2 ) { |
|
| 11 | - if ( is_wp_error( $error ) ) { |
|
| 12 | - $error->add( $error2->get_error_code(), $error2->get_error_message() ); |
|
| 10 | +function wogh_append_error($error, $error2) { |
|
| 11 | + if (is_wp_error($error)) { |
|
| 12 | + $error->add($error2->get_error_code(), $error2->get_error_message()); |
|
| 13 | 13 | } |
| 14 | 14 | return $error2; |
| 15 | 15 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param Writing_On_GitHub_Blob $blob |
| 21 | 21 | * @return bool |
| 22 | 22 | */ |
| 23 | -function wogh_equal_front_matter( $post, $blob ) { |
|
| 23 | +function wogh_equal_front_matter($post, $blob) { |
|
| 24 | 24 | $str1 = $post->front_matter(); |
| 25 | 25 | $str2 = $blob->front_matter(); |
| 26 | 26 | return trim($str1) === trim($str2); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return bool |
| 32 | 32 | */ |
| 33 | 33 | function wogh_is_dont_export_content() { |
| 34 | - return 'yes' === get_option( 'wogh_dont_export_content' ); |
|
| 34 | + return 'yes' === get_option('wogh_dont_export_content'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | * @param string $content |
| 41 | 41 | * @return string |
| 42 | 42 | */ |
| 43 | -function wogh_git_sha( $content ) { |
|
| 43 | +function wogh_git_sha($content) { |
|
| 44 | 44 | // $header = "blob $len\0" |
| 45 | 45 | // sha1($header . $content) |
| 46 | - $len = strlen( $content ); |
|
| 47 | - return sha1( "blob $len\0$content" ); |
|
| 46 | + $len = strlen($content); |
|
| 47 | + return sha1("blob $len\0$content"); |
|
| 48 | 48 | } |