api_key: '.stripslashes(strip_tags(get_option( 'applywithlinkedin_apikey' ))).' ';
} // if
}
// shortcode for adding linkedin buttons to post
//[applywithlinkedin jobtitle="Developer" companyname="d-Media" email="martijn@d-media.nl"]
function applywithlinkedin_sc_func( $atts ) {
extract( shortcode_atts( array(
'jobtitle' => '',
'companyname' => '',
'email' => '',
'logo' => '',
'themecolor' => '',
), $atts ) );
// clean vars
$jobtitle=strip_tags($jobtitle);
$companyname=strip_tags($companyname);
$email=strip_tags($email);
$logo=strip_tags($omschrijving);
$themecolor=strip_tags($themecolor);
if ($logo != ''){ $logo='data-logo="'.$logo.'"'; }
if ($themecolor != ''){ $themecolor='data-themecolor="'.$themecolor.'"'; }
// build button
$result='';
// add div for styling
if ( get_option( 'applywithlinkedin_divstyling' ) == 1){ $result='
'.$result.'
'; }
// return button
return $result;
}
add_shortcode( 'applywithlinkedin', 'applywithlinkedin_sc_func' );
/* admin area */
// register plugin options
function applywithlinkedin_register_plugin_settings() {
// only for users who can manage options
if ( current_user_can( 'manage_options' ) ){
// add options with default values (only adds them if they don't exist yet)
add_option( 'applywithlinkedin_apikey' ,'' );
add_option( 'applywithlinkedin_divstyling','' );
}
}
// adds page to the admin menu
function applywithlinkedin_options(){
$page=add_options_page( 'Apply with LinkedIn button settings', 'Apply with LinkedIn', 'administrator', basename(__FILE__), 'applywithlinkedin_options_page' );
// Using registered $page handle to hook stylesheet loading
add_action( 'admin_print_styles-' . $page, 'applywithlinkedin_admin_stylesandscripts' );
}
// add js and stylesheet for options page, It will be called only on your plugin admin page, enqueue our stylesheet here
function applywithlinkedin_admin_stylesandscripts() {
wp_enqueue_style('applywithlinkedinStylesheet');
wp_enqueue_script('applywithlinkedinScript');
}
// plugin options page
function applywithlinkedin_options_page(){
if ( isset( $_POST ) ){
if ( isset( $_POST['Submit'] ) ){
update_option( 'applywithlinkedin_apikey', $_POST['apikey'] );
update_option( 'applywithlinkedin_divstyling', $_POST['divstyling'] );
}
}
?>
After setting up the API key you can use the following shortcode to add buttons to your post:
[applywithlinkedin jobtitle="Developer" companyname="d-Media" email="martijn@d-media.nl"]
Settings' ), $links );
}
?>