I am using mediaelement.js to play Audio in my Wordpress site. I'm having trouble getting it to function exactly like the player on the front page of the mediaelementjs site. Particularly, I want to add timestamps when the user hovers over the audio player so that they can more easily navigate to a particular time. The player is working fine otherwise.
A second, related question. Has anyone found an easy way to add links to particular time stamps in this player (e.g. clicking 1:00 would cause the video to jump to that place without reloading the page). I tried the plugin "Skip to timestamp" but could not get the shortcodes to execute properly within my PHP template.
Sorry I don't have any code up live yet. Here is the code to generate the player.
$attr = array(
'src' => 'myfilepath',
'loop' => '',
'autoplay' => '',
'preload' => 'none',
'features' => array('playpause','progress','current','duration','volume')
);
echo wp_audio_shortcode( $attr );
Related
I'm currently working on a gallery system using cakephp. In it, we have paginated each image album so each page contains a set number of images at most. I have attained this by using:
$this->paginate = array(
'conditions' => array(
'Item.album_id' => $id
),
'order' => array(
'Item.added' => 'desc'
),
'limit' => '50'
);
On my view controller. With this, I can show all the items on each page with no problems.
I'm currently, however, facing a single issue: I need to show, after all the items in the current page, a button that leads to the next page. This is not a problem, except that by design the button that says NEXT PAGE should have an item from the next page as its background.
I have looked around, trying to figure out a way to pull an item from the next page of a paginated system in cakephp without luck. Has anyone done this, or does anyone have a clue how to go about it?
You have to query the preview image manually in the current page.
To access the page number you can use $this->params in the action. Then you have to query images with 'limit' and 'page' parameters as mentioned in the documentation.
After that set the image URL like this:
$this->set('preview_image_url', $queried_url);
Then in the view use inline styling to set the background for the next button.
With Alto's help, I ended up doing this (Putting it here just in case anyone wonders exactly how I did it):
$CurrPage = $this->params['paging']['Item']['page'];
$NextParams = array(
'limit' => 1,
//'page' => $CurrPage + 1,
'order' => array(
'Item.added' => 'desc'
),
'offset' => $CurrPage*50
//'order' =>('rand()')
);
$NextImage = $this->Item->find('first', $NextParams);
$this->set('NextImage', $NextImage);
This gives me the first item from the following page, which is good enough for me. Note the commented 'order' =>('rand()') - I tried to grab a random item from the following page but, alas, it seems like Cake first scrambles all items and THEN paginates. There's probably a way around this, but for now this one did it for me.
Also, using 'page' => $CurrPage + 1 didn't seem to work, with the system instead returning a seemingly randomly chosen image. That's why I instead defaulted to using 'offset' => $CurrPage*50, where 50 is the amount of items per page I'm showing.
I recently started working for this company and I am trying to modify the php code that was already created to display blocks on a page. I am using my localhost and wamp to test and develop my code. the first block that I created worked as the only thing that I did was to copy and modify the title of the code but now that I am trying to do the same for second and for some reason is not working. on my drupal 6 localhost block page I could see the block that I created and the region assign to it but is still not visible in the page. What am I missing?
Below is the code that I am using. Any help will be appreciated.
on the Page specific visibility settings this is the php code :
<p><?php return _admin_block_visibility('breeding_race_results'); ?></p>
$blocks['race_results'] = array('info' => t('Race Results'),
'status' => 1,
'region' => 'middle',
'visibility' => 2,
'weight' => -100,
'pages' => '<?php return _admin_block_visibility(\'race_results\'); ?>',
);
case 'race_results':
$block['subject'] = t('Race Results');
$block['content'] = admin_race_results_block_content();
break;
Generally, in Drupal, you don't need to write a code to have things displayed. Use Drupal core blocks management (Structure > Blocks) or use Context module to tell the system where you want certain elements like blocks to appear (what page or what type of pages etc.). Also, use Views module to create a dynamic lists of things to be displayed anywhere in the system.
Also, if a block is not showing where it suppose to, add there some text text and check if that will work. You will want to figure out first if the problem is with the code in the block (that makes the results invisible) or the problem is that the block is not rendering at all.
I'm writing a PHP app that posts to users' feeds. The posts are showing up in the feeds, but the images I'm specifying aren't.
App is currently in sandbox mode, so not sure if that makes a difference.
Here is the data array I'm passing:
$data = array(
'message' => 'I just donated to ORGANIZATION to help end the needless killing of healthy animals.',
'name' => 'Each day over 10,000 healthy pets are killed. Together we can help change this.',
'caption' => 'petbucks.net',
'link' => 'http://petbucks.net',
'description' => 'Sponsorship of real homeless pets gives them the time they need to find a forever home.',
'picture' => 'http://dev.petbucks.net/img/default-donation.jpg',
'actions' => array(
array(
'name' => 'Visit us',
'link' => 'http://petbucks.net'
)
)
);
Facebook::api('/'.$uid.'/feed', 'post', $data);
Like I said, the post is appearing in the user's feed, but the picture isn't. If I inspect the source of where the URL should be, here is the image tag that appears:
<img class="shareMediaPhoto fbStoryAttachmentImage img" src="https://fbstatic-a.akamaihd.net/rsrc.php/v2/y4/r/-PAXP-deijE.gif" alt="" style="background-image: url(https://fbexternal-a.akamaihd.net/app_full_proxy.php?app=332280520247212&v=1&size=z&cksum=534f379420f4d890f47eebaa5bf15f4a&src=http%3A%2F%2Fdev.petbucks.net%2Fimg%2Fdefault-donation.jpg);">
Based on that, I'd say that it's receiving the picture URL just fine (you can see the real URL in the source of that background image), so it must be something else. Is it because of sandbox mode?
Any idea what's going on would be appreciated!
Update
There was some weird DNS issues going on, so those have been fixed. However, I am now seeing full-size images in my main news feed, but not smaller ones in my own newsfeed.
This is going to be hard to demonstrate without giving out access to my FB account, but as an example, take a look at this post which I've made public:
https://www.facebook.com/colin.viebrock/posts/10153814802000226?stream_ref=10
That image shows correctly for me when I'm logged into FB, but not for you I'm guessing. The URL it is trying to display is:
https://fbexternal-a.akamaihd.net/app_full_proxy.php?app=332280520247212&v=1&size=z&cksum=15a4249f3c830d8818ed66e793ba3156&src=https%3A%2F%2Fpetbucks.org%2Fimg%2Fdefault-donation.jpg
When it does show up, it's referencing this image:
https://fbexternal-a.akamaihd.net/safe_image.php?d=AQD1l81SkouNC200&w=154&h=154&url=https%3A%2F%2Fpetbucks.org%2Fimg%2Fdefault-donation.jpg&cfs=1&upscale
I have a classifieds website. The website is php based, and uses a mysql database.
Today, I have a sitemap which I have to update using an external php script.
This php script takes all classifieds from the database and creates an xml sitemap, fresh.
Problem is I have to do this manually, by first opening the php script, then waiting for it to complete, then submitting the sitemap to google again (even though the last step is optional I still do it).
I must also point out that even though I do submit this to google, it still isn't indexed (doesn't come up in the search results), which I want it to.
I want the classifieds to show up in google SERPS as soon as possible. Currently this is taking too long... Like a week or so.
Anyways, I need to know how to improve this method I have.
Should I open and write to the xml file on every new classified?
I hesitat to do that because this means the file is open almost all the time, because new classifieds are frequent, and sometimes there are several new classifieds at the same time, so how would this impact the opening and writing to file if the file is already in use etc etc...
Is there any other method, like submitting a php sitemap to google, and whenever google accesses this php file, a new xml is dynamically created?
Need some ideas on how to do this in best way please...
Also, question 2:
If I dont have any links to a specific page on my server, except for a link in a sitemap, will this page be indexed anyways?
Thanks
You are asking too much from Google. They aren't magic. Indexing the whole internet is a big task. And they aren't out there to do what you want. However, there are ways to get the google to notice things fasterish and also ways to get more up-to-the-moment searching through other means.
Step one. The xml sitemap is good, but it still helps to have a legit html everything-everywhere link list/map. This is because links are in general of higher importance than a site map. So many search engines get to them faster.
On that note, not being the only dood linking to your stuff is a HUGE help. The way indexing works means that getting on the list sooner means being updated in the google sooner. More links from outside means more points of entry.
Also, the way google determines how important your site is comes, in part, from how much others link to you. More importance means being crawled for new info more often.
Now, about real time search. The 'next big thing' in search is using real time items to get more relevant results. Google already is doing some of this for certain things. Sports, big events like the recent spacex launch, so on. They are using Buzz and Twitter. Others are using facebook and a few other services.
Encouraging your users to tweet/like your items can make you more real-time search-able. So the moment a new listing comes out, a bunch of links may show up on twitter, and then they are more likely to show up in a real-time search.
You could put the script that builds the sitemap in the logic loop that creates a new classified ad. That way every time a new ad is created, the sitemap is updated.
Google has advice on using HTTP ping service to submit the sitemap automatically. You can use PHP's Client URL Library to create the ping.
Finally, you're out of luck trying to get Google to index your pages faster. As they say in their Webmaster Guidelines (in the sitemap section):
Google doesn't guarantee that we'll crawl or index all of your URLs.
In short: until Google's algorithm starts to believe your website is HotShitTM, they won't index every URL, and will usually take their time about it, sitemap or not.
I have created a small sitemap for the Laravel website. Since its an MVC arch structure remains the same.
Routing part:
Route::get('/sitemap', ['as' => 'Sitemap index', 'uses' => 'SiteMapController#index']);
Route::get('/sitemap/page', ['as' => 'Sitemap page', 'uses' => 'SiteMapController#page']);
View part two files Index.php this will be main sitemap index file
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc><?php echo url('/') ?>/sitemap/page</loc>
<lastmod><?php echo date('c', time()); ?></lastmod>
</sitemap>
<sitemap>
<loc><?php echo url('/') ?>/sitemap/exchanges</loc>
<lastmod><?php echo date('c', time()); ?></lastmod>
</sitemap>
page.php this is accessory files for individual urlset
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($posts as $post) { ?>
<url><loc><?php echo url('/') ?>/<?php echo $post['uri']; ?></loc><lastmod><?php echo $post['time']; ?></lastmod> <changefreq><?php echo $post['freequency']; ?></changefreq>
<priority><?php echo $post['priority']; ?></priority>
</url>
<?php } ?>
</urlset>
Now, controller, where you run the show:SitemapController.php you can change the time based on the frequency and freshness of the updates you provide in the content.
class SiteMapController extends Controller {
public function index() {
return response()->view('sitemap.index')->header('Content-Type', 'text/xml');
}
public function page() {
$posts = array(
array("uri" => "", "time" => date('c', time()), "freequency" => "Daily", "priority" => "0.8"),
array("uri" => "about-us", "time" => "2018-08-17", "freequency" => "Monthly", "priority" => "0.5"),
array("uri" => "contact-us", "time" => "2018-08-17", "freequency" => "Monthly", "priority" => "0.5"),
array("uri" => "privacy-policy", "time" => "2018-08-17", "freequency" => "Monthly", "priority" => "0.5"),
array("uri" => "cookie-policy", "time" => "2018-08-17", "freequency" => "Monthly", "priority" => "0.5"),
array("uri" => "thank-you", "time" => "2018-08-17", "freequency" => "Monthly", "priority" => "0.5"),
);
return response()->view('sitemap.page', ['posts' => $posts])->header('Content-Type', 'text/xml');
}
}
so currently i'm using pods to create some individual pages for a log, filled with custom stuff.
now i want to use the comments-system for each of this pages e.g.:
mydomain.com/podpages/page1
mydomain.com/podpages/page2
mydomain.com/podpages/page3
this are not pages created with wordpress so simply adding <?php comments_template(); ?> is not working.
any ideas how to solve this problem?
thanks in advance
please leave a comment if something is unclear :)
When a comment is stored in the WordPress database, the ID of the post (or page) the comment relates to is also stored.
Trouble is, you're trying to save comments using WordPress, but for a page that it doesn't actually know about.
So, how about we create a WordPress page for each real page, but merely as a representation, so that your real pages and WordPress have a common ground for working with each other.
So, the plan here is to;
Load WordPress in the background on each of the 'real' pages.
See if a WordPress page representation already exists for the 'real' page
If it doesn't, create it, then and there
Trick WordPress into thinking we're actually viewing the representation
Carry on using all of WP's functions and 'template tags' as you would normally
This code should be somewhere at the beginning of the template file used to render your 'real' pages;
include ('../path/to/wp-load.php');
// remove query string from request
$request = preg_replace('#\?.*$#', '', $_SERVER['REQUEST_URI']);
// try and get the page name from the URI
preg_match('#podpages/([a-z0-9_-]+)#', $matches);
if ($matches && isset($matches[1])) {
$pagename = $matches[1];
// try and find the WP representation page
$query = new WP_Query(array('pagename' => $pagename));
if (!$query->have_posts()) {
// no WP page exists yet, so create one
$id = wp_insert_post(array(
'post_title' => $pagename,
'post_type' => 'page',
'post_status' => 'publish',
'post_name' => $pagename
));
if (!$id)
do_something(); // something went wrong
}
// this sets up the main WordPress query
// from now on, WordPress thinks you're viewing the representation page
}
UPDATE
I can't believe I was this stupid. Below should replace current code inside outer if;
// try and find the WP representation page - post_type IS required
$query = new WP_Query(array('name' => $pagename, 'post_type' => 'page'));
if (!$query->have_posts()) {
// no WP page exists yet, so create one
$id = wp_insert_post(array(
'post_title' => $pagename,
'post_type' => 'page',
'post_status' => 'publish',
'post_name' => $pagename,
'post_author' => 1, // failsafe
'post_content' => 'wp_insert_post needs content to complete'
));
}
// this sets up the main WordPress query
// from now on, WordPress thinks you're viewing the representation page
// post_type is a must!
wp(array('name' => $pagename, 'post_type' => 'page'));
// set up post
the_post();
P.S I think using the query_var name over pagename is better suited - it queries the slug, rather than the slug 'path'.
You'll also need to either place an input inside the form with name redirect_to and a value of the URL you'd like to redirect to, or, filter the redirect with a function hooked onto comment_post_redirect, returning the correct URL.
add
require('/path/to/wp-blog-header.php');
to include the wp files. this should give you all the functions/data you need.
Can you create pages in wordpress which display your log data? You might need a new template for this. WordPress will then have something to connect the comments to.
Do you need to use WordPress for this? If not, maybe something in this SO question helps: Unobtrusive, self-hosted comments function to put onto existing web pages
Just supply the wordpress-comment-part with a new ID - start with something your usual posts will never reach (100.000+ is your pages i.e.)
I don't know exactly if in wordpress it's a function (saveComment i.e.), but if it is so, just use it in your page with he custom ID.
You will nevertheless have to insert the Comments-form yourself.
And don't forget to modify the query that gets the news-entires that IDs over 100.000 are not entries.
Or you can write your own template that displays the standard-Worpress-stuff with IDs < 100.000, or else your pages.
Summed up, it should not be very difficult.
p.s.: If you just want to use the wordpress-login, then use any comment-system or make your own (it's an 1hour-thing) and authenticate / use the worpress-session.