Skip to content

Commit 73a26a0

Browse files
committed
mini update
:) 1.08 version
1 parent a397ffe commit 73a26a0

File tree

3 files changed

+64
-25
lines changed

3 files changed

+64
-25
lines changed

admin/admin.php

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function artvelog_redirectpage_options_page() {
77
->add_fields( array(
88
Field::make( 'select', 'custom_page_id', __( 'Custom Redirect Page', 'redirect-artvelog') )
99
->add_options( crb_get_pages_array() )
10-
->set_help_text( 'Please select the page whose content will be displayed on the redirect page. <b>Using a custom page would be more beneficial.</b>', 'redirect-artvelog' ),
10+
->set_help_text( 'Please select the page whose content will be displayed on the redirect page. <b>Using a custom page would be more beneficial.</b> <br> <hr> Page ID Shortcode: <kbd>[rp_page_ID]</kbd>', 'redirect-artvelog' ),
1111

1212
Field::make( 'select', 'custom_page_builder', 'Page Builder', 'redirect-artvelog' )
1313
->add_options( array(
@@ -22,21 +22,21 @@ function artvelog_redirectpage_options_page() {
2222

2323

2424
Field::make( 'text', 'redirect_page_title', __( 'Custom Redirect Page Title', 'redirect-artvelog' ) )
25-
->set_help_text( 'Enter the title of the redirect page.', 'redirect-artvelog' )
25+
->set_help_text( 'Enter the title of the redirect page. <br> <hr> Page Title Shortcode: <kbd>[rp_title]</kbd>', 'redirect-artvelog' )
2626
->set_default_value( "Redirect Page" )
2727
->set_required(true),
2828

2929
Field::make( 'text', 'redirect_rewrite', __( 'Rewrite Page Slug' , 'redirect-artvelog') )
3030
->set_help_text( 'Determine the extension of the redirect page. <b>By default, "redirect" is used.</b> <b style="color: red;">After changing it, you must save the changes from the Permalinks section.</b>', 'redirect-artvelog' )
31-
->set_default_value( "yonlendirme" )
31+
->set_default_value( "redirect" )
3232
->set_required(true),
3333

3434
Field::make( 'text', 'delay_time', __( 'Delay Time', 'redirect-artvelog' ) )
3535
->set_default_value( 5 )
3636
->set_required(true)
3737
->set_attribute( 'type', 'number' )
3838
->set_attribute( 'step', '0.01' )
39-
->set_help_text( 'Determine the delay time.', 'redirect-artvelog' ),
39+
->set_help_text( 'Determine the delay time. <br> <hr> Delay Time Shortcode: <kbd>[rp_delay_time]</kbd>', 'redirect-artvelog' ),
4040

4141
Field::make( 'text', 'select_link_tag', __( 'Usable Html Tag', 'redirect-artvelog' ) )
4242
->set_help_text( 'Specify the class or ID of the "a" tag to be redirected. If you want to use all links directly, just write "a". <b style="color: red;">(Internal links will not be redirected!)</b> ', 'redirect-artvelog' )
@@ -58,7 +58,7 @@ function artvelog_redirectpage_options_page() {
5858
->set_attribute( 'placeholder', 'CSS Code...' ),
5959

6060
Field::make( 'html', 'credits' )
61-
->set_html(sprintf( '<h3>Redirect Page</h3> <p>© <a href="https://creative.artvelog.com">Plugin by Artvelog</a> - <a href="https://carbonfields.net/">Options Page by Carbon Fields.</a></p></br><h4><a href="https://github.com/artvelog/Custom-Redirect-Page">Github</a></h4>', __( 'https://emreertan.com or https://creative.artvelog.com' ) ) )
61+
->set_html(sprintf( 'If you wish, you can print the url address of the site to be redirected in your redirect page with this shortcode: <kbd>[rp_redirect_url]</kbd> <br> <hr> <h3>Redirect Page</h3> <p>© <a href="https://creative.artvelog.com">Plugin by Artvelog</a> - <a href="https://carbonfields.net/">Options Page by Carbon Fields.</a></p></br><h4><a href="https://github.com/artvelog/Custom-Redirect-Page">Github</a></h4>', __( 'https://emreertan.com or https://creative.artvelog.com' ) ) ),
6262
) );
6363

6464
}
@@ -73,4 +73,22 @@ function crb_get_pages_array() {
7373
$pages_array[ $page->ID ] = $page->post_title;
7474
}
7575
return $pages_array;
76-
}
76+
}
77+
78+
function rp_time_shortcode(){
79+
$time = carbon_get_theme_option('delay_time');
80+
return $time;
81+
}
82+
add_shortcode( 'rp_delay_time', 'rp_time_shortcode' );
83+
84+
function rp_pageID_shortcode(){
85+
$p_id = carbon_get_theme_option('custom_page_id');
86+
return $p_id;
87+
}
88+
add_shortcode( 'rp_page_ID', 'rp_pageID_shortcode' );
89+
90+
function rp_title_shortcode(){
91+
$title = carbon_get_theme_option('redirect_page_title');
92+
return $title;
93+
}
94+
add_shortcode( 'rp_title', 'rp_title_shortcode' );

index.php

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Plugin Name: Artvelog - Redirect Page
66
* Plugin URI: https://creative.artvelog.com/#redirect-page
77
* Description: It creates a 'redirect page' between your website and the site to which you will be redirected for Wordpress.
8-
* Version: 1.05
8+
* Version: 1.08
99
* Author: Emre Ertan
1010
* Author URI: https://emreertan.com
1111
* Text Domain: redirect-artvelog
@@ -68,25 +68,32 @@ function artvelog_redirect() {
6868
$trim_slug = text_to_url($slug);
6969

7070
$use_tag = carbon_get_theme_option('select_link_tag');
71+
72+
$site_directory = base64_encode(ABSPATH);
7173
?>
7274
<script>
73-
jQuery(function($){
74-
$("<?php echo $use_tag ?>").click(function(e) {
75-
if(e.target.href.indexOf(location.hostname) != -1){
76-
return;
77-
}
78-
else{
79-
if (!$(this).attr("href").startsWith("#")) {
80-
e.preventDefault();
81-
var url = $(this).attr('href');
82-
var ref = "<?php echo $trim_ref ?>";
83-
var time = <?php echo $time ?>;
84-
var slug = "<?php echo $trim_slug ?>";
85-
window.location.href = "/" + slug + "?url=" + encodeURIComponent(url) + "&ref=" + ref + "&time=" + time;
86-
}
87-
}
88-
});
89-
});
75+
(function ($) {
76+
jQuery(function($){
77+
$("<?php echo $use_tag ?>").click(function(e) {
78+
var role = e.target.getAttribute("role");
79+
if(e.target.href.indexOf(location.hostname) != -1){
80+
return;
81+
}
82+
else{
83+
if (!$(this).attr("href").startsWith("#") || role == "button") {
84+
e.preventDefault();
85+
var url = $(this).attr('href');
86+
var ref = "<?php echo $trim_ref ?>";
87+
var time = <?php echo $time ?>;
88+
var slug = "<?php echo $trim_slug ?>";
89+
var base = "<?php echo $site_directory ?>";
90+
91+
window.location.href = "/" + slug + "?url=" + encodeURIComponent(url) + "&ref=" + ref + "&time=" + time + "&base=" + base;
92+
}
93+
}
94+
});
95+
});
96+
})(jQuery);
9097
</script>
9198
<?php
9299
}

redirect-page.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<?php
22
define('WP_USE_THEMES', false);
3-
require_once( $_SERVER[ 'DOCUMENT_ROOT' ] .'/wp-blog-header.php');
3+
if(isset($_GET['base'])){
4+
$base_url = base64_decode( $_GET['base'] );
5+
$base_directory = $base_url;
6+
require_once( $base_directory . '/wp-blog-header.php');
7+
}
8+
else{
9+
require_once( $_SERVER[ 'DOCUMENT_ROOT' ] .'/wp-blog-header.php');
10+
}
11+
412

513
if(isset($_SERVER['HTTP_REFERER'])) {
614
$referer = $_SERVER['HTTP_REFERER'];
@@ -9,6 +17,12 @@
917
remove_action( 'wp_footer', 'artvelog_redirect' );
1018

1119
require_once(plugin_dir_path( __FILE__ ) . '/inc/builder_support.php');
20+
21+
function redirect_url_shortcode(){
22+
$redirect_url = $_GET['url'];
23+
return $redirect_url;
24+
}
25+
add_shortcode( 'rp_redirect_url', 'redirect_url_shortcode' );
1226

1327
?>
1428
<!DOCTYPE html>

0 commit comments

Comments
 (0)