Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

Goran Tesic on "How to save Theme Customizer changes into .less file instead of inline css?"

$
0
0

First time I'm asking a question here so I apologize in advance if I'm breaking any rules.
I'm trying to build a theme with bootstrap 3 less. I managed to setup wordpress customizer options for color changing to work by outputting css into theme header, the classic way, but I was wondering if there is a way to output these options into .less file and compile the style.css with something like lessphp compiler, which I managed to integrate into the theme and which seems to work when I manually update less files.

Right now i'm outputing css into head by placing this function into functions.php:

`<?php
//change colors
function le_libertaire_register_theme_customizer($wp_customize) {
$colors = array();
$colors[] = array(
'slug' => 'header_text_color',
'default' => '#fff',
'label' => __('Header Text Color', 'Le-libertaire')
);
$colors[] = array(
'slug' => 'navbar_bg_color',
'default' => '#dc3023',
'label' => __('Navbar BG Color', 'Le-libertaire')
);

foreach( $colors as $color ) {
// SETTINGS
$wp_customize->add_setting(
$color['slug'], array(
'default' => $color['default'],
'type' => 'option',
'capability' =>
'edit_theme_options'
)
);
// CONTROLS
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
$color['slug'],
array('label' => $color['label'],
'section' => 'colors',
'settings' => $color['slug'])
)
);
}
}
add_action('customize_register', 'le_libertaire_register_theme_customizer');

?>

and this code into my header.php:

<?php
$navbar_bg_color = get_option('navbar_bg_color');
$header_text_color = get_option('header_text_color');
?>
<style>
.navbar{background: <?php echo $navbar_bg_color ?> !important; }
.navbar-brand, .navbar-nav a{color: <?php echo $header_text_color ?> !important;}
</style>

this is the function from functions.php which I'm using to integrate lessphp into wordpress:

//compile less
function autoCompileLess() {

// include lessc.inc
require_once( get_template_directory().'/less/lessc.inc.php' );

// input and output location
$inputFile = get_template_directory().'/less/bootstrap.less';
$outputFile = get_template_directory().'/style.css';

// load the cache
$cacheFile = $inputFile.".cache";

if (file_exists($cacheFile)) {
$cache = unserialize(file_get_contents($cacheFile));
} else {
$cache = $inputFile;
}

$less = new lessc;
// create a new cache object, and compile
$newCache = $less->cachedCompile($cache);

// output a LESS file, and cache file only if it has been modified since last compile
if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
file_put_contents($cacheFile, serialize($newCache));
file_put_contents($outputFile, $newCache['compiled']);
}
}

if(is_admin()) {
add_action('init', 'autoCompileLess');
}

Can anyone tell me if there is a way to output these variables into, lets say wp-customizer.less file which would be included into bootstrap.less via @import, so that the output code in wp-customizer.less is formated like this

@brand-primary: #dc3023; @brand-success: #fff; where color hex code would be replaced by variable from customizer output?
So to be clear, I want to be able to compile new style.css every time the settings are changed because bloating the head with ton of inline css to achieve something which can be done by changing 3-4 less variables seems like a massive overkill to me. I already integrated lessphp into the theme which seems to work when less files are updated manually, so now I only need to find a way to export customizer settings into an external less file, which will then trigger lessphp compiler and do the trick. I searched all over the web for a solution but to no avail.

Is there a way to save these customizer settings into an external file instead of posting them to head as inline css?


andrewbecks on "Adding an additional paginated page to the_content"

$
0
0

I'm trying to figure out how to append the_content with an additional, paginated page.

For example: I have a paginated post with 3 pages, separated <!--nextpage-->. I want to intercept the_content and add an additional, fourth page.

I've read through a few examples that provide instructions on how to append detail to post content:
https://wordpress.org/support/topic/including-custom-fields-in-the_content-for-posts?replies=1#post-1542139
https://wordpress.org/support/topic/add-code-to-the_content

From there, I have some working code, but adding <!--nextpage--> doesn't have the desired effect of adding the additional, paginated page.

function my_custom_post_append_function($content) {
	global $post;
        $content .= '<!--nextpage-->test test test';
return $content;
}
add_filter( 'the_content', 'my_custom_post_append_function' );

Any thoughts or insight would be greatly appreciated.

Varun Sridharan on "Plugin Subversion Question"

$
0
0

Hi,

I am a Wp Plugin developer.
i have 1 question.

if i commit some files in my plugins trunk svn folder. it gets updated in live even if i have already tagged my plugin version.

Eg : i have released 1.0 plugin version and tagged as 1.0 and i have also started working in 1.1 and also committing 1.l files in truck folder.. when i download my plugins zip file the new files committed in trunk is getting packed not the tagged files :( what to do.

Ken on "Related Posts by Tags"

$
0
0

My current related posts are related by categories. I'd like to make them related by tags.

Please help.

So far, I've changed the top part like this, but got stuck:

*Get current post's tags*/
$post_tags_temp = wp_get_post_tags( $post->ID );
$post_tags = array();
if( !empty( $post_tags_temp )){
	foreach ( $post_tags_temp as $tag) {
		$post_tags[] = $tag->term_ID;
	}
}

Here's link to full file:
http://pastebin.com/9Nye9MHY

kiannachauntis on "Modifying Wordpress Search to Pull From Tags"

$
0
0

Alright, so I know this has been asked *several* times before, and I hate to be the one to ask again, but my situation is a bit different from what I've seen from other posts. However, I can't seem to find a straight answer.

Myself and another programmer have helped to create this website -
http://www.newamericangoods.com/

(Pardon the kinks, it's a work in progress)

We have managed to create a collective of brands that make their products in the US using custom post types. We also built a custom search system that filters these things based off of taxonomies for category, location, quality of the products and so on.

The person we are building this for has put a lot of time into tagging all of these products in hopes that this would help people be able to find them via the search bar, after of course filtering out the things they need from our dropdowns.

However- low and behold- the search box is only pulling from titles and content. We absolutely need this to pull from titles and tags only.

Every post I have seen has been telling people to use the "Search Everything" plugin. I tried that as well as the WP Extended Search plugin and neither seem to work. I assumed at first that this is because we aren't grabbing the default wordpress search form, but rather using our own. However, when using the default search on our "nothing found" page, it still rendered no results.

Does anyone have any links/references/know-how on how to just edit Wordpress core search to pull from tags and titles like this? I am relatively new to search queries myself, but my other programmer is a bit more seasoned but having the same issues finding answers that I am.

Any help or pointers will be greatly appreciated!

shimu666 on "Output data from Wp job manager application to other page"

$
0
0

Hello,
I use Wp job manager, wp job manager Applications.

i would like to output entries done via application form directly on the single job page.
The plugin output the entries in the job manager dashboard. but i would like to output in single job page.

Can you help me with it

2blearn on "Custom plugin to generate flipping squares"

$
0
0

ok, if you go to http://www.2blearn.com , and you scroll down some, you will see a series of squares that flip when the mouse is over them.

Im trying to create a wordpress plugin that lets me create arrangements of this squares and save them, like you would a gallery. Each square will have a title and thumbnail in the front. On the flip side, will have 2 tag counters for pages, those can be fixed.

I have to be able to pic a color for the square and a link that will open in the same window when the square is clicked.

the code for the squares is this:

<div class=" flip-container orange">

<a href="#" class="flipper">
    <div class="front">
        <span>&nbsp;</span>
    </div>
    <div class="back">
        <strong>#</strong>
        <span>Conferencias</span>
        <strong>#</strong>
        <span>VIDEO</span>
    </div>
 </a>
</div>

I've been following this tutorial:

http://www.webdesignerdepot.com/2012/09/building-your-first-wordpress-plugin-part-1/

what i think i have to do is basically define a custom taxonomy in the core.php of my plugin?
Can you people point me in the right direction please?

game_0ver on "wpdb->insert escaping"

$
0
0

I have created a function that adds some data to a database table using wpdb->insert()

Each time the form is submit it adds back slashes to ' character, if form validation fails and refreshes it still adds it, resulting in something like this:

i've becomes i\\\\\\\\\\\\\\\'ve

I am struggling to find the correct WP function to use.


sandyfischler on "Custom Widget Code"

$
0
0

I've got multiple tabs open with tutorials for creating a custom WP widget and I'm confused since they are all saying slighting different things.

I've created my plugin and it shows up in the plugin list (good so far).

Where I'm challenged is in adding the code to actually create the widget and what order things go in since each tutorial is doing it differently and I'd like to start out with Best Practices.

This where I am so far and I'm already stuck because I have questions....

<?php
/*
Plugin Name: Fuller Donation Widgets
Description: Donation channel widgets
Author: Sandy Fischler
Version: 1
*/
/* Start Adding Functions Below this Line */

class fuller_of_openstrap_donation_page_one extends WP_Widget {
    function fuller_of_openstrap_donation_page_one() {
        parent::__construct(false, $name = __('Fuller Donation Widget One', 'fuller_of_openstrap_donation_page_one') );
    }

Questions:

1) Do I state the class first or register the widget first? I see it done both ways. One tutorial starts out with register widget and another has it much lower in the code.

2) In the WP codex they use parent::__construct, in one tutorial they use parent::WP_Widget which is correct?

Thanks!

wpbond on "Custom Option Settings for Slider"

$
0
0

Hello,

I have used the BX Slider for my WordPress site.

Right now all the slider options (speed, effects etc etc.) are hard coded in the JS file.

So I want to do or create various options like Drop down boxes, select check boxes, radio buttons etc etc. so that I can edit those options in the JS file from inside the WP Admin panel.

Can anybody tell me how to do it or direct me to various WP functions and tutorials?

Thank you :)

bobschwenkler on "Trouble adding inline JS in page content"

$
0
0

I'm having trouble with WP stripping JS from my page content. I'm wanting to use the following code as part of my Mailchimp opt in, and the JS is getting stripped. It works in preview mode but the moment I update the page the code disappears. I've been searching for over an hour for a solution and can't find one!

<input id="mce-FNAME" class="required" name="FNAME" type="text" value="First name" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/>

cgaybba on "Google Ajax jQuery wp_enqueue_script on plugin not working"

$
0
0

I have written a custom plugin that should 'enqueue' a few .js files into WordPress. The plugin is basically a jQuery Autocomplete that gets the information from a .js file and inject it into Gravity Form input field using CSS class.

I got it all to work, but I have a problem with the "enqueue" of Google's ajax jQuery file. If I enqueue it in a certain way, the form works 100%, but than it screws around with the admin, especially the "add media" button and the "Visual / Text" toggle buttons on the page.

I've tried the "if (!is_admin())" enqueue scripts, but than the form doesn't work as it should.

So basically, this works, but screws with admin:
wp_enqueue_script('jquery-custom-injection', 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js', __FILE__, '2.1.3', 0 );

This is how it should be, but it doesn't work:

//Making jQuery Google API
function modify_jquery() {
    if (!is_admin()) {
        wp_deregister_script('jquery');
        wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js', false, '2.1.3');
        wp_enqueue_script('jquery');
    }
}
add_action('init', 'modify_jquery');

My plugin's main file looks like this:

// registering core Javascript files
wp_enqueue_script('airport-codes-styles', plugins_url('/css/airports.css', __FILE__), '1.0.0', true );
wp_enqueue_script('jquery-custom-injection', 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js', __FILE__, '2.1.3', 0 );
wp_enqueue_script('airport-codes', plugins_url('/js/airports.js', __FILE__), '1.0.0', 1 );
wp_enqueue_script('airport-autocomplete-method', plugins_url('/js/method.js', __FILE__), '1.0.0', 1 );
wp_enqueue_script('jquery-autocomplete', plugins_url('/js/jquery.autocomplete.js', __FILE__), '1.0.0', 1 );

This is my first time using a plugin to inject Java files, so I am fairly a noob.

Howdy_McGee on "WP Media - Simply Modify Input Value with JS"

$
0
0

I've created a metabox and added a wp_editor() into it. I've removed the default editor from the page ( as this is a post type ). Now, what I'm trying to do is simply understand how to run some JS on the media frame to modify input values.

I tried just plain jQuery but since it's a module and dynamic, it won't work like I initially expected. I then tried searching the Codex but didn't find much in documentation on wp.media save for the initial page but that it more along the lines of creating a wp.media frame where I already have one and just need to attach JS to it.

I'm not sure where to start to even get the current frame Object, using The Codex link above, I thought I could maybe get the current frame with wp.media() but it doens't seem to work so I'm not entirely sure where else to look.

Of course, assume this is enqueued into the footer of the admin-panel.

jQuery(document).ready(function( $ ) {
	var frame = wp.media();

	if ( frame ) {
		frame.on( 'select', function() {
			console.log( 'test' );
		} );
	}
} );

I've posted a similar question in hopes of getting an answer onto the WordPress Stack Exchange, open to any suggests or comments or anything that points me in a forward direction.

Again, I just need to know how to modify an input value in JS on the current or default Media Frame / Module.

dwasisto on "Contact Form 7 Checkbox/Label Issue"

$
0
0

After researching some of the known issues with Contact Form 7, I'm finding that some are acceptable, Contact Form 7 works great for me, except that, for some stylesheet - it may cause some error on the WordPress site I'm currently building.

I've noticed with Contact Form 7's check-boxes or radio buttons will not appear next to the label, but instead in bottom or top, i.e. http://kangen.aripeach.com/index.php/contact/

I would like the check-boxes to line up horizontally, three on a line like in most of the example Contact 7 pages. Unfortunately, no matter how much i tried, it just won't appear as it should. Is this may be related with any stylesheet issue? Can someone please shed some light and help me out?

Can someone help me troubleshoot and how I would fix this?

Thanks for your help!

shawmutsteve on "Page loads twice - but with a twist"

$
0
0

We build dynamic real estate pages. We've noticed that for each single request to generate a page for any given url, our plugin goes through it's initialization twice. The difference appears to be $_SERVER['HTTP_ACCEPT']. On the first time through, HTTP_ACCEPT contains what you would expect -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"

But on the second time through, it only contains "image/webp,*/*;q=0.8". Like it's looking for a favicon or something.

The plugin loads like this:

add_action('plugins_loaded', array(self::instance(), '_setup'));

public static function _setup ()
	{
	global $rover_idx;
	$rover_idx					= new Rover_IDX;

	if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']), 'text/html') !== false))
		{
		require_once ROVER_IDX_PLUGIN_PATH.'rover-init.php';
		require_once ROVER_IDX_PLUGIN_PATH.'rover-content.php';
		}
	}

So we made a change (above)to exit the initilization if HTTP_ACCEPT did not contain 'text/html'. This worked great, until we realized that the Next / Prev browser buttons didn't like it. If you pressed the Prev button, you'd see the previous page, but the [rover_idx...] shortcode would not be translated into content - you'd just see the shortcode on the page.

To reproduce:
- First go to http://vail.demo.roveridx.com/.
- Then go to http://vail.demo.roveridx.com/co/vail/.
- Then hit the back button.

I *think* this should be moved into the Advanced forum section.

Thanks
Steve


NachoMan42 on "fatal error when creating user and blog programmatically"

$
0
0

I have written a plugin for a multisite installation that bypasses the normal login and automatically logs a user in based on a set cookie or creates a user and blog if the user doesn't already exist. I based the user/blog creation on site-new.php. When I run the wpmu_create_blog function I get the following error:

Notice: Use of undefined constant WP_DEFAULT_THEME - assumed 'WP_DEFAULT_THEME' in /usr/local/share/wordpress/wp-admin/includes/schema.php on line 356

Notice: Use of undefined constant WP_DEFAULT_THEME - assumed 'WP_DEFAULT_THEME' in /usr/local/share/wordpress/wp-admin/includes/schema.php on line 423

Fatal error: Call to a member function init() on null in /usr/local/share/wordpress/wp-admin/includes/upgrade.php on line 250

Below is the relevant plugin code:

add_action ('set_current_user', 'sc_authenticate');

function sc_authenticate () {
// Check if already logged in
$user = wp_get_current_user();
if ( ! $user->exists() ) {
// Check if cookie set
if ( isset($_COOKIE['user'])) {
$username = $_COOKIE['user'];
$email = $_COOKIE['email'];

// Automatic login
$user = get_user_by('login', $username );

// Check if user already created in wordpress
if ($user == false) { // user doesn't exist
// create new site and user
$password = wp_generate_password( 12, false );
$user_id = wpmu_create_user( $username, $password, $email )
or die('Unable to create new wordpress user.');
$current_site = get_current_site();
$id = wpmu_create_blog( $current_site->domain, "/$username/", $username . '\'s Musings', $user_id , array( 'public' => 1 ), $current_site->id )
or die('Unable to create new wordpress blog.');
update_user_option( $user_id, 'primary_blog', $id, true );
// set auth cookie and login
wp_clear_auth_cookie();
wp_set_current_user ( $userid );
wp_set_auth_cookie ( $userid );
} else { // user already exists
// set auth cookie and login
wp_clear_auth_cookie();
wp_set_current_user ( $user->ID );
wp_set_auth_cookie ( $user->ID );
}
}
}
}

ehis38 on "My website has being hacked."

$
0
0

Hello all, my website has being hacked. i am actually a newbie with wordpress and i really do not know how to go about this.

Someone please help me out, i just hosted the website last week.

I can view the website but cannot access the backend, am i suppose to delete any file or files from my public_html folder?

The website domain is http://www.ship2naija.com

danatennyson on "Centering location of header with-in code"

$
0
0

My client is wanting us to center the phone number on a "mobile device". What do I need to change in this code to achieve that? The theme we are using is Agency Pro. ( <?php echo '<div class="between-header">' . do_shortcode('[telnumlink](903)870-9000[/telnumlink]') . '</div>'; ?> )
http://www.graysonrecovery.com/
Thank you

tech55541 on "Including this code for a bot trap"

$
0
0

Hello,
I have this code i would like to put on my website. The website says to put it on the top of pages.
Here is the website: https://perishablepress.com/blackhole-bad-bots/
Here is the code: <?php include($_SERVER['DOCUMENT_ROOT'] . "/blackhole/blackhole.php"); ?>
I have uploaded the unzipped folder to my Home directory. Placed the code in header.php only to get this very long error.
EDIT: I have set Executable permissions for User, Group, and World.
ERROR: Warning: include(/home2/ytadvise/public_html/blackhole/blackhole.php): failed to open stream: No such file or directory in /home2/ytadvise/public_html/wp-content/themes/wpex-thoughts/header.php on line 13

Warning: include(): Failed opening '/home2/ytadvise/public_html/blackhole/blackhole.php' for inclusion (include_path='.:/opt/php54/lib/php') in /home2/ytadvise/public_html/wp-content/themes/wpex-thoughts/header.php on line 13

Thanks for the help,
Alex

Link to site: http://ytadvisers.com

Varun Sridharan on "WordPress Built In Dialog Box For My Plugin"

$
0
0

I want to using wordpress defaults model box in post edit page

[wp-admin/post.php?post=368&action=edit]

Model I wanted : Model I wanted

i tried the following instruction in https://codex.wordpress.org/Javascript_Reference/ThickBox

http://i.stack.imgur.com/nGlNK.png

Code I Entered

<div id="my-content-id" style="display:none;">  <p> This is my hidden content! It will appear in ThickBox when the link is clicked. </p>
</div>

I want to control my model with javascript and also needed tab view in that model like

[Media Model ]

Kindly help me to get this done

Viewing all 8245 articles
Browse latest View live


Latest Images