Code Duplication    Length = 31-31 lines in 3 locations

components/Helpers.php 1 location

@@ 320-350 (lines=31) @@
317
     *
318
     * @return bool|int|null
319
     */
320
    public function save_meta ( $_null, $post_ID = null, $meta_key = null, $meta_value = null ) {
321
        if ( 'code' == $meta_key ) {
322
            $post = get_post( $post_ID );
323
324
            if ( is_object( $post ) && $this->object_type == $post->post_type ) {
325
                $postdata = array(
326
                    'ID' => $post_ID,
327
                    'post_content' => $meta_value
328
                );
329
330
                remove_filter( current_filter(), array( $this, __FUNCTION__ ), 10 );
331
332
                $revisions = false;
333
334
                if ( has_action( 'pre_post_update', 'wp_save_post_revision' ) ) {
335
                    remove_action( 'pre_post_update', 'wp_save_post_revision' );
336
337
                    $revisions = true;
338
                }
339
340
                wp_update_post( (object) $postdata ); // objects will be automatically sanitized
341
342
                if ( $revisions )
343
                    add_action( 'pre_post_update', 'wp_save_post_revision' );
344
345
                return true;
346
            }
347
        }
348
349
        return $_null;
350
    }
351
352
    /**
353
     * @static

components/Templates/Templates.php 1 location

@@ 375-405 (lines=31) @@
372
	 *
373
	 * @return bool|int|null
374
	 */
375
	public function save_meta ( $_null, $post_ID = null, $meta_key = null, $meta_value = null ) {
376
		if ( 'code' == $meta_key ) {
377
			$post = get_post( $post_ID );
378
379
			if ( is_object( $post ) && $this->object_type == $post->post_type ) {
380
				$postdata = array(
381
					'ID' => $post_ID,
382
					'post_content' => $meta_value
383
				);
384
385
				remove_filter( current_filter(), array( $this, __FUNCTION__ ), 10 );
386
387
				$revisions = false;
388
389
				if ( has_action( 'pre_post_update', 'wp_save_post_revision' ) ) {
390
					remove_action( 'pre_post_update', 'wp_save_post_revision' );
391
392
					$revisions = true;
393
				}
394
395
				wp_update_post( (object) $postdata ); // objects will be automatically sanitized
396
397
				if ( $revisions )
398
					add_action( 'pre_post_update', 'wp_save_post_revision' );
399
400
				return true;
401
			}
402
		}
403
404
		return $_null;
405
	}
406
407
	/**
408
	 * Display the page template

components/Pages.php 1 location

@@ 574-604 (lines=31) @@
571
     *
572
     * @return bool|int|null
573
     */
574
    public function save_meta ( $_null, $post_ID = null, $meta_key = null, $meta_value = null ) {
575
        if ( 'code' == $meta_key ) {
576
            $post = get_post( $post_ID );
577
578
            if ( is_object( $post ) && $this->object_type == $post->post_type ) {
579
                $postdata = array(
580
                    'ID' => $post_ID,
581
                    'post_content' => $meta_value
582
                );
583
584
                remove_filter( current_filter(), array( $this, __FUNCTION__ ), 10 );
585
586
                $revisions = false;
587
588
                if ( has_action( 'pre_post_update', 'wp_save_post_revision' ) ) {
589
                    remove_action( 'pre_post_update', 'wp_save_post_revision' );
590
591
                    $revisions = true;
592
                }
593
594
                wp_update_post( (object) $postdata ); // objects will be automatically sanitized
595
596
                if ( $revisions )
597
                    add_action( 'pre_post_update', 'wp_save_post_revision' );
598
599
                return true;
600
            }
601
        }
602
603
        return $_null;
604
    }
605
606
    /**
607
     * Flush Pod Page Rewrite cache