首页 \ 问答 \ 在wordpress中的白名单主页(Whitelist home page in wordpress)

在wordpress中的白名单主页(Whitelist home page in wordpress)

我正在使用强制登录wordpress插件来限制用户登录之前查看某些页面,但我想查看主页没有登录我想在白名单中添加主页,但它不工作我使用我的自定义主题。可以建议什么插件我应该使用/我应该为此做什么。

function my_forcelogin_whitelist( $whitelist ) {
            //$whitelist[] = 'http://localhost/wordpress/index.php/home/';
            //$whitelist[] = site_url( '/index.php/home/' );
              $whitelist[] = 'http://localhost/wordpress/index.php/';
              $whitelist[] = site_url( '/index.php/' );

        return $whitelist;
    }
    add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);

I am using force login wordpress plugin to restrict user to login before viewing certain pages but i want to view home page without login i am trying to add home page in whitelist but its not working i am using my custom theme.Can you suggest what plugin should i use/what should i do for this purpose.

function my_forcelogin_whitelist( $whitelist ) {
            //$whitelist[] = 'http://localhost/wordpress/index.php/home/';
            //$whitelist[] = site_url( '/index.php/home/' );
              $whitelist[] = 'http://localhost/wordpress/index.php/';
              $whitelist[] = site_url( '/index.php/' );

        return $whitelist;
    }
    add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);

原文:https://stackoverflow.com/questions/45597626
更新时间:2023-06-30 19:06

最满意答案

从1.8.11升级到2.0.0后,我设法通过改变图像添加到PDF的方式来解决问题。

PDPageContentStream contentStream = ...;
PDDocument document = ...;
InputStream imageStream = this.getClass().getClassLoader().getResourceAsStream("image.jpg");
PDImageXObject image = JPEGFactory.createFromStream(document,imageStream);
contentStream.drawImage(image, 50, 700, 250, 67);

关键似乎是使用:

JPEGFactory.createFromStream()

代替:

PDImageXObject.createFromFile()

After upgrading from 1.8.11 to 2.0.0, I've managed to resolve the issue by changing the way the image was added to the PDF.

PDPageContentStream contentStream = ...;
PDDocument document = ...;
InputStream imageStream = this.getClass().getClassLoader().getResourceAsStream("image.jpg");
PDImageXObject image = JPEGFactory.createFromStream(document,imageStream);
contentStream.drawImage(image, 50, 700, 250, 67);

The key seems to be the use of:

JPEGFactory.createFromStream()

instead of:

PDImageXObject.createFromFile()

相关问答

更多
  • 你犯了两个错误: 保存文档后,您已关闭contentStream而不是之前。 您还没有设置字体。 适用于我的代码(删除了异常处理): PDDocument document; PDPage page; PDPageContentStream contentStream; document = new PDDocument(); page = new PDPage(); document.addPage(page); contentStream = new PDPageContentStream(docum ...
  • 从1.8.11升级到2.0.0后,我设法通过改变图像添加到PDF的方式来解决问题。 PDPageContentStream contentStream = ...; PDDocument document = ...; InputStream imageStream = this.getClass().getClassLoader().getResourceAsStream("image.jpg"); PDImageXObject image = JPEGFactory.createFromStream(d ...
  • 我能找到一个解决方案,但我仍然不明白使用流时出了什么问题。 详细: 虽然以下代码引发异常( java.io.IOException:错误:文件结束,预计行) : ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream mainDocStream = new FileInputStream(path...); InputStream additionalDocStream = new FileInputStream(path.. ...
  • 使用 BufferedImage img = page.convertToImage(BufferedImage.TYPE_INT_RGB, 300); 在PDFBox 1.8。*中,这将以300dpi呈现。 默认(您使用的)是144dpi。 因此,根据您的需要,使用大于或小于144的dpi参数。 use BufferedImage img = page.convertToImage(BufferedImage.TYPE_INT_RGB, 300); in PDFBox 1.8.*, this will ...
  • 如果您的意图是PDF上的A4大小的图片,那么我猜您会找到典型A4的实际大小(以像素为单位)。 另外你应该知道你要查看的图片的扩展名,如jpg,gif或bmp ... 从我在你的代码中看到的,图片的尺寸是10 X 700,我认为这是相当小的尺寸。 contentStream.drawImage(img, 10, 700); 而图片的扩展是:jpg InputStream in = new FileInputStream(new File("img.jpg")); 检查这些并返回以获取更多信息。 就这样。 ...
  • 正如评论中所讨论的:特定字体的PDFont对象应该只构造一次,并且可以在一个PDF的不同页面中重用。 字体应该是子集化的(即只嵌入使用的字形),使用PDType0Font.load() 。 这同样适用于PDXObjectImage对象,例如公司徽标:PDXObjectImage应创建一次,并在一个PDF的不同页面中重用。 不应在不同的PDF中使用PD对象。 As discussed in the comments: PDFont objects of a specific font should be co ...
  • 问题是你添加一个新的页面到文档 doc.addPage(new PDPage()); 但是然后为另一个不添加到文档中的新页面创建一个内容流: PDPageContentStream contentStream = new PDPageContentStream(doc, new PDPage(), true, false); 您应该为添加到文档中的页面创建内容流,例如: PDDocument doc = null; doc = new PDDocument(); PDPage page = new PD ...
  • 由于没有人回答,我自己在评论中尝试了我的建议。 第一个结果: import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.IOException; import java.lang.reflect.Field; import java.util.H ...
  • 如果查看日志记录输出(可能需要在您的环境中激活日志记录)。 你会看到很多像这样的条目(使用PDFBox 1.8.5生成): Jun 16, 2014 8:40:43 AM org.apache.pdfbox.pdmodel.font.PDSimpleFont drawString Warnung: Changing font on from to the default font Jun 16, 2014 8:40:43 AM org.apache ...
  • 您只需使用PdfMergeUtility.addSource(InputStream)方法从输入流而不是物理文件添加源。 通过快速浏览一下API,你可以做的就是使用PDDocument.save(OutputStream)方法将文件写入内存中的字节数组中,像这样的应该工作。 static byte[] doIt(String message) { PDDocument doc = new PDDocument(); // add the message ByteArrayOutputStr ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)