nm = init_90min(); // main 90min instance add_action( 'admin_menu', array( $this, 'action_admin_menu' ) ); add_action( 'admin_init', array( $this, 'register_settings' ) ); } /** * Register the settings page * * @since 1.0 */ public function action_admin_menu() { $this->hook = add_options_page( __( '90min Settings', '90min' ), //
";
//print_r($all_keys);exit;
$newarray = array();
foreach($all_keys as $key)
{
$m=0;
$newcat = array();
$leagues = $array['data'][$key]['leagues'];
foreach($leagues as $league)
{
$name = $league['name'];
$api = parse_url($league['api']);
$ids = explode("/",$api['path']);
$id = $ids[7];
$teams = $league['teams'];
$categories = $league['categories'];
$newarray[$key][$name]['id'] = intval($id);
$newteam = array();
$j=0;
foreach($teams as $team)
{
$newteam[$j]['name'] = $team['name'];
$teamapi = parse_url($team['api']);
$teamids = explode("/",$teamapi['path']);
$teamid = $teamids[7];
$newteam[$j]['id'] = intval($teamid);
$j++;
}
//$categories = $array['data'][$key]['categories'];
foreach($categories as $category)
{
$categories = explode("/",$category['api']);
$newcat[$m] = $categories[9];
$m++;
}
$newarray[$key][$name]['teams'] = $newteam;
}
$newarray[$key]['categories'] = array_unique($newcat);
}
}
//echo "";
//print_r($newarray);exit;
$json = json_encode($newarray);
if($json) {
if(file_put_contents($dirpath.'data/'.$outfile, $json)) {
// echo "Saved JSON fetched from "{$url}" as "{$outfile}".";
}
}
// main switch for some various maintenance processes
if ( isset( $_GET['action'] ) ) {
$settings = get_option( $this->slug );
switch ( $_GET['action'] ) {
case 'debug-run-cron':
// run the main WP_Cron job
do_action( '90min_fetch_new_posts' );
// message
add_settings_error( $this->slug, '90min-debug-cron', __( 'Debug: Posts were fetched and inserted (if any).', '90min' ), 'updated' );
break;
}
}
// set up the help tabs
add_action( 'in_admin_header', array( $this, 'setup_help_tabs' ) );
// enqueue the CSS for the admin
wp_enqueue_style( 'nm-admin', plugins_url( 'css/admin.css', NMIN_PLUGIN_BASE ) );
// admin scripts
wp_enqueue_script( 'nm-adminjs', plugins_url( 'js/90min-admin.js', NMIN_PLUGIN_BASE ), array( 'jquery', 'underscore' ), false, true );
// localize script, print that JSON file
wp_localize_script( 'nm-adminjs', 'NM', array(
'leagues' => array(
'all' => NM_Util::read_json( 'result.json' ),
'saved' => MC_90min_Settings_Controls::get_option( 'leagues' ),
),
'savedCategories' => MC_90min_Settings_Controls::get_option( 'categories' ),
'strings' => array(
'auth' => array(
'success' => __( 'Success! Your account details are valid.', '90min' ),
'failure' => __( 'The provided account details are not valid, please review them or reach our administrator for assistance.', '90min' ),
),
'leagueFeed' => __( 'League Feed', '90min' ),
)
) );
}
public function setup_help_tabs() {
$screen = get_current_screen();
$screen->add_help_tab( array(
'title' => __( 'Overview', '90min' ),
'id' => '90min-overview',
'content' => __( '
Instructions
Once the plugin is activated, you will be able to select your desired content type and more.
', '90min' )
) );
/*
$screen->add_help_tab( array(
'title' => __( 'Additional Help', '90min' ),
'id' => '90min-additionalhelp',
'content' => __( '
More Help
OpenTracker runs several times faster than older tracker implementations and requires less memory. (For example, it runs fine with the limited resources of many embedded systems.) Several instances of the software may be run in a cluster, with all of them synchronizing with each other. Besides the Hypertext Transfer Protocol (HTTP) opentracker may also be connected to via User Datagram Protocol (UDP), which creates less than half of the tracker traffic HTTP creates.[1] It supports IPv6, gzip compression of full scrapes, and blacklists of torrents. Because there have already been cases of people being accused of copyright violation by the fact that their IP address was listed on a BitTorrent tracker,[2] opentracker may mix in random IP address numbers for the purpose of plausible deniability.
Amazing! screen provides access to the tickets (or ticket types) you have created. Each ticket is has various attributes like price and quantity. The total amount of available tickets determines the maximum capacity of the event. Please note that once the ticket has been published, editing things like price or questions can break data consistency, since attendees may have already bought the ticket with the old data. Also, once a ticket has been published, please keep it published. Do not revert to draft, pending or trash.
Use the Screen Options panel to show and hide the columns that matter most.
', '90min' ),
) );
*/
$screen->set_help_sidebar( __( '
For more information:
', '90min' ) );
}
private function add_settings_field( $section, $key, $field_type, $label, $description = '', $extra_args = array() ) {
$args = wp_parse_args( $extra_args, array(
'id' => $key,
'page' => $this->slug,
'description' => $description,
) );
return add_settings_field(
$key,
$label,
array( 'MC_90min_Settings_Controls', $field_type ),
$this->slug,
$section,
$args
);
}
public function get_supported_languages() {
$dirpath = plugin_dir_path( __FILE__ ) ;
$setting_api_key = get_option('nmin-settings');
$api_key = $setting_api_key['api-key'];
if($api_key != ''){
//$str = file_get_contents('http://www.90min.com/api/partners/v1/catalog?key='.$api_key);
$url='http://www.90min.com/api/partners/v1/catalog?key='.$api_key;
$str = file_get_contents($url);
$array = json_decode($str, true);
$all_keys = array_keys($array['data']);
$all_key = json_encode($all_keys);
$lang = array();
foreach($all_keys as $keylan)
{
$lang[$keylan] = $keylan;
}
//echo "";
//print_r($lang);exit;
if($lang) {
$langs = json_encode($lang);
if(file_put_contents($dirpath.'data/language.json', $langs)) {
// echo "Saved JSON fetched from "{$url}" as "{$outfile}".";
}
}
}
if ( ! empty( $this->supported_languages ) )
return $this->supported_languages;
$decoded = NM_Util::read_json('language.json');
if ( !$decoded )
return array();
return $this->supported_languages = $decoded;
}
public function get_supported_languages_iso() {
$langs = array();
foreach ( (array) $this->get_supported_languages() as $language_code => $language ) {
$langs[ $language_code ] = $language;
}
return $langs;
}
public function register_settings() {
global $pagenow;
// If no options exist, create them.
if ( ! get_option( $this->slug ) ) {
update_option( $this->slug, apply_filters( '90min_default_options', array(
'partner-id' => '',
'api-key' => '',
'post-type' => 'post',
'tagging-tax' => 'category',
'post-status' => 'publish',
'language' => 'en',
'first-save-made' => false,
'is-authenticated' => false,
'update-featured-image' => true,
'show-author-name' => true,
'index-nm-post'=>false,
) ) );
}
register_setting( '90min-options', $this->slug, array( $this, 'validate' ) );
// First, we register a section. This is necessary since all future options must belong to a
add_settings_section(
'general_settings_section',
__( 'Account Details', '90min' ),
array( 'MC_90min_Settings_Controls', 'description' ),
$this->slug
);
$this->add_settings_field(
'general_settings_section',
'partner-id',
'text',
__( 'Partner ID', '90min' )
);
$this->add_settings_field(
'general_settings_section',
'api-key',
'text',
__( 'API Key', '90min' )/*,
sprintf( '%s', '#', _x( 'Where can I find my API key?', 'settings page', '90min' ) )*/
);
$this->add_settings_field(
'general_settings_section',
'auth-button-area',
'auth_button',
''
);
$this->add_settings_field(
'general_settings_section',
'ajax-auth-nonce',
'hidden',
'',
'',
array(
'value' => wp_create_nonce( '90min-ajax-auth' )
)
);
// Post setting section
add_settings_section(
'post_settings_section',
__( 'Post Settings', '90min' ),
array( 'MC_90min_Settings_Controls', 'description' ),
$this->slug
);
$this->add_settings_field(
'post_settings_section',
'display-post-title',
'checkbox',
__( 'Post Title', '90min' ),
'',
array(
'label' => __( 'Do not show title in post body', '90min' )
)
);
$this->add_settings_field(
'post_settings_section',
'display-views-counter',
'checkbox',
__( 'Views Counter', '90min' ),
'',
array(
'label' => __( 'Hide 90min number of views counter', '90min' )
)
);
$this->add_settings_field(
'post_settings_section',
'update-featured-image',
'checkbox',
__( 'Featured Image', '90min' ),
'',
array(
'label' => __( 'Set the article’s main image as your ‘Featured Image’.', '90min' )
)
);
$_post_types_found = get_post_types( array(
'public' => true,
'show_ui' => true,
) );
// clear "attachment" post type
if ( isset($_post_types_found['attachment']) )
unset( $_post_types_found['attachment'] );
$this->add_settings_field(
'post_settings_section',
'post-type',
'select',
__( 'Post Type', '90min' ),
'',
array(
'options' => apply_filters( '90min_supported_post_types', $_post_types_found ) // post types
)
);
$settings_saved_post_type = MC_90min_Settings_Controls::get_option( 'post-type' ); // "post" is default
$selected_post_type = apply_filters( '90min_post_type', $settings_saved_post_type ? $settings_saved_post_type : 'post' );
$all_post_statuses = get_available_post_statuses( $selected_post_type );
$this->add_settings_field(
'post_settings_section',
'post-status',
'select',
__( 'Post Status', '90min' ),
'',
array(
'options' => array_combine( $all_post_statuses, $all_post_statuses )
)
);
// tagging taxonomy
$supported_taxos = get_object_taxonomies( $selected_post_type, 'objects' );
$supported_taxos_list = array();
foreach ( $supported_taxos as $supported_tax_key => $supported_tax ) {
// if this is post_format, ignore
if ( 'post_format' == $supported_tax_key )
continue;
$supported_taxos_list[ $supported_tax_key ] = $supported_tax->labels->singular_name;
}
if ( ! empty($supported_taxos_list) ) {
$this->add_settings_field(
'post_settings_section',
'tagging-tax',
'select',
__( 'Tagging Taxonomy', '90min' ),
'Set 90min\'s categories as ',
array(
'options' => $supported_taxos_list,
'class'=>'tagging-taxonomy'
)
);
}
/*Specific Tags*/
$this->add_settings_field(
'post_settings_section',
'specific-tags',
'checkbox',
__( 'Tags', '90min' ),
'',
array(
'label' => __( "Provide 90min's post specific tags", '90min' )
)
);
/*Show Autho*/
$this->add_settings_field(
'post_settings_section',
'show-author-name',
'checkbox',
__( 'Author', '90min' ),
'',
array(
'label' => __( "Show author's name within post body", '90min' )
)
);
$authors = get_users();
$authors_option = array();
foreach ( $authors as $author ) {
$authors_option[ $author->ID ] = $author->display_name;
}
$this->add_settings_field(
'post_settings_section',
'post-author',
'select',
__( 'Post Author', '90min' ),
__( 'The posts will be attributed to this author', '90min' ),
array(
'options' => $authors_option,
)
);
/*Show Index 90min post option*/
$this->add_settings_field(
'post_settings_section',
'index-nm-post',
'checkbox',
__( 'SEO', '90min' ),
'',
array(
'label' => __( "Don't index posts created by the 90min plugin", '90min' )
)
);
/*$this->add_settings_field(
'post_settings_section',
'hide-author-name',
'checkbox',
__( 'Author', '90min' ),
'',
array(
'label' => __( 'Hide author name?', '90min' )
)
);*/
// Feed Selection section
add_settings_section(
'feed_selection_settings_section',
__( 'Feed Selection', '90min' ),
array( 'MC_90min_Settings_Controls', 'description' ),
$this->slug
);
// $supported_languages = $this->get_supported_languages();
$supported_languages = $this->get_supported_languages_iso();
$this->add_settings_field(
'feed_selection_settings_section',
'language',
'select',
__( 'Language', '90min' ),
'',
array(
'options' => $supported_languages
)
);
$this->add_settings_field(
'feed_selection_settings_section',
'leagues',
'select_special',
__( 'Leagues / Teams', '90min' ),
'',
array(
'options' => array('' => ''),
'multi' => true
)
);
$this->add_settings_field(
'feed_selection_settings_section',
'categories',
'checkbox_group',
__( 'Categories', '90min' ),
'',
array(
'options' => array( '' => ''),
'multi' => true,
)
);
// don't register this setting on all pages
/* if ( 'options-general.php' == $pagenow && $user_info && isset( $user_info->type ) && 'free' != $user_info->type ) {} */
do_action( '90min_setup_settings_fields' );
}
public function display_settings_page() {
?>
90min plugin allows you to automatically integrated 90min content into WordPress posts and pages
90min.com/partners', 'WPsupport@90min.com' ); ?>
" id="nm-started-tab" href="#top#nm-started">
" id="nm-setting-tab" href="#top#nm-setting">
nmtab">
include_once(NMIN_PLUGIN_DIR."get-started.php")?>
nmtab">
dispatcher_auth_test_result) ? NM_Dispatcher::test_auth( $input['partner-id'], $input['api-key'] ) : false;
if ( isset($data->error) ) {
$this->dispatcher_auth_test_result = false;
// credentials are incorrect
add_settings_error( $this->slug, 'invalid-creds', __( 'The credentials are incorrect! Please verify that you have entered them correctly.', '90min' ) );
return $input; // bail
} elseif ( isset( $data->status ) && $data->status == 'success' ) {
$this->dispatcher_auth_test_result = true;
// test the returned data, and let the user know she's alright!
add_settings_error( $this->slug, 'valid-creds', __( 'Connection with 90min has been established! You\'re all set!', '90min' ), 'updated' );
// authenticated? yes.
$input['is-authenticated'] = true;
// great. if this is the first save, also fetch posts now.
if ( ! MC_90min_Settings_Controls::get_option( 'first-save-made' ) ) {
// run the cron job
do_action( '90min_fetch_new_posts' );
// update setting
$input['first-save-made'] = true;
}
}
} else {
$this->dispatcher_auth_test_result = false;
$input['is-authenticated'] = false;
// empty
add_settings_error( $this->slug, 'invalid-creds', __( 'Please fill in the Partner ID and the API key first.', '90min' ) );
}
return $input;
}
}
final class MC_90min_Settings_Controls {
public static function auth_button( $args ) {
?>
sprintf( __('Enter your 90min credentials in order to set up the plugin. Credentials are provided upon request, contact us at %s to receive access.', '90min'), 'WPsupport@90min' ),
'post_settings_section' => __('Customize 90min content in accordance to your editorial needs. Changes to the post layout will only take effect on new posts.', '90min'),
'feed_selection_settings_section' => __('Select your desired content.', '90min'),
);
if ( array_key_exists($args['id'], $sections) ) :
?>
" data-item-name="">
$label ) : ?>
" />
" />
" data-name="">
$label ) : ?>