: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'LCW_Live_Score' ) ) {
class LCW_Live_Score extends LCW_Base_Class{
public function __construct() {
$this->add_action( 'admin_menu', 'lcw_score_admin_menus');
$this->add_action( 'wp_loaded', 'lcw_score_front_reg_scripts');
$this->add_action( 'admin_enqueue_scripts', 'lcw_score_admin_scripts');
$this->add_action( 'admin_enqueue_scripts', 'lcw_score_admin_styles');
$this->add_action( 'wp_enqueue_scripts', 'lcw_score_front_scripts');
$this->add_action( 'wp_enqueue_scripts', 'lcw_score_front_styles');
$this->add_action( 'wp_footer', 'lcw_add_js_code');
$this->add_action( 'wp_head', 'lcw_add_css_code');
$this->add_action( 'init', 'lcw_score_mapping' );
$this->add_action( 'init', 'lcw_score_matches_mapping' );
$this->add_filter( 'lcw_fixture_text', 'lcw_add_fixture_text');
$this->add_filter( 'lcw_stats_tab_text' , 'lcw_add_stats_tab_text');
$this->add_filter( 'lcw_completed_tab_text' , 'lcw_add_completed_tab_text');
$this->add_filter( 'lcw_upcomming_tab_text' , 'lcw_add_upcomming_tab_text');
$this->add_filter( 'lcw_series_text' , 'lcw_add_series_text');
$this->add_filter( 'lcw_completed_widget_text', 'lcw_add_completed_widget_text');
$this->add_filter( 'lcw_upcomming_widget_text', 'lcw_add_upcomming_widget_text');
$this->add_filter( 'lcw_live_widget_text', 'lcw_add_live_widget_text');
$this->add_ajax ( 'lcw_update_score', 'lcw_update_score');
$this->add_ajax ( 'lcw_update_live_score', 'lcw_update_live_score');
$this->add_ajax ( 'lcw_update_score_cards', 'lcw_update_score_cards');
$this->add_ajax ( 'lcw_update_psl_score', 'lcw_update_psl_score');
$this->add_ajax ( 'lcw_update_psl_score_shortcode', 'lcw_update_psl_score_shortcode');
$this->register_shortcode( 'series', 'lcw_score_series_shortcode' );
$this->register_shortcode( 'series-matches', 'lcw_score_series_matches_shortcode' );
$this->register_shortcode( 'match-detail', 'lcw_match_detail_shortcode' );
$this->register_shortcode( 'player-stats', 'lcw_player_stats_shortcode' );
$this->register_shortcode( 'psl-match', 'lcw_psl_match_shortcode' );
$this->add_action( 'init', 'lcw_feed');
$this->add_filter( 'document_title_parts', 'lcw_change_document_title_parts' );
$this->add_filter( 'pre_get_document_title', 'lcw_change_document_title', 999,1 );
$this->add_action( 'init','lcw_rewrite_rules');
$this->add_action( 'admin_init', 'lcw_flush_rewrite');
$this->add_ajax ( 'lcw_series_list', 'lcw_list_ajax');
$this->add_action( 'admin_footer' , 'lcw_series_list' );
$this->add_action( 'admin_head' , 'lcw_mce_button');
public function lcw_update_psl_score_shortcode( ){
public function lcw_flush_rewrite() {
if ( !get_option('plugin_settings_have_changed') ) {
update_option('plugin_settings_have_changed', false);
public function lcw_score_widget( ){
register_widget( 'lcw_live_score_widget' );
public static function lcw_score_admin_menus() {
add_menu_page( LCW_LIVE_SCORE_PLUGIN_NAME, __( LCW_LIVE_SCORE_PLUGIN_NAME , 'emoji-reaction-settings' ), 'manage_options', 'lcw-score-settings', array(
'lcw_score_plugin_settings_page'
), plugins_url( 'images/live-score.png', dirname(__FILE__)));
public static function lcw_score_plugin_settings_page() {
require_once LCW_LIVE_SCORE_ROOT_PATH . '/admin-pages/live-score-settings.php';
public function lcw_feed(){
add_feed('lcw-feed', array($this,'lcw_feed_content'));
* Function to output button list ajax script
public function lcw_series_list() {
if( $pagenow != 'admin.php' ){
$nonce = wp_create_nonce( 'twd-nonce' );
<script type="text/javascript">
jQuery( document ).ready( function( $ ) {
'action' : 'lcw_series_list', // wp ajax action
'security' : '<?php echo $nonce; ?>' // nonce value created earlier
jQuery.post( ajaxurl, data, function( response ) {
// if nonce fails then not authorized else settings saved
if (typeof(tinyMCE) != 'undefined') {
if (tinyMCE.DOM != null) {
tinyMCE.DOM.cptPostsList = response;
// Hooks your functions into the correct filters
public function lcw_mce_button() {
// check user permissions
if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
// check if WYSIWYG is enabled
if ( 'true' == get_user_option( 'rich_editing' ) ) {
$this->add_filter( 'mce_external_plugins', 'add_mce_plugin' );
$this->add_filter( 'mce_buttons', 'register_mce_button' );
// Script for our mce button
public function add_mce_plugin( $plugin_array ) {
$plugin_array['twd_mce_button'] = plugins_url('js/mce.js',dirname(__FILE__));
// Register our button in the editor
public function register_mce_button( $buttons ) {
array_push( $buttons, 'twd_mce_button' );
public function lcw_list_ajax( ){
$content = $this->lcw_get_content('series');
$contents = utf8_encode($content);
$series = json_decode($contents);
$series_list = $series->seriesList->series;
$arr[ 'World Cup 2019' ] = 2181;
foreach ($series_list as $single_series) {
'text' => $single_series->name,
'value' => $single_series->id
'text' => 'World Cup 2019',
$json = wp_send_json( $list );
public function lcw_update_psl_score( ){
$match_id = $_POST['match_id'];
$psl_content = $this->lcw_get_content_psl( 'https://cricket.yahoo.net/sifeeds/cricket/live/json/'.$match_id.'.json' );
$psl_contents = utf8_encode( $psl_content );
$pslmatches_list = json_decode( $psl_contents);
<div class="lcw-match-info">
if(!empty($pslmatches_list->Innings)){
foreach ( $pslmatches_list->Innings as $Inning ) {
$team = $Inning->Battingteam;
<div class="lcw-home-team">
<?php echo $pslmatches_list->Teams->{$team}->Name_Full ?>
<span> <?php echo $Inning->Total ?>/<?php echo $Inning->Wickets ?> (<?php echo $Inning->Overs ?>) </span>
<div class="lcw-home-team">
<?php echo $pslmatches_list->Teams->{ $pslmatches_list->Matchdetail->Team_Home }->Name_Full ?>
<div class="lcw-home-team">
<?php echo $pslmatches_list->Teams->{ $pslmatches_list->Matchdetail->Team_Away }->Name_Full ?>
<div class="lcw-match-msg">
<?php echo $pslmatches_list->Matchdetail->Result; ?>
<?php echo $pslmatches_list->Matchdetail->Status; ?>
<p><?php echo $pslmatches_list->Matchdetail->Series->Name; ?></p>
<p><?php echo $pslmatches_list->Matchdetail->Venue->Name; ?></p>
<p>Start Date : <?php echo date('d F Y ',strtotime( $pslmatches_list->Matchdetail->Match->Date )) ?></p>
<?php if($pslmatches_list->Matchdetail->Status_Id == 117): ?>
<div class="lcw-table lcw-batsmen" id="lcw-sm-table">
<?php foreach ( $pslmatches_list->Innings as $Inning ) {
$team = $Inning->Battingteam;
<div class="lcw-tr" style="background: #3e3e3e !important;">
<div class="lcw-td" style="text-align: center;"><?php echo $pslmatches_list->Teams->{$team}->Name_Full ?>( Run Rate : <?php echo $Inning->Runrate ?> )</div>
<div class="lcw-td">Batsmens</div>
<div class="lcw-td">R</div>
<div class="lcw-td">B</div>
<div class="lcw-td">4S</div>
<div class="lcw-td">6S</div>
<div class="lcw-td">SR</div>
<?php foreach ($Inning->Batsmen as $batsmen ) {
if(!isset($batsmen->Isbatting) && !$batsmen->Isbatting){
if(isset($batsmen->Isonstrike) && $batsmen->Isonstrike){
$strike = '<em style="color: red;">*</em>';
echo $pslmatches_list->Teams->{$team}->Players->{ $batsmen->Batsman }->Name_Full.$strike;
<p><?php echo $batsmen->Howout ?></p>
<div class="lcw-td"><?php echo $batsmen->Runs ?></div>
<div class="lcw-td"><?php echo $batsmen->Balls ?></div>
<div class="lcw-td hidden-xs hidden-sm"><?php echo $batsmen->Fours ?></div>
<div class="lcw-td hidden-xs hidden-sm"><?php echo $batsmen->Sixes ?></div>
<div class="lcw-td hidden-xs hidden-sm"><?php echo $batsmen->Strikerate ?></div>
<div class="lcw-td">Bowler</div>
<div class="lcw-td">O</div>
<div class="lcw-td">R</div>
<div class="lcw-td">W</div>
<div class="lcw-td hidden-xs hidden-sm">Econ</div>
<div class="lcw-td hidden-xs hidden-sm">WD</div>
<?php foreach ($Inning->Bowlers as $bowler ) {
if(!isset($bowler->Isbowlingtandem) && !$bowler->Isbowlingtandem){
if(isset($bowler->Isbowlingnow) && $bowler->Isbowlingnow){
$strike = '<em style="color: red;">*</em>';
if($pslmatches_list->Teams->{$pslmatches_list->Matchdetail->Team_Home}->Players->{$bowler->Bowler}->Name_Full){
echo $pslmatches_list->Teams->{$pslmatches_list->Matchdetail->Team_Home}->Players->{$bowler->Bowler}->Name_Full.$strike;
}elseif( $pslmatches_list->Teams->{$pslmatches_list->Matchdetail->Team_Away}->Players->{$bowler->Bowler}->Name_Full ){
echo $pslmatches_list->Teams->{$pslmatches_list->Matchdetail->Team_Away}->Players->{$bowler->Bowler}->Name_Full.$strike;
<div class="lcw-td"><?php echo $bowler->Overs ?></div>
<div class="lcw-td"><?php echo $bowler->Runs ?></div>
<div class="lcw-td"><?php echo $bowler->Wickets ?></div>
<div class="lcw-td hidden-xs hidden-sm"><?php echo $bowler->Economyrate ?></div>
<div class="lcw-td hidden-xs hidden-sm"><?php echo $bowler->Wides ?></div>
$content = ob_get_clean();
public function lcw_psl_match_shortcode( $atts ){
/*extract(shortcode_atts(
require_once LCW_LIVE_SCORE_ROOT_PATH . '/templates/psl-matches.php';
$content = lcw_load_psl_match( $this, $match_id );*/
public function lcw_get_content_psl( $segment ){
if ( function_exists('curl_init')){
curl_setopt($ch, CURLOPT_URL, $segment );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($ch);
}else if( ini_get('allow_url_fopen') ){
$content = @file_get_contents( $segment );
$content = 'Please enable curl or allow_url_fopen in order to get cricket data';
public function lcw_change_document_title( $title ){
$series_id = isset( $_GET['series-id'] ) ? $_GET['series-id'] : '';
$match_id = isset( $_GET['match-id'] ) ? $_GET['match-id'] : '';
$player_id = isset( $_GET['player-id'] ) ? $_GET['player-id'] : '';
if( get_query_var( 'series' ) ){
$series_id = get_query_var( 'series' );
if( get_query_var( 'match' ) ){
$match_id = get_query_var( 'match' );
if( get_query_var( 'player' ) ){
if( ! empty( $title ) && is_page('match-detail' ) ){
$match_detail_content = $this->lcw_get_content('matches/'.$series_id.'/'.$match_id);
$match_detail_contents = utf8_encode( $match_detail_content );
$match_detail_list = json_decode($match_detail_contents);
if($match_detail_list->match->status == 'INPROGRESS' || $match_detail_list->match->status == 'LIVE' ){
if( !empty( $match_detail_list->match->scores->homeScore ) ){
$homeScore = $match_detail_list->match->scores->homeScore.' ( '.
$match_detail_list->match->scores->homeOvers.' ) ovs';
if( !empty( $match_detail_list->match->scores->awayScore ) ){
$awayScore = $match_detail_list->match->scores->awayScore.' ( '.
$match_detail_list->match->scores->awayOvers.' ) ovs';
$newtitle = $match_detail_list->match->homeTeam->shortName.' '.$homeScore.' | '.$match_detail_list->match->awayTeam->shortName.' '.$awayScore.' | '.$match_detail_list->match->series->name.' '.$title;
$newtitle = $match_detail_list->match->name.' , '.$match_detail_list->match->series->name.' '.$title;
}elseif( is_page( 'player-stats' ) ){
$player_id = get_query_var( 'player' );
$player_detail_content = $this->lcw_get_content('players/'.$player_id.'/stats/');
$player_detail_contents = utf8_encode( $player_detail_content );
$player_detail_list = json_decode($player_detail_contents);
$newtitle = $player_detail_list->meta->firstName.' '.$player_detail_list->meta->lastName.' '.$title;