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/Pages.php 1 location

@@ 551-581 (lines=31) @@
548
     *
549
     * @return bool|int|null
550
     */
551
    public function save_meta ( $_null, $post_ID = null, $meta_key = null, $meta_value = null ) {
552
        if ( 'code' == $meta_key ) {
553
            $post = get_post( $post_ID );
554
555
            if ( is_object( $post ) && $this->object_type == $post->post_type ) {
556
                $postdata = array(
557
                    'ID' => $post_ID,
558
                    'post_content' => $meta_value
559
                );
560
561
                remove_filter( current_filter(), array( $this, __FUNCTION__ ), 10 );
562
563
                $revisions = false;
564
565
                if ( has_action( 'pre_post_update', 'wp_save_post_revision' ) ) {
566
                    remove_action( 'pre_post_update', 'wp_save_post_revision' );
567
568
                    $revisions = true;
569
                }
570
571
                wp_update_post( (object) $postdata ); // objects will be automatically sanitized
572
573
                if ( $revisions )
574
                    add_action( 'pre_post_update', 'wp_save_post_revision' );
575
576
                return true;
577
            }
578
        }
579
580
        return $_null;
581
    }
582
583
    /**
584
     * Flush Pod Page Rewrite cache

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