query("SELECT id FROM " . $yydev_redirect_table_name . " WHERE id = " . $secondary_page_id); if($check_for_real_data_id == 0) { $error_message = "The redirect id you were looking for was not found"; $new_page_link = $plugin_page_url . "&error-message=" . urlencode($error_message); yydev_redirect_redirections_page($new_page_link); } // if($check_for_real_data_id < 1 ) { } else { // if( isset($secondary_page_id) && !empty($secondary_page_id) && is_numeric($secondary_page_id) ) { $error_message = "The redirect id you were looking for was not found"; $new_page_link = $plugin_page_url . "&error-message=" . urlencode($error_message); yydev_redirect_redirections_page($new_page_link); } // } else { // if( isset($secondary_page_id) && !empty($secondary_page_id) && is_numeric($secondary_page_id) ) { // ==================================================== // Removing the main Data if it was deleted // ==================================================== if(isset($_GET['remove-form']) && isset($secondary_page_id) && !empty($secondary_page_id) ) { $check_content_id = $wpdb->query("SELECT * FROM " . $yydev_redirect_table_name . " WHERE id = " . $secondary_page_id); if($check_content_id > 0) { // if the data id exists on the database it will be removed $wpdb->delete( $yydev_redirect_table_name, array('id'=>$secondary_page_id) ); // removing main database info $wpdb->delete( $yydev_secondary_table_name, array('secondary_id'=>$secondary_page_id) ); // removing all sub database info $message = "The redirect id #" . $secondary_page_id . " was removed successfully"; $new_page_link = $plugin_page_url . "&message=" . urlencode($message); yydev_redirect_redirections_page($new_page_link); } else { // if($check_content_id > 0) { $error_message = "The redirect id wasn't not found"; $new_page_link = $plugin_page_url . "&error-message=" . urlencode($error_message); yydev_redirect_redirections_page($new_page_link); } // } else { // if($check_content_id > 0) { } // if(isset($_GET['remove-form']) && isset($secondary_page_id) && !empty($secondary_page_id) ) { // ==================================================== // Removing secondary form data if it was deleted // ==================================================== if( isset($_GET['remove-secondary-form']) && isset($_GET['secondary_id']) ) { $secondary_redirect_id = intval(yydev_redirect_mysql_prep($_GET['secondary_id'])); $check_secondary_data_id = $wpdb->query("SELECT id FROM " . $yydev_secondary_table_name . " WHERE id = " . $secondary_redirect_id ); if($check_secondary_data_id > 0) { // if the secondary data id exists on the database it will be removed $wpdb->delete( $yydev_secondary_table_name, array('id'=>$secondary_redirect_id) ); $message = "The redirect was removed successfully"; $new_page_link = $plugin_page_url . "&view=secondary&id=" . $secondary_page_id . "&message=" . urlencode($message); yydev_redirect_redirections_page($new_page_link); } else { // if($check_secondary_data_id > 0) { $error_message = "The redirect id was not found and not deleted"; $new_page_link = $plugin_page_url . "&view=secondary&id=" . $secondary_page_id . "&error-message=" . urlencode($error_message); yydev_redirect_redirections_page($new_page_link); } // } else { // if($check_secondary_data_id > 0) { } // if( isset($_GET['remove-secondary-form']) && isset($secondary_redirect_id) ) { // ==================================================== // Add new secondary deta to the database // ==================================================== if( isset($_POST['submit-new-secondary-deta']) && isset($secondary_page_id) && !empty($secondary_page_id) ) { // Getting new position number $new_position = 1; $checking_first_position = $wpdb->get_results("SELECT * FROM " . $yydev_secondary_table_name . " WHERE secondary_id = " . $secondary_page_id . " ORDER BY position ASC limit 1"); foreach($checking_first_position as $wordpress_position) { $new_position = $wordpress_position->position / 2; } // foreach($checking_first_position as $wordpress_position) { // incase there are a lot of data and the new position is 0 // we will reorder all the options if( $new_position == 0 ) { $checking_redirect_positions = $wpdb->get_results("SELECT * FROM " . $yydev_secondary_table_name . " WHERE secondary_id = " . $secondary_page_id . " ORDER BY position ASC"); $redirect_postion = 1; foreach($checking_redirect_positions as $wordpress_positions) { $this_redirect_id = $wordpress_positions->id; $wpdb->update( $yydev_secondary_table_name,array('position'=>$redirect_postion), array('id'=>$this_redirect_id), array('%f') ); $redirect_postion++; } // foreach($checking_first_position as $wordpress_position) { $new_position = 0.5; } // if( $new_position == 0 ) { // If there is no error insert the info to the database $main_deta_id = intval( yydev_redirect_mysql_prep($secondary_page_id) ); $request_url = yydev_redirect_mysql_prep( strtolower(esc_url_raw($_POST['request_url'])) ); $destination_url = yydev_redirect_mysql_prep( esc_url_raw($_POST['destination_url']) ); $redirect_type = yydev_redirect_mysql_prep( intval($_POST['redirect_type']) ); $advertising_platform = yydev_redirect_mysql_prep( sanitize_text_field($_POST['advertising_platform']) ); $new_data_position = yydev_redirect_mysql_prep( floatval($new_position) ); // Checking if the data id exists $check_database_exists = $wpdb->query("SELECT id FROM " . $yydev_redirect_table_name . " where id = " . $main_deta_id); if($check_database_exists == 0 ) { $post_error_message = "The redirect id was not found"; } // if($check_database_exists == 0 ) { if(empty($request_url) || empty($destination_url) ) { $post_error_message = "You mush fill both the Request URL and the Destination URL."; } // if(empty($request_url) || empty($destination_url) ) { // making sure the request url doesn't exists so it won't redirect the page twice $checking_if_request_already_exists = $wpdb->query("SELECT * FROM " . $yydev_secondary_table_name . " where request_url = '{$request_url}'"); if($checking_if_request_already_exists > 0 ) { $post_error_message = "The request url is already exists please edit it instead of creating new one."; } // if($checking_if_request_already_exists == 0 ) { if( !isset($post_error_message) ) { // If the secondary data id exists it will add the new data $wpdb->insert( $yydev_secondary_table_name, array('secondary_id'=>$main_deta_id, 'request_url'=>$request_url, 'destination_url'=>$destination_url, 'redirect_type'=>$redirect_type, 'advertising_platform'=>$advertising_platform, 'position'=>$new_data_position, ), array('%d', '%s', '%s', '%s', '%s', '%f') ); // Creating page link and redirect the user the current page with the new data $new_detabase_id = $wpdb->insert_id; $message = "The new redirect was inserted successfully"; $new_page_link = $plugin_page_url . "&view=secondary&id=" . $main_deta_id . "&message=" . urlencode($message); yydev_redirect_redirections_page($new_page_link); } // if( !isset($post_error_message) ) { } // if( isset($_POST['submit-new-secondary-deta']) && isset($secondary_page_id) && !empty($secondary_page_id) ) { // ==================================================== // Update the secondary data if they are changed // ==================================================== if( isset($_POST['update-secondary-deta']) ) { foreach( $_POST['form_id'] as $this_secondary_data_id) { // If there is no error insert the info to the database $main_deta_id = yydev_redirect_mysql_prep( intval($_POST['form_id'][$this_secondary_data_id]) ); $request_url = yydev_redirect_mysql_prep( esc_url_raw(strtolower($_POST['request_url'][$this_secondary_data_id])) ); $destination_url = yydev_redirect_mysql_prep( esc_url_raw($_POST['destination_url'][$this_secondary_data_id]) ); $redirect_type = yydev_redirect_mysql_prep( intval($_POST['redirect_type'][$this_secondary_data_id]) ); $redirects_amount = yydev_redirect_mysql_prep( intval($_POST['redirects_amount'][$this_secondary_data_id]) ); $advertising_platform = yydev_redirect_mysql_prep( sanitize_text_field($_POST['advertising_platform'][$this_secondary_data_id]) ); $position = yydev_redirect_mysql_prep( floatval($_POST['position'][$this_secondary_data_id]) ); // Checking data id exists $check_database_exists = $wpdb->query("SELECT id FROM " . $yydev_secondary_table_name . " where id = " . $main_deta_id); if($check_database_exists == 0 ) { $post_error_message = "The redirect id was not found"; } else { // if($check_database_exists < 1 ) { // If the database id exists it will add the new secondary data $wpdb->update( $yydev_secondary_table_name, array('request_url'=>$request_url, 'destination_url'=>$destination_url, 'redirect_type'=>$redirect_type, 'advertising_platform'=>$advertising_platform, 'position'=>$position, 'redirects_amount'=>$redirects_amount, ), array('id'=>$main_deta_id), array('%s', '%s', '%s', '%s', '%f', '%d') ); $success_message = "The redirect settings were updated successfully"; } // } else { // if($check_database_exists < 1 ) { } // foreach( $_POST['form_id'] as $this_secondary_data_id) { } // if( isset($_POST['update-secondary-deta']) ) { // ==================================================== // Update the main database if it's changed // ==================================================== if( isset($_POST['edit-main-database']) && isset($_POST['form_id']) && !empty($_POST['form_id']) ) { // If there is no error insert the info to the database $redirections_name = yydev_redirect_mysql_prep($_POST['redirections_name']); $redirections_slug = str_replace(" ", "_", strtolower(trim($redirections_name))); $redirections_slug = yydev_redirect_mysql_prep($redirections_slug); $main_deta_id = yydev_redirect_mysql_prep($_POST['form_id']); // Checking if the main database id exists $check_database_exists = $wpdb->query("SELECT id FROM " . $yydev_redirect_table_name . " where id = " . $main_deta_id); if($check_database_exists == 0 ) { $post_error_message = "The redirect id was not found"; } else { // if($check_database_exists < 1 ) { // If the main database id exists it will update it $wpdb->update( $yydev_redirect_table_name, array('name'=>$redirections_name, 'slug'=>$redirections_slug, ), array('id'=>$main_deta_id), array('%s', '%s') ); // Creating page link and redirect the user the current page with the new data $new_detabase_id = $wpdb->insert_id; $message = "The redirect was updated successfully"; $new_page_link = $plugin_page_url . "&view=secondary&id=" . $main_deta_id . "&message=" . urlencode($message); yydev_redirect_redirections_page($new_page_link); } // } else { // if($check_database_exists < 1 ) { } // if( isset($_POST['edit-main-database']) && isset($_POST['form_id']) && !empty($_POST['form_id']) ) { ?>
">

Edit 301/302 Redirects Go Back

get_row("SELECT * FROM " . $yydev_redirect_table_name . " WHERE id = " . $secondary_page_id ); ?>

Edit Redirect Settings

Redirect ID: id; ?>




Add Redirect

Example: /go/text/themes/
Example: /go/text/themes/, Example2: http://www.website.com,
Examples: CJ, Impact, ClickBank, Amazon




Edit Redirects

get_results("SELECT * FROM " . $yydev_secondary_table_name . " WHERE secondary_id = " . $secondary_page_id . " ORDER BY position ASC"); // Echo there is no data found if(empty($main_secondary_data_info)) { ?> id;; ?>
ID Request URL Destination URL Redirect Type Redirects Amount Advertising Platform Position Remove
No. redirects found
ID Request URL Destination URL Redirect Type Redirects Amount Advertising Platform Position Remove