I am trying to fix an issue where my custom font (ArcaMojora) is not loading on HTTPS protocol and I have seen a ton of fixes everywhere for code that uses #font-face. After searching vigorously through my WP theme files I realized that my theme (Kleanity) doesn't use #font-face at all but rather below code.
How can I adjust the code so that the custom font loads with HTTPS as well as HTTP?
Any and all help appreciated!
// add filter to register custom fonts for font lists
add_filter('gdlr_core_custom_uploaded_font', 'kleanity_register_custom_uploaded_font');
if( !function_exists('kleanity_register_custom_uploaded_font') ){
function kleanity_register_custom_uploaded_font( $custom_fonts ){
$custom_font = kleanity_get_option('typography', 'font-upload');
if( !empty($custom_font) ){
foreach($custom_font as $font_option){
$custom_fonts[$font_option['name']] = array(
'eot' => $font_option['eot'],
'ttf' => $font_option['ttf'],
);
}
}
$custom_fonts['ArcaMojora'] = array(
'name' => 'ArcaMojora',
'eot' => get_template_directory_uri() . '/fonts/ArcaMajora/ArcaMajora3-Bold.eot',
'ttf' => get_template_directory_uri() . '/fonts/ArcaMajora/ArcaMajora3-Bold.ttf',
'font-weight' => 600
);
$custom_fonts['ArcaMojora-Heavy'] = array(
'name' => 'ArcaMojora',
'eot' => get_template_directory_uri() . '/fonts/ArcaMajora/ArcaMajora3-Heavy.eot',
'ttf' => get_template_directory_uri() . '/fonts/ArcaMajora/ArcaMajora3-Heavy.ttf',
'font-weight' => 800,
'varient' => true
);
return $custom_fonts;
} // kleanity_register_custom_uploaded_font
} // function_exists
Well, in the end it was #font-face all along, just hidden away in a file that my search tool wasn't reaching. Sorry about that and thanks for the help! Solution can be found here among other places: Google Web Fonts on HTTPS pages on Chrome
Related
I'm developing an ionic app in which I have a rest api to get the blog contents from wordpress page. I'm trying to get the visual composer page through api but I'm getting raw html format and css or missing for visual component pages. Can I get the visual composer page fully along the properties through api or is there any restriction to use api ??
I think you find your answer here: https://github.com/WP-API/WP-API/issues/2578
The example below was taken from the link above (thank you, bradmsmith!)
Here is an example how to render the VC shortcodes on the content of a post:
add_action( 'rest_api_init', function ()
{
register_rest_field(
'page',
'content',
array(
'get_callback' => 'compasshb_do_shortcodes',
'update_callback' => null,
'schema' => null,
)
);
});
function compasshb_do_shortcodes( $object, $field_name, $request )
{
WPBMap::addAllMappedShortcodes(); // This does all the work
global $post;
$post = get_post ($object['id']);
$output['rendered'] = apply_filters( 'the_content', $post->post_content );
return $output;
}
I'm using a studiopress theme with backstretch script already included. The site's background image is used but I'm using a content delivery network.
At present the image url is:
mysite.com/media/background-image.jpg
I want it to be:
cdn-url.com/media/background-image.jpg
The reason this matters is the site is hosted in Mid-West, US but has a UK audience. The CDN serves static content from London, UK.
I've posted on studiopress support forum but no reply as yet.
The current functions php code is:
//* Enqueue Backstretch script and prepare images for loading
add_action( 'wp_enqueue_scripts', 'agency_enqueue_backstretch_scripts' );
function agency_enqueue_backstretch_scripts() {
//* Load scripts only if custom background is being used
if ( ! get_background_image() )
return;
wp_enqueue_script( 'agency-pro-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_script( 'agency-pro-backstretch-set', get_bloginfo( 'stylesheet_directory' ).'/js/backstretch-set.js' , array( 'jquery', 'agency-pro-backstretch' ), '1.0.0' );
wp_localize_script( 'agency-pro-backstretch-set', 'BackStretchImg', array( 'src' => str_replace( 'http:', '', get_background_image() ) ) );
}
Can this be altered to get the result I want?
Editing the last line as below works:
wp_localize_script( 'agency-pro-backstretch-set', 'BackStretchImg', array( 'src' => 'cdn_url_here' ) );
I would like to create a file in the Wordpress theme, where i will add my own code, edit profile, show profile information, and perhaps an ability to insert posts / meta data programmatically.
So it needs to be www.mysite.com/profile.php or www.mysite.com/profile/
I do not want to use Buddy Press or any other plugin.
I know how the template system works, i do not want a page template.
It will probably be a class, later on, i do not want to change .htaccess file, and if i must i would appreciated filter function how to do this from functions.php
Basically just a simple .php file i can link to, located in theme root.
include('../../../wp-load.php');
and write any code i would like to.
Any creative solution that is not too "hacky" would be appreciated.
Spent around 2 days googling bashing my head on this, before i decided to ask question.
Thank you very much.
Ok, I managed to do this, took me 2 days to figure it out. Here is how I managed to do it:
Make a plugin folder.
In that plugin folder make 1x php file. so index.php
Ok so first thing we need to register plugin I did it like this, in your index.php paste
this code.
function activate_profile_plugin() {
add_option( 'Activated_Plugin', 'Plugin-Slug' );
/* activation code here */
}
register_activation_hook( __FILE__, 'activate_profile_plugin' );
Then we need a function when you register a plugin only once register profile pages.
function create_profile_page( $title, $slug, $post_type, $shortcode, $template = null ) {
//Check if the page with this name exists.
if(!get_page_by_title($title)) {
// if not :
$page_id = -1;
$page_id = wp_insert_post(
array(
'comment_status' => 'open',
'ping_status' => 'open',
'post_content' => $shortcode,
'post_author' => 1, // Administrator is creating the page
'post_title' => $title,
'post_name' => strtolower( $slug ),
'post_status' => 'publish',
'post_type' => strtolower( $post_type )
)
);
// If a template is specified in the function arguments, let's apply it
if( null != $template ) {
update_post_meta( get_the_ID(), '_wp_page_template', $template );
} // end if
return $page_id;
}
}
Ok so we created function which programatically register pages. It has 5 paramethers.
is Title
Slug
Post type
Shortcode.
Template
For the shortcode template you need to make a shortcode with the complete page output
and add it as a parameter to this function, so for registration page it will be a shortcode with the registration forms etc.
For example :
function registration_shortcode(){
echo 'Wellcome to Registration page';
}
add_shortcode('registration_output', 'registration_shortcode');
Next thing we need to call it once only when plugin loads.
so we do this :
function load_plugin() {
if ( is_admin() && get_option( 'Activated_Plugin' ) == 'Plugin-Slug' ) {
delete_option( 'Activated_Plugin' );
/* do stuff once right after activation */
// example: add_action( 'init', 'my_init_function' );
create_profile_page('Registration', 'registration', 'page', '[registration_output]');
create_profile_page('Profile', 'profile', 'page', '[profile_shortcode]');
create_profile_page('Profil Edit', 'profile-edit', 'page', '[edit_shortcode]');
}
}
add_action( 'admin_init', 'load_plugin' );
Ok so this will execute only once when plugin loads and it will create 3 Pages, which are Profile, Registration and Profile Edit.
And that's it, you have your front-end user profile blank pages, and you can write page output in shortcodes ,create more pages, put any forms or elements you like and create decent profile (which doesn't have any stuff you don't need in it like plugins. )
Hope this helps, it was painful for me to figure this out. Cheers!
I'm developing a social network with Buddypress, I created a RSS plugin to pull the RSS feed from the specified websites.
Everything is working, except when the RSS is posted to the activity stream. When I create the activity content to print a link, I set the link target to "_new" to open it in a new page.
Here's the code:
function wprss_add_to_activity_feed($item, $inserted_ID) {
$permalink = $item->get_permalink();
$title = $item->get_title();
$admin = get_user_by('login', 'admin');
# Generates the link
$activity_action = sprintf( __( '%s published a new RSS link: %s - ', 'buddypress'), bp_core_get_userlink( $admin->ID ), '' . attribute_escape( wprss_limit_rss_title_chars($title) ) . '');
/* Record this in activity streams */
bp_activity_add( array(
'user_id' => $admin->ID,
'item_id' => $inserted_ID,
'action' => $activity_action,
'component' => 'rss',
'primary_link' => $permalink,
'type' => 'activity_update',
'hide_sitewide' => false
));
}
It should come up with something like that:
Test
But it prints like that:
Test
Why is this happening?
The 'target' attribute is probably getting stripped by BuddyPress's implementation of the kses filters. You can whitelist the attribute as follows:
function se16329156_whitelist_target_in_activity_action( $allowedtags ) {
$allowedtags['a']['target'] = array();
return $allowedtags;
}
add_filter( 'bp_activity_allowed_tags', 'se16329156_whitelist_target_in_activity_action' );
This probably won't retroactively fix the issue for existing activity items - it's likely that they had the offending attribute stripped before being stored in the database. But it should help for future items.
i've written a plugin for the Wordpress TinyMCE editor and i want to use images which have been previously uploaded to the media gallery in that plugin. How can i access all uploaded pictures in my own plugin? I can't find it in the wordpress docs.
Thanks.
I am slightly not clear on your question. Are you looking for a method to access the Add Media button?
In attempts to answer your question -> This method allows you to get all attachments that is in your media section.. Currently it displays everything but you can manipulate it the way you want to.
Reference: http://codex.wordpress.org/Template_Tags/get_posts
$args = array( 'post_type' => 'attachment', 'numberposts' => -1);
$attachments = get_posts($args);
if ($attachments) {
foreach ( $attachments as $attachment ) {
echo apply_filters( 'the_title' , $attachment->post_title );
the_attachment_link( $attachment->ID , false );
}
}