Initial Commit - Plugin v1.0.0

This commit is contained in:
2018-05-22 23:40:58 +02:00
parent 0ef7665850
commit 09b279d447
119 changed files with 12872 additions and 0 deletions

30
process/save-options.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
function fbr_save_options(){
if( !current_user_can( 'edit_theme_options' ) ){
wp_die( __( 'You are not allowed to access this page.', 'wp-fb-ratings' ) );
}
check_admin_referer( 'fbr_save_options_verify' );
$fbr_opts = get_option( 'fbr_opts' );
$fbr_opts['fbr_app_id'] = sanitize_text_field( $_POST['fbr_app_id'] );
$fbr_opts['fbr_app_secret'] = sanitize_text_field( $_POST['fbr_app_secret'] );
$fb = new Facebook\Facebook([
'app_id' => $fbr_opts['fbr_app_id'],
'app_secret' => $fbr_opts['fbr_app_secret'],
'default_graph_version' => 'v2.2',
]);
$helper = $fb->getRedirectLoginHelper();
$permissions = ['email','public_profile','manage_pages','pages_show_list'];
$loginUrl = $helper->getLoginUrl(admin_url( 'admin-post.php?action=fbr_fb_login_cb' ), $permissions);
update_option( 'fbr_opts', $fbr_opts );
wp_redirect( $loginUrl );
exit;
}

21
process/select-page.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
function fbr_select_page() {
if( !current_user_can( 'edit_theme_options' ) ){
wp_die( __( 'You are not allowed to access this page.', 'wp-fb-ratings' ) );
}
check_admin_referer( 'fbr_select_page_verify' );
$fbr_opts = get_option( 'fbr_opts' );
$data = explode(',', $_POST['fbr_page_selected']);
$fbr_opts['fbr_page_id'] = sanitize_text_field( $data[0] );
$fbr_opts['fbr_page_access_token'] = sanitize_text_field( $data[1] );
update_option( 'fbr_opts', $fbr_opts );
wp_redirect( admin_url( 'admin.php?page=fbr_plugin_opts&status=3' ) );
exit;
}