Code:
<?php
/*
Plugin Name: Shorted.ga Easy Link pluggin
Plugin URI: http://shorted.ga/
Description: Just simple, if you use this plugins, your Shorted.ga EASY LINK will be added automatically, for all the external links of your website posts or pages.
Version: 1.0
Author: John
Author URI: http://shorted.ga/
License: GPL2
*/
add_filter( 'the_content', 'cn_nf_url_parse2');
function cn_nf_url_parse2( $content ) {
$tip = get_option( 'shortedgatip-info-settings' );
$id = get_option( 'shortedgaid-info-settings' );
$content = str_replace('href="', 'href="http://shorted.ga/'.$id.'/'.$tip.'/', $content);
return $content;
}
add_action( 'admin_menu', 'register_shortedga_menu_page' );
function register_shortedga_menu_page(){
add_menu_page( 'Shorted Menu', 'Shorted Menu', 'manage_options', 'shorted-easy-link-pluggin/shorted-easy-link-pluggin.php', 'shortedga_menu_page', '', 6 );
}
function shortedga_menu_page(){
?><h1>Shorted.ga Menu Options</h1>
<form method="post" action="options.php">
<?php settings_fields( 'shortedgaid-info-settings' ); ?>
<?php do_settings_sections( 'shortedgaid-info-settings' ); ?>
<?php settings_fields( 'shortedgatip-info-settings' ); ?>
<?php do_settings_sections( 'shortedgatip-info-settings' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">Shorted.ga Menu Options</th>
</tr> <tr valign="top"> <td>Please add your Shorted.ga ID<br /><input type="text" name="shortedgaid-info-settings" value="<?php echo get_option( 'shortedgaid-info-settings' ); ?>"/></td>
</tr> <tr valign="top">
<td>Please write correct type of links "0" for Family Safe and "1" for Adult links<br /><input type="text" name="shortedgatip-info-settings" value="<?php echo get_option( 'shortedgatip-info-settings' ); ?>"/></td>
</tr>
</table>
<?php submit_button(); ?></form>
<?php
}
function register_mysettings() { // whitelist options
register_setting( 'shortedgaid-info-settings', 'shortedgaid-info-settings' );
register_setting( 'shortedgatip-info-settings', 'shortedgatip-info-settings' );
}
add_action( 'admin_init', 'register_mysettings' );
<?php
/*
Plugin Name: Shorted.ga Easy Link pluggin
Plugin URI: http://shorted.ga/
Description: Just simple, if you use this plugins, your Shorted.ga EASY LINK will be added automatically, for all the external links of your website posts or pages.
Version: 1.0
Author: John
Author URI: http://shorted.ga/
License: GPL2
*/
add_filter( 'the_content', 'cn_nf_url_parse2');
function cn_nf_url_parse2( $content ) {
$tip = get_option( 'shortedgatip-info-settings' );
$id = get_option( 'shortedgaid-info-settings' );
$content = str_replace('href="', 'href="http://shorted.ga/'.$id.'/'.$tip.'/', $content);
return $content;
}
add_action( 'admin_menu', 'register_shortedga_menu_page' );
function register_shortedga_menu_page(){
add_menu_page( 'Shorted Menu', 'Shorted Menu', 'manage_options', 'shorted-easy-link-pluggin/shorted-easy-link-pluggin.php', 'shortedga_menu_page', '', 6 );
}
function shortedga_menu_page(){
?><h1>Shorted.ga Menu Options</h1>
<form method="post" action="options.php">
<?php settings_fields( 'shortedgaid-info-settings' ); ?>
<?php do_settings_sections( 'shortedgaid-info-settings' ); ?>
<?php settings_fields( 'shortedgatip-info-settings' ); ?>
<?php do_settings_sections( 'shortedgatip-info-settings' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">Shorted.ga Menu Options</th>
</tr> <tr valign="top"> <td>Please add your Shorted.ga ID<br /><input type="text" name="shortedgaid-info-settings" value="<?php echo get_option( 'shortedgaid-info-settings' ); ?>"/></td>
</tr> <tr valign="top">
<td>Please write correct type of links "0" for Family Safe and "1" for Adult links<br /><input type="text" name="shortedgatip-info-settings" value="<?php echo get_option( 'shortedgatip-info-settings' ); ?>"/></td>
</tr>
</table>
<?php submit_button(); ?></form>
<?php
}
function register_mysettings() { // whitelist options
register_setting( 'shortedgaid-info-settings', 'shortedgaid-info-settings' );
register_setting( 'shortedgatip-info-settings', 'shortedgatip-info-settings' );
}
add_action( 'admin_init', 'register_mysettings' );
EDIT - Zamenio sam kod. Ovo je dobar kod koji "radi" jedino sto je problem nece da mi registruje 2 polja podesavanja u bazi. Tacnije uvek registruje "shortedgatip-info-settings" i zapamti vrednost a "shortedgaid-info-settings" se ne pojavljuje nigde u bazi i nece da pamti njegova podesavanja... Verovatno da nesto prilikom prosledjivanja nije dobro ili ne znam... Mozda ne mogu 2 podesavanja odjednom da se proslede :)
[Ovu poruku je menjao Jorgovan88 dana 06.12.2014. u 04:33 GMT+1]
EDIT 2 - Izgleda da WP ne moze ovako da sacuva 2 podesavanja nego mora da bude sacuvano jedno pa drugo :) Pa sam onda tu jednu formu razdvojio na 2 forme i dobio 2 dugmeta za Sacuvavanje tako da sad radi ok sve... TnX
[Ovu poruku je menjao Jorgovan88 dana 06.12.2014. u 13:15 GMT+1]